[TS] Update auto-generated TS bindings
[ldk-java] / ts / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include "js-wasm.h"
4 #include <stdatomic.h>
5 #include <lightning.h>
6
7 // These should be provided...somehow...
8 void *memset(void *s, int c, size_t n);
9 void *memcpy(void *dest, const void *src, size_t n);
10 int memcmp(const void *s1, const void *s2, size_t n);
11
12 extern void __attribute__((noreturn)) abort(void);
13 static inline void assert(bool expression) {
14         if (!expression) { abort(); }
15 }
16
17 uint32_t __attribute__((export_name("test_bigint_pass_deadbeef0badf00d"))) test_bigint_pass_deadbeef0badf00d(uint64_t val) {
18         return val == 0xdeadbeef0badf00dULL;
19 }
20
21
22 void *malloc(size_t size);
23 void free(void *ptr);
24
25 #define MALLOC(a, _) malloc(a)
26 #define do_MALLOC(a, _b, _c) malloc(a)
27 #define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
28 #define DO_ASSERT(a) (void)(a)
29 #define CHECK(a)
30 #define CHECK_ACCESS(p)
31 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
32
33 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
34 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
35 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
36 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
37
38 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
39
40 #define DECL_ARR_TYPE(ty, name) \
41         struct name##array { \
42                 uint32_t arr_len; \
43                 ty elems[]; \
44         }; \
45         typedef struct name##array * name##Array; \
46         static inline name##Array init_##name##Array(size_t arr_len, int lineno) { \
47                 name##Array arr = (name##Array)do_MALLOC(arr_len * sizeof(ty) + sizeof(uint32_t), #name" array init", lineno); \
48                 arr->arr_len = arr_len; \
49                 return arr; \
50         }
51
52 DECL_ARR_TYPE(int64_t, int64_t);
53 DECL_ARR_TYPE(int8_t, int8_t);
54 DECL_ARR_TYPE(uint32_t, uint32_t);
55 DECL_ARR_TYPE(void*, ptr);
56 DECL_ARR_TYPE(char, char);
57 typedef charArray jstring;
58
59 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
60         charArray arr = init_charArray(len, __LINE__);
61         memcpy(arr->elems, chars, len);
62         return arr;
63 }
64 static inline LDKStr str_ref_to_owned_c(const jstring str) {
65         char* newchars = MALLOC(str->arr_len + 1, "String chars");
66         memcpy(newchars, str->elems, str->arr_len);
67         newchars[str->arr_len] = 0;
68         LDKStr res = {
69                 .chars = newchars,
70                 .len = str->arr_len,
71                 .chars_is_owned = true
72         };
73         return res;
74 }
75
76 typedef bool jboolean;
77
78 uint32_t __attribute__((export_name("TS_malloc"))) TS_malloc(uint32_t size) {
79         return (uint32_t)MALLOC(size, "JS-Called malloc");
80 }
81 void __attribute__((export_name("TS_free"))) TS_free(uint32_t ptr) {
82         FREE((void*)ptr);
83 }
84
85 jstring __attribute__((export_name("TS_get_ldk_c_bindings_version"))) TS_get_ldk_c_bindings_version() {
86         const char *res = check_get_ldk_bindings_version();
87         if (res == NULL) return NULL;
88         return str_ref_to_ts(res, strlen(res));
89 }
90 jstring __attribute__((export_name("TS_get_ldk_version"))) get_ldk_version() {
91         const char *res = check_get_ldk_version();
92         if (res == NULL) return NULL;
93         return str_ref_to_ts(res, strlen(res));
94 }
95 #include "version.c"
96 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
97 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
98         switch (ord) {
99                 case 0: return LDKAccessError_UnknownChain;
100                 case 1: return LDKAccessError_UnknownTx;
101         }
102         abort();
103 }
104 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
105         switch (val) {
106                 case LDKAccessError_UnknownChain: return 0;
107                 case LDKAccessError_UnknownTx: return 1;
108                 default: abort();
109         }
110 }
111 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_js(int32_t ord) {
112         switch (ord) {
113                 case 0: return LDKCOption_NoneZ_Some;
114                 case 1: return LDKCOption_NoneZ_None;
115         }
116         abort();
117 }
118 static inline int32_t LDKCOption_NoneZ_to_js(LDKCOption_NoneZ val) {
119         switch (val) {
120                 case LDKCOption_NoneZ_Some: return 0;
121                 case LDKCOption_NoneZ_None: return 1;
122                 default: abort();
123         }
124 }
125 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
126         switch (ord) {
127                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
128                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
129         }
130         abort();
131 }
132 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
133         switch (val) {
134                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
135                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
136                 default: abort();
137         }
138 }
139 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
140         switch (ord) {
141                 case 0: return LDKConfirmationTarget_Background;
142                 case 1: return LDKConfirmationTarget_Normal;
143                 case 2: return LDKConfirmationTarget_HighPriority;
144         }
145         abort();
146 }
147 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
148         switch (val) {
149                 case LDKConfirmationTarget_Background: return 0;
150                 case LDKConfirmationTarget_Normal: return 1;
151                 case LDKConfirmationTarget_HighPriority: return 2;
152                 default: abort();
153         }
154 }
155 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
156         switch (ord) {
157                 case 0: return LDKCreationError_DescriptionTooLong;
158                 case 1: return LDKCreationError_RouteTooLong;
159                 case 2: return LDKCreationError_TimestampOutOfBounds;
160                 case 3: return LDKCreationError_InvalidAmount;
161                 case 4: return LDKCreationError_MissingRouteHints;
162         }
163         abort();
164 }
165 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
166         switch (val) {
167                 case LDKCreationError_DescriptionTooLong: return 0;
168                 case LDKCreationError_RouteTooLong: return 1;
169                 case LDKCreationError_TimestampOutOfBounds: return 2;
170                 case LDKCreationError_InvalidAmount: return 3;
171                 case LDKCreationError_MissingRouteHints: return 4;
172                 default: abort();
173         }
174 }
175 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
176         switch (ord) {
177                 case 0: return LDKCurrency_Bitcoin;
178                 case 1: return LDKCurrency_BitcoinTestnet;
179                 case 2: return LDKCurrency_Regtest;
180                 case 3: return LDKCurrency_Simnet;
181                 case 4: return LDKCurrency_Signet;
182         }
183         abort();
184 }
185 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
186         switch (val) {
187                 case LDKCurrency_Bitcoin: return 0;
188                 case LDKCurrency_BitcoinTestnet: return 1;
189                 case LDKCurrency_Regtest: return 2;
190                 case LDKCurrency_Simnet: return 3;
191                 case LDKCurrency_Signet: return 4;
192                 default: abort();
193         }
194 }
195 static inline LDKIOError LDKIOError_from_js(int32_t ord) {
196         switch (ord) {
197                 case 0: return LDKIOError_NotFound;
198                 case 1: return LDKIOError_PermissionDenied;
199                 case 2: return LDKIOError_ConnectionRefused;
200                 case 3: return LDKIOError_ConnectionReset;
201                 case 4: return LDKIOError_ConnectionAborted;
202                 case 5: return LDKIOError_NotConnected;
203                 case 6: return LDKIOError_AddrInUse;
204                 case 7: return LDKIOError_AddrNotAvailable;
205                 case 8: return LDKIOError_BrokenPipe;
206                 case 9: return LDKIOError_AlreadyExists;
207                 case 10: return LDKIOError_WouldBlock;
208                 case 11: return LDKIOError_InvalidInput;
209                 case 12: return LDKIOError_InvalidData;
210                 case 13: return LDKIOError_TimedOut;
211                 case 14: return LDKIOError_WriteZero;
212                 case 15: return LDKIOError_Interrupted;
213                 case 16: return LDKIOError_Other;
214                 case 17: return LDKIOError_UnexpectedEof;
215         }
216         abort();
217 }
218 static inline int32_t LDKIOError_to_js(LDKIOError val) {
219         switch (val) {
220                 case LDKIOError_NotFound: return 0;
221                 case LDKIOError_PermissionDenied: return 1;
222                 case LDKIOError_ConnectionRefused: return 2;
223                 case LDKIOError_ConnectionReset: return 3;
224                 case LDKIOError_ConnectionAborted: return 4;
225                 case LDKIOError_NotConnected: return 5;
226                 case LDKIOError_AddrInUse: return 6;
227                 case LDKIOError_AddrNotAvailable: return 7;
228                 case LDKIOError_BrokenPipe: return 8;
229                 case LDKIOError_AlreadyExists: return 9;
230                 case LDKIOError_WouldBlock: return 10;
231                 case LDKIOError_InvalidInput: return 11;
232                 case LDKIOError_InvalidData: return 12;
233                 case LDKIOError_TimedOut: return 13;
234                 case LDKIOError_WriteZero: return 14;
235                 case LDKIOError_Interrupted: return 15;
236                 case LDKIOError_Other: return 16;
237                 case LDKIOError_UnexpectedEof: return 17;
238                 default: abort();
239         }
240 }
241 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
242         switch (ord) {
243                 case 0: return LDKLevel_Gossip;
244                 case 1: return LDKLevel_Trace;
245                 case 2: return LDKLevel_Debug;
246                 case 3: return LDKLevel_Info;
247                 case 4: return LDKLevel_Warn;
248                 case 5: return LDKLevel_Error;
249         }
250         abort();
251 }
252 static inline int32_t LDKLevel_to_js(LDKLevel val) {
253         switch (val) {
254                 case LDKLevel_Gossip: return 0;
255                 case LDKLevel_Trace: return 1;
256                 case LDKLevel_Debug: return 2;
257                 case LDKLevel_Info: return 3;
258                 case LDKLevel_Warn: return 4;
259                 case LDKLevel_Error: return 5;
260                 default: abort();
261         }
262 }
263 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
264         switch (ord) {
265                 case 0: return LDKNetwork_Bitcoin;
266                 case 1: return LDKNetwork_Testnet;
267                 case 2: return LDKNetwork_Regtest;
268                 case 3: return LDKNetwork_Signet;
269         }
270         abort();
271 }
272 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
273         switch (val) {
274                 case LDKNetwork_Bitcoin: return 0;
275                 case LDKNetwork_Testnet: return 1;
276                 case LDKNetwork_Regtest: return 2;
277                 case LDKNetwork_Signet: return 3;
278                 default: abort();
279         }
280 }
281 static inline LDKRecipient LDKRecipient_from_js(int32_t ord) {
282         switch (ord) {
283                 case 0: return LDKRecipient_Node;
284                 case 1: return LDKRecipient_PhantomNode;
285         }
286         abort();
287 }
288 static inline int32_t LDKRecipient_to_js(LDKRecipient val) {
289         switch (val) {
290                 case LDKRecipient_Node: return 0;
291                 case LDKRecipient_PhantomNode: return 1;
292                 default: abort();
293         }
294 }
295 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
296         switch (ord) {
297                 case 0: return LDKSecp256k1Error_IncorrectSignature;
298                 case 1: return LDKSecp256k1Error_InvalidMessage;
299                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
300                 case 3: return LDKSecp256k1Error_InvalidSignature;
301                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
302                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
303                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
304                 case 7: return LDKSecp256k1Error_InvalidTweak;
305                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
306                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
307                 case 10: return LDKSecp256k1Error_InvalidParityValue;
308         }
309         abort();
310 }
311 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
312         switch (val) {
313                 case LDKSecp256k1Error_IncorrectSignature: return 0;
314                 case LDKSecp256k1Error_InvalidMessage: return 1;
315                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
316                 case LDKSecp256k1Error_InvalidSignature: return 3;
317                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
318                 case LDKSecp256k1Error_InvalidSharedSecret: return 5;
319                 case LDKSecp256k1Error_InvalidRecoveryId: return 6;
320                 case LDKSecp256k1Error_InvalidTweak: return 7;
321                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
322                 case LDKSecp256k1Error_InvalidPublicKeySum: return 9;
323                 case LDKSecp256k1Error_InvalidParityValue: return 10;
324                 default: abort();
325         }
326 }
327 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
328         switch (ord) {
329                 case 0: return LDKSemanticError_NoPaymentHash;
330                 case 1: return LDKSemanticError_MultiplePaymentHashes;
331                 case 2: return LDKSemanticError_NoDescription;
332                 case 3: return LDKSemanticError_MultipleDescriptions;
333                 case 4: return LDKSemanticError_NoPaymentSecret;
334                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
335                 case 6: return LDKSemanticError_InvalidFeatures;
336                 case 7: return LDKSemanticError_InvalidRecoveryId;
337                 case 8: return LDKSemanticError_InvalidSignature;
338                 case 9: return LDKSemanticError_ImpreciseAmount;
339         }
340         abort();
341 }
342 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
343         switch (val) {
344                 case LDKSemanticError_NoPaymentHash: return 0;
345                 case LDKSemanticError_MultiplePaymentHashes: return 1;
346                 case LDKSemanticError_NoDescription: return 2;
347                 case LDKSemanticError_MultipleDescriptions: return 3;
348                 case LDKSemanticError_NoPaymentSecret: return 4;
349                 case LDKSemanticError_MultiplePaymentSecrets: return 5;
350                 case LDKSemanticError_InvalidFeatures: return 6;
351                 case LDKSemanticError_InvalidRecoveryId: return 7;
352                 case LDKSemanticError_InvalidSignature: return 8;
353                 case LDKSemanticError_ImpreciseAmount: return 9;
354                 default: abort();
355         }
356 }
357 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
358         switch (ord) {
359                 case 0: return LDKSiPrefix_Milli;
360                 case 1: return LDKSiPrefix_Micro;
361                 case 2: return LDKSiPrefix_Nano;
362                 case 3: return LDKSiPrefix_Pico;
363         }
364         abort();
365 }
366 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
367         switch (val) {
368                 case LDKSiPrefix_Milli: return 0;
369                 case LDKSiPrefix_Micro: return 1;
370                 case LDKSiPrefix_Nano: return 2;
371                 case LDKSiPrefix_Pico: return 3;
372                 default: abort();
373         }
374 }
375 uint32_t __attribute__((export_name("TS_LDKBech32Error_ty_from_ptr"))) TS_LDKBech32Error_ty_from_ptr(uint32_t ptr) {
376         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
377         switch(obj->tag) {
378                 case LDKBech32Error_MissingSeparator: return 0;
379                 case LDKBech32Error_InvalidChecksum: return 1;
380                 case LDKBech32Error_InvalidLength: return 2;
381                 case LDKBech32Error_InvalidChar: return 3;
382                 case LDKBech32Error_InvalidData: return 4;
383                 case LDKBech32Error_InvalidPadding: return 5;
384                 case LDKBech32Error_MixedCase: return 6;
385                 default: abort();
386         }
387 }
388 int32_t __attribute__((export_name("TS_LDKBech32Error_InvalidChar_get_invalid_char"))) TS_LDKBech32Error_InvalidChar_get_invalid_char(uint32_t ptr) {
389         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
390         assert(obj->tag == LDKBech32Error_InvalidChar);
391                         int32_t invalid_char_conv = obj->invalid_char;
392         return invalid_char_conv;
393 }
394 int8_t __attribute__((export_name("TS_LDKBech32Error_InvalidData_get_invalid_data"))) TS_LDKBech32Error_InvalidData_get_invalid_data(uint32_t ptr) {
395         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
396         assert(obj->tag == LDKBech32Error_InvalidData);
397                         int8_t invalid_data_conv = obj->invalid_data;
398         return invalid_data_conv;
399 }
400 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
401         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
402         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
403         return ret;
404 }
405 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) {
406         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
407         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
408         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
409         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
410         CVec_u8Z_free(ret_var);
411         return ret_arr;
412 }
413
414 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) {
415         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
416         int64_t ret_conv = TxOut_get_value(thing_conv);
417         return ret_conv;
418 }
419
420 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
421 CHECK(owner->result_ok);
422         return *owner->contents.result;
423 }
424 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_ok"))) TS_CResult_NoneNoneZ_get_ok(uint32_t owner) {
425         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
426         CResult_NoneNoneZ_get_ok(owner_conv);
427 }
428
429 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
430 CHECK(!owner->result_ok);
431         return *owner->contents.err;
432 }
433 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_err"))) TS_CResult_NoneNoneZ_get_err(uint32_t owner) {
434         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
435         CResult_NoneNoneZ_get_err(owner_conv);
436 }
437
438 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
439 CHECK(owner->result_ok);
440         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
441 }
442 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(uint32_t owner) {
443         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
444         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
445         uint32_t ret_ref = 0;
446         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
447         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
449         ret_ref = (uintptr_t)ret_var.inner;
450         if (ret_var.is_owned) {
451                 ret_ref |= 1;
452         }
453         return ret_ref;
454 }
455
456 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
457 CHECK(!owner->result_ok);
458         return DecodeError_clone(&*owner->contents.err);
459 }
460 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(uint32_t owner) {
461         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
462         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
463         uint32_t ret_ref = 0;
464         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
465         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
467         ret_ref = (uintptr_t)ret_var.inner;
468         if (ret_var.is_owned) {
469                 ret_ref |= 1;
470         }
471         return ret_ref;
472 }
473
474 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
475 CHECK(owner->result_ok);
476         return *owner->contents.result;
477 }
478 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_ok"))) TS_CResult_SecretKeyErrorZ_get_ok(uint32_t owner) {
479         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
480         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
481         memcpy(ret_arr->elems, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes, 32);
482         return ret_arr;
483 }
484
485 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
486 CHECK(!owner->result_ok);
487         return *owner->contents.err;
488 }
489 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_err"))) TS_CResult_SecretKeyErrorZ_get_err(uint32_t owner) {
490         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
491         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_SecretKeyErrorZ_get_err(owner_conv));
492         return ret_conv;
493 }
494
495 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
496 CHECK(owner->result_ok);
497         return *owner->contents.result;
498 }
499 int8_tArray  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_ok"))) TS_CResult_PublicKeyErrorZ_get_ok(uint32_t owner) {
500         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
501         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
502         memcpy(ret_arr->elems, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form, 33);
503         return ret_arr;
504 }
505
506 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
507 CHECK(!owner->result_ok);
508         return *owner->contents.err;
509 }
510 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_err"))) TS_CResult_PublicKeyErrorZ_get_err(uint32_t owner) {
511         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
512         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PublicKeyErrorZ_get_err(owner_conv));
513         return ret_conv;
514 }
515
516 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
517 CHECK(owner->result_ok);
518         return TxCreationKeys_clone(&*owner->contents.result);
519 }
520 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t owner) {
521         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
522         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
523         uint32_t ret_ref = 0;
524         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
525         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
527         ret_ref = (uintptr_t)ret_var.inner;
528         if (ret_var.is_owned) {
529                 ret_ref |= 1;
530         }
531         return ret_ref;
532 }
533
534 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
535 CHECK(!owner->result_ok);
536         return DecodeError_clone(&*owner->contents.err);
537 }
538 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t owner) {
539         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
540         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
541         uint32_t ret_ref = 0;
542         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
543         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
545         ret_ref = (uintptr_t)ret_var.inner;
546         if (ret_var.is_owned) {
547                 ret_ref |= 1;
548         }
549         return ret_ref;
550 }
551
552 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
553 CHECK(owner->result_ok);
554         return ChannelPublicKeys_clone(&*owner->contents.result);
555 }
556 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t owner) {
557         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
558         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
559         uint32_t ret_ref = 0;
560         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
561         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
563         ret_ref = (uintptr_t)ret_var.inner;
564         if (ret_var.is_owned) {
565                 ret_ref |= 1;
566         }
567         return ret_ref;
568 }
569
570 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
571 CHECK(!owner->result_ok);
572         return DecodeError_clone(&*owner->contents.err);
573 }
574 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t owner) {
575         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
576         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
577         uint32_t ret_ref = 0;
578         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
579         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
581         ret_ref = (uintptr_t)ret_var.inner;
582         if (ret_var.is_owned) {
583                 ret_ref |= 1;
584         }
585         return ret_ref;
586 }
587
588 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
589 CHECK(owner->result_ok);
590         return TxCreationKeys_clone(&*owner->contents.result);
591 }
592 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_ok"))) TS_CResult_TxCreationKeysErrorZ_get_ok(uint32_t owner) {
593         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
594         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
595         uint32_t ret_ref = 0;
596         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
597         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
599         ret_ref = (uintptr_t)ret_var.inner;
600         if (ret_var.is_owned) {
601                 ret_ref |= 1;
602         }
603         return ret_ref;
604 }
605
606 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
607 CHECK(!owner->result_ok);
608         return *owner->contents.err;
609 }
610 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_err"))) TS_CResult_TxCreationKeysErrorZ_get_err(uint32_t owner) {
611         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
612         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_TxCreationKeysErrorZ_get_err(owner_conv));
613         return ret_conv;
614 }
615
616 uint32_t __attribute__((export_name("TS_LDKCOption_u32Z_ty_from_ptr"))) TS_LDKCOption_u32Z_ty_from_ptr(uint32_t ptr) {
617         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
618         switch(obj->tag) {
619                 case LDKCOption_u32Z_Some: return 0;
620                 case LDKCOption_u32Z_None: return 1;
621                 default: abort();
622         }
623 }
624 int32_t __attribute__((export_name("TS_LDKCOption_u32Z_Some_get_some"))) TS_LDKCOption_u32Z_Some_get_some(uint32_t ptr) {
625         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
626         assert(obj->tag == LDKCOption_u32Z_Some);
627                         int32_t some_conv = obj->some;
628         return some_conv;
629 }
630 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
631 CHECK(owner->result_ok);
632         return HTLCOutputInCommitment_clone(&*owner->contents.result);
633 }
634 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t owner) {
635         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
636         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
637         uint32_t ret_ref = 0;
638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
641         ret_ref = (uintptr_t)ret_var.inner;
642         if (ret_var.is_owned) {
643                 ret_ref |= 1;
644         }
645         return ret_ref;
646 }
647
648 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
649 CHECK(!owner->result_ok);
650         return DecodeError_clone(&*owner->contents.err);
651 }
652 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t owner) {
653         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
654         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
655         uint32_t ret_ref = 0;
656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
659         ret_ref = (uintptr_t)ret_var.inner;
660         if (ret_var.is_owned) {
661                 ret_ref |= 1;
662         }
663         return ret_ref;
664 }
665
666 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
667 CHECK(owner->result_ok);
668         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
669 }
670 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
671         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
672         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
673         uint32_t ret_ref = 0;
674         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
675         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
677         ret_ref = (uintptr_t)ret_var.inner;
678         if (ret_var.is_owned) {
679                 ret_ref |= 1;
680         }
681         return ret_ref;
682 }
683
684 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
685 CHECK(!owner->result_ok);
686         return DecodeError_clone(&*owner->contents.err);
687 }
688 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
689         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
690         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
691         uint32_t ret_ref = 0;
692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
695         ret_ref = (uintptr_t)ret_var.inner;
696         if (ret_var.is_owned) {
697                 ret_ref |= 1;
698         }
699         return ret_ref;
700 }
701
702 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
703 CHECK(owner->result_ok);
704         return ChannelTransactionParameters_clone(&*owner->contents.result);
705 }
706 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
707         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
708         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
709         uint32_t ret_ref = 0;
710         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
711         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
713         ret_ref = (uintptr_t)ret_var.inner;
714         if (ret_var.is_owned) {
715                 ret_ref |= 1;
716         }
717         return ret_ref;
718 }
719
720 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
721 CHECK(!owner->result_ok);
722         return DecodeError_clone(&*owner->contents.err);
723 }
724 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
725         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
726         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
727         uint32_t ret_ref = 0;
728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
731         ret_ref = (uintptr_t)ret_var.inner;
732         if (ret_var.is_owned) {
733                 ret_ref |= 1;
734         }
735         return ret_ref;
736 }
737
738 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
739 CHECK(owner->result_ok);
740         return HolderCommitmentTransaction_clone(&*owner->contents.result);
741 }
742 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
743         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
744         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
745         uint32_t ret_ref = 0;
746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
749         ret_ref = (uintptr_t)ret_var.inner;
750         if (ret_var.is_owned) {
751                 ret_ref |= 1;
752         }
753         return ret_ref;
754 }
755
756 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
757 CHECK(!owner->result_ok);
758         return DecodeError_clone(&*owner->contents.err);
759 }
760 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
761         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
762         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
763         uint32_t ret_ref = 0;
764         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
765         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
767         ret_ref = (uintptr_t)ret_var.inner;
768         if (ret_var.is_owned) {
769                 ret_ref |= 1;
770         }
771         return ret_ref;
772 }
773
774 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
775 CHECK(owner->result_ok);
776         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
777 }
778 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
779         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
780         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
781         uint32_t ret_ref = 0;
782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
785         ret_ref = (uintptr_t)ret_var.inner;
786         if (ret_var.is_owned) {
787                 ret_ref |= 1;
788         }
789         return ret_ref;
790 }
791
792 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
793 CHECK(!owner->result_ok);
794         return DecodeError_clone(&*owner->contents.err);
795 }
796 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
797         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
798         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
799         uint32_t ret_ref = 0;
800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
803         ret_ref = (uintptr_t)ret_var.inner;
804         if (ret_var.is_owned) {
805                 ret_ref |= 1;
806         }
807         return ret_ref;
808 }
809
810 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
811 CHECK(owner->result_ok);
812         return &*owner->contents.result;
813 }
814 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t owner) {
815         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
816         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
817         uint32_t ret_ref = 0;
818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
821         ret_ref = (uintptr_t)ret_var.inner & ~1;
822         return ret_ref;
823 }
824
825 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
826 CHECK(!owner->result_ok);
827         return *owner->contents.err;
828 }
829 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_err"))) TS_CResult_TrustedClosingTransactionNoneZ_get_err(uint32_t owner) {
830         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
831         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
832 }
833
834 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
835 CHECK(owner->result_ok);
836         return CommitmentTransaction_clone(&*owner->contents.result);
837 }
838 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
839         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
840         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
841         uint32_t ret_ref = 0;
842         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
843         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
845         ret_ref = (uintptr_t)ret_var.inner;
846         if (ret_var.is_owned) {
847                 ret_ref |= 1;
848         }
849         return ret_ref;
850 }
851
852 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
853 CHECK(!owner->result_ok);
854         return DecodeError_clone(&*owner->contents.err);
855 }
856 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
857         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
858         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
859         uint32_t ret_ref = 0;
860         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
861         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
863         ret_ref = (uintptr_t)ret_var.inner;
864         if (ret_var.is_owned) {
865                 ret_ref |= 1;
866         }
867         return ret_ref;
868 }
869
870 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
871 CHECK(owner->result_ok);
872         return &*owner->contents.result;
873 }
874 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t owner) {
875         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
876         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
877         uint32_t ret_ref = 0;
878         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
879         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
881         ret_ref = (uintptr_t)ret_var.inner & ~1;
882         return ret_ref;
883 }
884
885 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
886 CHECK(!owner->result_ok);
887         return *owner->contents.err;
888 }
889 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t owner) {
890         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
891         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
892 }
893
894 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
895 CHECK(owner->result_ok);
896         return *owner->contents.result;
897 }
898 ptrArray  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_ok"))) TS_CResult_CVec_SignatureZNoneZ_get_ok(uint32_t owner) {
899         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
900         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
901         ptrArray ret_arr = NULL;
902         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
903         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
904         for (size_t m = 0; m < ret_var.datalen; m++) {
905                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
906                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
907                 ret_arr_ptr[m] = ret_conv_12_arr;
908         }
909         
910         return ret_arr;
911 }
912
913 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
914 CHECK(!owner->result_ok);
915         return *owner->contents.err;
916 }
917 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_err"))) TS_CResult_CVec_SignatureZNoneZ_get_err(uint32_t owner) {
918         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
919         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
920 }
921
922 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
923 CHECK(owner->result_ok);
924         return ShutdownScript_clone(&*owner->contents.result);
925 }
926 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t owner) {
927         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
928         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
929         uint32_t ret_ref = 0;
930         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
931         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
932         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
933         ret_ref = (uintptr_t)ret_var.inner;
934         if (ret_var.is_owned) {
935                 ret_ref |= 1;
936         }
937         return ret_ref;
938 }
939
940 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
941 CHECK(!owner->result_ok);
942         return DecodeError_clone(&*owner->contents.err);
943 }
944 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t owner) {
945         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
946         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
947         uint32_t ret_ref = 0;
948         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
949         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
951         ret_ref = (uintptr_t)ret_var.inner;
952         if (ret_var.is_owned) {
953                 ret_ref |= 1;
954         }
955         return ret_ref;
956 }
957
958 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
959 CHECK(owner->result_ok);
960         return ShutdownScript_clone(&*owner->contents.result);
961 }
962 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t owner) {
963         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
964         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
965         uint32_t ret_ref = 0;
966         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
967         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
969         ret_ref = (uintptr_t)ret_var.inner;
970         if (ret_var.is_owned) {
971                 ret_ref |= 1;
972         }
973         return ret_ref;
974 }
975
976 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
977 CHECK(!owner->result_ok);
978         return InvalidShutdownScript_clone(&*owner->contents.err);
979 }
980 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t owner) {
981         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
982         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
983         uint32_t ret_ref = 0;
984         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
985         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
987         ret_ref = (uintptr_t)ret_var.inner;
988         if (ret_var.is_owned) {
989                 ret_ref |= 1;
990         }
991         return ret_ref;
992 }
993
994 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
995 CHECK(owner->result_ok);
996         return RouteHop_clone(&*owner->contents.result);
997 }
998 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHopDecodeErrorZ_get_ok(uint32_t owner) {
999         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1000         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
1001         uint32_t ret_ref = 0;
1002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1005         ret_ref = (uintptr_t)ret_var.inner;
1006         if (ret_var.is_owned) {
1007                 ret_ref |= 1;
1008         }
1009         return ret_ref;
1010 }
1011
1012 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1013 CHECK(!owner->result_ok);
1014         return DecodeError_clone(&*owner->contents.err);
1015 }
1016 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_err"))) TS_CResult_RouteHopDecodeErrorZ_get_err(uint32_t owner) {
1017         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1018         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1019         uint32_t ret_ref = 0;
1020         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1021         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1023         ret_ref = (uintptr_t)ret_var.inner;
1024         if (ret_var.is_owned) {
1025                 ret_ref |= 1;
1026         }
1027         return ret_ref;
1028 }
1029
1030 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1031         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1032         for (size_t i = 0; i < ret.datalen; i++) {
1033                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1034         }
1035         return ret;
1036 }
1037 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1038         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1039         for (size_t i = 0; i < ret.datalen; i++) {
1040                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1041         }
1042         return ret;
1043 }
1044 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1045 CHECK(owner->result_ok);
1046         return Route_clone(&*owner->contents.result);
1047 }
1048 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_ok"))) TS_CResult_RouteDecodeErrorZ_get_ok(uint32_t owner) {
1049         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1050         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1051         uint32_t ret_ref = 0;
1052         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1053         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1055         ret_ref = (uintptr_t)ret_var.inner;
1056         if (ret_var.is_owned) {
1057                 ret_ref |= 1;
1058         }
1059         return ret_ref;
1060 }
1061
1062 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1063 CHECK(!owner->result_ok);
1064         return DecodeError_clone(&*owner->contents.err);
1065 }
1066 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_err"))) TS_CResult_RouteDecodeErrorZ_get_err(uint32_t owner) {
1067         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1068         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1069         uint32_t ret_ref = 0;
1070         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1071         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1073         ret_ref = (uintptr_t)ret_var.inner;
1074         if (ret_var.is_owned) {
1075                 ret_ref |= 1;
1076         }
1077         return ret_ref;
1078 }
1079
1080 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1081 CHECK(owner->result_ok);
1082         return RouteParameters_clone(&*owner->contents.result);
1083 }
1084 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_ok"))) TS_CResult_RouteParametersDecodeErrorZ_get_ok(uint32_t owner) {
1085         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1086         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1087         uint32_t ret_ref = 0;
1088         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1089         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1091         ret_ref = (uintptr_t)ret_var.inner;
1092         if (ret_var.is_owned) {
1093                 ret_ref |= 1;
1094         }
1095         return ret_ref;
1096 }
1097
1098 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1099 CHECK(!owner->result_ok);
1100         return DecodeError_clone(&*owner->contents.err);
1101 }
1102 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_err"))) TS_CResult_RouteParametersDecodeErrorZ_get_err(uint32_t owner) {
1103         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1104         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1105         uint32_t ret_ref = 0;
1106         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1107         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1109         ret_ref = (uintptr_t)ret_var.inner;
1110         if (ret_var.is_owned) {
1111                 ret_ref |= 1;
1112         }
1113         return ret_ref;
1114 }
1115
1116 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1117         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1118         for (size_t i = 0; i < ret.datalen; i++) {
1119                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1120         }
1121         return ret;
1122 }
1123 uint32_t __attribute__((export_name("TS_LDKCOption_u64Z_ty_from_ptr"))) TS_LDKCOption_u64Z_ty_from_ptr(uint32_t ptr) {
1124         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1125         switch(obj->tag) {
1126                 case LDKCOption_u64Z_Some: return 0;
1127                 case LDKCOption_u64Z_None: return 1;
1128                 default: abort();
1129         }
1130 }
1131 int64_t __attribute__((export_name("TS_LDKCOption_u64Z_Some_get_some"))) TS_LDKCOption_u64Z_Some_get_some(uint32_t ptr) {
1132         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1133         assert(obj->tag == LDKCOption_u64Z_Some);
1134                         int64_t some_conv = obj->some;
1135         return some_conv;
1136 }
1137 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1138 CHECK(owner->result_ok);
1139         return PaymentParameters_clone(&*owner->contents.result);
1140 }
1141 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_get_ok(uint32_t owner) {
1142         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1143         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1144         uint32_t ret_ref = 0;
1145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1148         ret_ref = (uintptr_t)ret_var.inner;
1149         if (ret_var.is_owned) {
1150                 ret_ref |= 1;
1151         }
1152         return ret_ref;
1153 }
1154
1155 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1156 CHECK(!owner->result_ok);
1157         return DecodeError_clone(&*owner->contents.err);
1158 }
1159 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_err"))) TS_CResult_PaymentParametersDecodeErrorZ_get_err(uint32_t owner) {
1160         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1161         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1162         uint32_t ret_ref = 0;
1163         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1164         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1166         ret_ref = (uintptr_t)ret_var.inner;
1167         if (ret_var.is_owned) {
1168                 ret_ref |= 1;
1169         }
1170         return ret_ref;
1171 }
1172
1173 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1174         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1175         for (size_t i = 0; i < ret.datalen; i++) {
1176                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1177         }
1178         return ret;
1179 }
1180 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1181 CHECK(owner->result_ok);
1182         return RouteHint_clone(&*owner->contents.result);
1183 }
1184 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_ok"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint32_t owner) {
1185         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1186         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1187         uint32_t ret_ref = 0;
1188         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1189         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1191         ret_ref = (uintptr_t)ret_var.inner;
1192         if (ret_var.is_owned) {
1193                 ret_ref |= 1;
1194         }
1195         return ret_ref;
1196 }
1197
1198 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1199 CHECK(!owner->result_ok);
1200         return DecodeError_clone(&*owner->contents.err);
1201 }
1202 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_err"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint32_t owner) {
1203         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1204         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1205         uint32_t ret_ref = 0;
1206         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1207         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1209         ret_ref = (uintptr_t)ret_var.inner;
1210         if (ret_var.is_owned) {
1211                 ret_ref |= 1;
1212         }
1213         return ret_ref;
1214 }
1215
1216 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1217 CHECK(owner->result_ok);
1218         return RouteHintHop_clone(&*owner->contents.result);
1219 }
1220 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t owner) {
1221         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1222         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1223         uint32_t ret_ref = 0;
1224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1227         ret_ref = (uintptr_t)ret_var.inner;
1228         if (ret_var.is_owned) {
1229                 ret_ref |= 1;
1230         }
1231         return ret_ref;
1232 }
1233
1234 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1235 CHECK(!owner->result_ok);
1236         return DecodeError_clone(&*owner->contents.err);
1237 }
1238 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_err"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint32_t owner) {
1239         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1240         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1241         uint32_t ret_ref = 0;
1242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1245         ret_ref = (uintptr_t)ret_var.inner;
1246         if (ret_var.is_owned) {
1247                 ret_ref |= 1;
1248         }
1249         return ret_ref;
1250 }
1251
1252 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1253         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1254         for (size_t i = 0; i < ret.datalen; i++) {
1255                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1256         }
1257         return ret;
1258 }
1259 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1260 CHECK(owner->result_ok);
1261         return Route_clone(&*owner->contents.result);
1262 }
1263 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_ok"))) TS_CResult_RouteLightningErrorZ_get_ok(uint32_t owner) {
1264         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1265         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1266         uint32_t ret_ref = 0;
1267         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1268         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1270         ret_ref = (uintptr_t)ret_var.inner;
1271         if (ret_var.is_owned) {
1272                 ret_ref |= 1;
1273         }
1274         return ret_ref;
1275 }
1276
1277 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1278 CHECK(!owner->result_ok);
1279         return LightningError_clone(&*owner->contents.err);
1280 }
1281 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_err"))) TS_CResult_RouteLightningErrorZ_get_err(uint32_t owner) {
1282         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1283         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1284         uint32_t ret_ref = 0;
1285         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1286         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1288         ret_ref = (uintptr_t)ret_var.inner;
1289         if (ret_var.is_owned) {
1290                 ret_ref |= 1;
1291         }
1292         return ret_ref;
1293 }
1294
1295 uint32_t __attribute__((export_name("TS_LDKPaymentPurpose_ty_from_ptr"))) TS_LDKPaymentPurpose_ty_from_ptr(uint32_t ptr) {
1296         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1297         switch(obj->tag) {
1298                 case LDKPaymentPurpose_InvoicePayment: return 0;
1299                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
1300                 default: abort();
1301         }
1302 }
1303 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(uint32_t ptr) {
1304         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1305         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1306                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1307                         memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
1308         return payment_preimage_arr;
1309 }
1310 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret(uint32_t ptr) {
1311         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1312         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1313                         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
1314                         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
1315         return payment_secret_arr;
1316 }
1317 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment"))) TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(uint32_t ptr) {
1318         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1319         assert(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
1320                         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
1321                         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
1322         return spontaneous_payment_arr;
1323 }
1324 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1325 CHECK(owner->result_ok);
1326         return PaymentPurpose_clone(&*owner->contents.result);
1327 }
1328 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_get_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_get_ok(uint32_t owner) {
1329         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1330         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
1331         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
1332         uint32_t ret_ref = (uintptr_t)ret_copy;
1333         return ret_ref;
1334 }
1335
1336 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1337 CHECK(!owner->result_ok);
1338         return DecodeError_clone(&*owner->contents.err);
1339 }
1340 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_get_err"))) TS_CResult_PaymentPurposeDecodeErrorZ_get_err(uint32_t owner) {
1341         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1342         LDKDecodeError ret_var = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
1343         uint32_t ret_ref = 0;
1344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1347         ret_ref = (uintptr_t)ret_var.inner;
1348         if (ret_var.is_owned) {
1349                 ret_ref |= 1;
1350         }
1351         return ret_ref;
1352 }
1353
1354 uint32_t __attribute__((export_name("TS_LDKClosureReason_ty_from_ptr"))) TS_LDKClosureReason_ty_from_ptr(uint32_t ptr) {
1355         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1356         switch(obj->tag) {
1357                 case LDKClosureReason_CounterpartyForceClosed: return 0;
1358                 case LDKClosureReason_HolderForceClosed: return 1;
1359                 case LDKClosureReason_CooperativeClosure: return 2;
1360                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
1361                 case LDKClosureReason_FundingTimedOut: return 4;
1362                 case LDKClosureReason_ProcessingError: return 5;
1363                 case LDKClosureReason_DisconnectedPeer: return 6;
1364                 case LDKClosureReason_OutdatedChannelManager: return 7;
1365                 default: abort();
1366         }
1367 }
1368 jstring __attribute__((export_name("TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg"))) TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(uint32_t ptr) {
1369         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1370         assert(obj->tag == LDKClosureReason_CounterpartyForceClosed);
1371                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1372                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1373         return peer_msg_conv;
1374 }
1375 jstring __attribute__((export_name("TS_LDKClosureReason_ProcessingError_get_err"))) TS_LDKClosureReason_ProcessingError_get_err(uint32_t ptr) {
1376         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1377         assert(obj->tag == LDKClosureReason_ProcessingError);
1378                         LDKStr err_str = obj->processing_error.err;
1379                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1380         return err_conv;
1381 }
1382 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_ty_from_ptr"))) TS_LDKCOption_ClosureReasonZ_ty_from_ptr(uint32_t ptr) {
1383         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1384         switch(obj->tag) {
1385                 case LDKCOption_ClosureReasonZ_Some: return 0;
1386                 case LDKCOption_ClosureReasonZ_None: return 1;
1387                 default: abort();
1388         }
1389 }
1390 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_Some_get_some"))) TS_LDKCOption_ClosureReasonZ_Some_get_some(uint32_t ptr) {
1391         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1392         assert(obj->tag == LDKCOption_ClosureReasonZ_Some);
1393                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1394         return some_ref;
1395 }
1396 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1397 CHECK(owner->result_ok);
1398         return COption_ClosureReasonZ_clone(&*owner->contents.result);
1399 }
1400 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t owner) {
1401         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1402         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
1403         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
1404         uint32_t ret_ref = (uintptr_t)ret_copy;
1405         return ret_ref;
1406 }
1407
1408 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1409 CHECK(!owner->result_ok);
1410         return DecodeError_clone(&*owner->contents.err);
1411 }
1412 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t owner) {
1413         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1414         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
1415         uint32_t ret_ref = 0;
1416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1419         ret_ref = (uintptr_t)ret_var.inner;
1420         if (ret_var.is_owned) {
1421                 ret_ref |= 1;
1422         }
1423         return ret_ref;
1424 }
1425
1426 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ty_from_ptr"))) TS_LDKNetworkUpdate_ty_from_ptr(uint32_t ptr) {
1427         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1428         switch(obj->tag) {
1429                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
1430                 case LDKNetworkUpdate_ChannelFailure: return 1;
1431                 case LDKNetworkUpdate_NodeFailure: return 2;
1432                 default: abort();
1433         }
1434 }
1435 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg"))) TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(uint32_t ptr) {
1436         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1437         assert(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
1438                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1439                         uint32_t msg_ref = 0;
1440                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1441                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1442                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1443                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1444         return msg_ref;
1445 }
1446 int64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelFailure_get_short_channel_id"))) TS_LDKNetworkUpdate_ChannelFailure_get_short_channel_id(uint32_t ptr) {
1447         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1448         assert(obj->tag == LDKNetworkUpdate_ChannelFailure);
1449                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
1450         return short_channel_id_conv;
1451 }
1452 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_ChannelFailure_get_is_permanent"))) TS_LDKNetworkUpdate_ChannelFailure_get_is_permanent(uint32_t ptr) {
1453         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1454         assert(obj->tag == LDKNetworkUpdate_ChannelFailure);
1455                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
1456         return is_permanent_conv;
1457 }
1458 int8_tArray __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_node_id"))) TS_LDKNetworkUpdate_NodeFailure_get_node_id(uint32_t ptr) {
1459         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1460         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1461                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1462                         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
1463         return node_id_arr;
1464 }
1465 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_is_permanent"))) TS_LDKNetworkUpdate_NodeFailure_get_is_permanent(uint32_t ptr) {
1466         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1467         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1468                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
1469         return is_permanent_conv;
1470 }
1471 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_ty_from_ptr"))) TS_LDKCOption_NetworkUpdateZ_ty_from_ptr(uint32_t ptr) {
1472         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1473         switch(obj->tag) {
1474                 case LDKCOption_NetworkUpdateZ_Some: return 0;
1475                 case LDKCOption_NetworkUpdateZ_None: return 1;
1476                 default: abort();
1477         }
1478 }
1479 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_Some_get_some"))) TS_LDKCOption_NetworkUpdateZ_Some_get_some(uint32_t ptr) {
1480         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1481         assert(obj->tag == LDKCOption_NetworkUpdateZ_Some);
1482                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1483         return some_ref;
1484 }
1485 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_ty_from_ptr"))) TS_LDKSpendableOutputDescriptor_ty_from_ptr(uint32_t ptr) {
1486         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1487         switch(obj->tag) {
1488                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1489                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1490                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1491                 default: abort();
1492         }
1493 }
1494 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(uint32_t ptr) {
1495         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1496         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1497                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1498                         uint32_t outpoint_ref = 0;
1499                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1500                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1501                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1502                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
1503         return outpoint_ref;
1504 }
1505 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_output"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_output(uint32_t ptr) {
1506         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1507         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1508                         uint32_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
1509         return (uint32_t)output_ref;
1510 }
1511 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output"))) TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(uint32_t ptr) {
1512         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1513         assert(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1514                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1515                         uint32_t delayed_payment_output_ref = 0;
1516                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1517                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1518                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1519                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
1520         return delayed_payment_output_ref;
1521 }
1522 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output"))) TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(uint32_t ptr) {
1523         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1524         assert(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1525                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1526                         uint32_t static_payment_output_ref = 0;
1527                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1528                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1529                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1530                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
1531         return static_payment_output_ref;
1532 }
1533 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1534         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1535         for (size_t i = 0; i < ret.datalen; i++) {
1536                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1537         }
1538         return ret;
1539 }
1540 uint32_t __attribute__((export_name("TS_LDKEvent_ty_from_ptr"))) TS_LDKEvent_ty_from_ptr(uint32_t ptr) {
1541         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1542         switch(obj->tag) {
1543                 case LDKEvent_FundingGenerationReady: return 0;
1544                 case LDKEvent_PaymentReceived: return 1;
1545                 case LDKEvent_PaymentClaimed: return 2;
1546                 case LDKEvent_PaymentSent: return 3;
1547                 case LDKEvent_PaymentFailed: return 4;
1548                 case LDKEvent_PaymentPathSuccessful: return 5;
1549                 case LDKEvent_PaymentPathFailed: return 6;
1550                 case LDKEvent_PendingHTLCsForwardable: return 7;
1551                 case LDKEvent_SpendableOutputs: return 8;
1552                 case LDKEvent_PaymentForwarded: return 9;
1553                 case LDKEvent_ChannelClosed: return 10;
1554                 case LDKEvent_DiscardFunding: return 11;
1555                 case LDKEvent_OpenChannelRequest: return 12;
1556                 default: abort();
1557         }
1558 }
1559 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id(uint32_t ptr) {
1560         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1561         assert(obj->tag == LDKEvent_FundingGenerationReady);
1562                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1563                         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
1564         return temporary_channel_id_arr;
1565 }
1566 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_counterparty_node_id"))) TS_LDKEvent_FundingGenerationReady_get_counterparty_node_id(uint32_t ptr) {
1567         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1568         assert(obj->tag == LDKEvent_FundingGenerationReady);
1569                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
1570                         memcpy(counterparty_node_id_arr->elems, obj->funding_generation_ready.counterparty_node_id.compressed_form, 33);
1571         return counterparty_node_id_arr;
1572 }
1573 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis"))) TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(uint32_t ptr) {
1574         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1575         assert(obj->tag == LDKEvent_FundingGenerationReady);
1576                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
1577         return channel_value_satoshis_conv;
1578 }
1579 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_output_script"))) TS_LDKEvent_FundingGenerationReady_get_output_script(uint32_t ptr) {
1580         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1581         assert(obj->tag == LDKEvent_FundingGenerationReady);
1582                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1583                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
1584                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
1585         return output_script_arr;
1586 }
1587 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_user_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_user_channel_id(uint32_t ptr) {
1588         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1589         assert(obj->tag == LDKEvent_FundingGenerationReady);
1590                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
1591         return user_channel_id_conv;
1592 }
1593 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_payment_hash"))) TS_LDKEvent_PaymentReceived_get_payment_hash(uint32_t ptr) {
1594         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1595         assert(obj->tag == LDKEvent_PaymentReceived);
1596                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1597                         memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
1598         return payment_hash_arr;
1599 }
1600 int64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_amount_msat"))) TS_LDKEvent_PaymentReceived_get_amount_msat(uint32_t ptr) {
1601         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1602         assert(obj->tag == LDKEvent_PaymentReceived);
1603                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
1604         return amount_msat_conv;
1605 }
1606 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_purpose"))) TS_LDKEvent_PaymentReceived_get_purpose(uint32_t ptr) {
1607         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1608         assert(obj->tag == LDKEvent_PaymentReceived);
1609                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
1610         return purpose_ref;
1611 }
1612 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_payment_hash"))) TS_LDKEvent_PaymentClaimed_get_payment_hash(uint32_t ptr) {
1613         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1614         assert(obj->tag == LDKEvent_PaymentClaimed);
1615                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1616                         memcpy(payment_hash_arr->elems, obj->payment_claimed.payment_hash.data, 32);
1617         return payment_hash_arr;
1618 }
1619 int64_t __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_amount_msat"))) TS_LDKEvent_PaymentClaimed_get_amount_msat(uint32_t ptr) {
1620         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1621         assert(obj->tag == LDKEvent_PaymentClaimed);
1622                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
1623         return amount_msat_conv;
1624 }
1625 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_purpose"))) TS_LDKEvent_PaymentClaimed_get_purpose(uint32_t ptr) {
1626         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1627         assert(obj->tag == LDKEvent_PaymentClaimed);
1628                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_claimed.purpose) | 1;
1629         return purpose_ref;
1630 }
1631 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_id"))) TS_LDKEvent_PaymentSent_get_payment_id(uint32_t ptr) {
1632         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1633         assert(obj->tag == LDKEvent_PaymentSent);
1634                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1635                         memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
1636         return payment_id_arr;
1637 }
1638 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_preimage"))) TS_LDKEvent_PaymentSent_get_payment_preimage(uint32_t ptr) {
1639         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1640         assert(obj->tag == LDKEvent_PaymentSent);
1641                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1642                         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
1643         return payment_preimage_arr;
1644 }
1645 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_hash"))) TS_LDKEvent_PaymentSent_get_payment_hash(uint32_t ptr) {
1646         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1647         assert(obj->tag == LDKEvent_PaymentSent);
1648                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1649                         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
1650         return payment_hash_arr;
1651 }
1652 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentSent_get_fee_paid_msat"))) TS_LDKEvent_PaymentSent_get_fee_paid_msat(uint32_t ptr) {
1653         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1654         assert(obj->tag == LDKEvent_PaymentSent);
1655                         uint32_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
1656         return fee_paid_msat_ref;
1657 }
1658 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_id"))) TS_LDKEvent_PaymentFailed_get_payment_id(uint32_t ptr) {
1659         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1660         assert(obj->tag == LDKEvent_PaymentFailed);
1661                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1662                         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
1663         return payment_id_arr;
1664 }
1665 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_hash"))) TS_LDKEvent_PaymentFailed_get_payment_hash(uint32_t ptr) {
1666         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1667         assert(obj->tag == LDKEvent_PaymentFailed);
1668                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1669                         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
1670         return payment_hash_arr;
1671 }
1672 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_id"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_id(uint32_t ptr) {
1673         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1674         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1675                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1676                         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
1677         return payment_id_arr;
1678 }
1679 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_hash"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_hash(uint32_t ptr) {
1680         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1681         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1682                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1683                         memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
1684         return payment_hash_arr;
1685 }
1686 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_path"))) TS_LDKEvent_PaymentPathSuccessful_get_path(uint32_t ptr) {
1687         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1688         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1689                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1690                         uint32_tArray path_arr = NULL;
1691                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1692                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1693                         for (size_t k = 0; k < path_var.datalen; k++) {
1694                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1695                                 uint32_t path_conv_10_ref = 0;
1696                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1697                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1698                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1699                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1700                                 path_arr_ptr[k] = path_conv_10_ref;
1701                         }
1702                         
1703         return path_arr;
1704 }
1705 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_id"))) TS_LDKEvent_PaymentPathFailed_get_payment_id(uint32_t ptr) {
1706         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1707         assert(obj->tag == LDKEvent_PaymentPathFailed);
1708                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1709                         memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
1710         return payment_id_arr;
1711 }
1712 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_hash"))) TS_LDKEvent_PaymentPathFailed_get_payment_hash(uint32_t ptr) {
1713         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1714         assert(obj->tag == LDKEvent_PaymentPathFailed);
1715                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1716                         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
1717         return payment_hash_arr;
1718 }
1719 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest"))) TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest(uint32_t ptr) {
1720         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1721         assert(obj->tag == LDKEvent_PaymentPathFailed);
1722                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
1723         return rejected_by_dest_conv;
1724 }
1725 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_network_update"))) TS_LDKEvent_PaymentPathFailed_get_network_update(uint32_t ptr) {
1726         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1727         assert(obj->tag == LDKEvent_PaymentPathFailed);
1728                         uint32_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
1729         return network_update_ref;
1730 }
1731 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_all_paths_failed"))) TS_LDKEvent_PaymentPathFailed_get_all_paths_failed(uint32_t ptr) {
1732         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1733         assert(obj->tag == LDKEvent_PaymentPathFailed);
1734                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
1735         return all_paths_failed_conv;
1736 }
1737 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_path"))) TS_LDKEvent_PaymentPathFailed_get_path(uint32_t ptr) {
1738         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1739         assert(obj->tag == LDKEvent_PaymentPathFailed);
1740                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1741                         uint32_tArray path_arr = NULL;
1742                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1743                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1744                         for (size_t k = 0; k < path_var.datalen; k++) {
1745                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1746                                 uint32_t path_conv_10_ref = 0;
1747                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1748                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1749                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1750                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1751                                 path_arr_ptr[k] = path_conv_10_ref;
1752                         }
1753                         
1754         return path_arr;
1755 }
1756 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_short_channel_id"))) TS_LDKEvent_PaymentPathFailed_get_short_channel_id(uint32_t ptr) {
1757         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1758         assert(obj->tag == LDKEvent_PaymentPathFailed);
1759                         uint32_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
1760         return short_channel_id_ref;
1761 }
1762 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_retry"))) TS_LDKEvent_PaymentPathFailed_get_retry(uint32_t ptr) {
1763         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1764         assert(obj->tag == LDKEvent_PaymentPathFailed);
1765                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1766                         uint32_t retry_ref = 0;
1767                         if ((uintptr_t)retry_var.inner > 4096) {
1768                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1769                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1770                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1771                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
1772                         }
1773         return retry_ref;
1774 }
1775 int64_t __attribute__((export_name("TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable"))) TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(uint32_t ptr) {
1776         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1777         assert(obj->tag == LDKEvent_PendingHTLCsForwardable);
1778                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
1779         return time_forwardable_conv;
1780 }
1781 uint32_tArray __attribute__((export_name("TS_LDKEvent_SpendableOutputs_get_outputs"))) TS_LDKEvent_SpendableOutputs_get_outputs(uint32_t ptr) {
1782         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1783         assert(obj->tag == LDKEvent_SpendableOutputs);
1784                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1785                         uint32_tArray outputs_arr = NULL;
1786                         outputs_arr = init_uint32_tArray(outputs_var.datalen, __LINE__);
1787                         uint32_t *outputs_arr_ptr = (uint32_t*)(((uint8_t*)outputs_arr) + 4);
1788                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1789                                 uint32_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
1790                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1791                         }
1792                         
1793         return outputs_arr;
1794 }
1795 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_prev_channel_id"))) TS_LDKEvent_PaymentForwarded_get_prev_channel_id(uint32_t ptr) {
1796         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1797         assert(obj->tag == LDKEvent_PaymentForwarded);
1798                         int8_tArray prev_channel_id_arr = init_int8_tArray(32, __LINE__);
1799                         memcpy(prev_channel_id_arr->elems, obj->payment_forwarded.prev_channel_id.data, 32);
1800         return prev_channel_id_arr;
1801 }
1802 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_next_channel_id"))) TS_LDKEvent_PaymentForwarded_get_next_channel_id(uint32_t ptr) {
1803         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1804         assert(obj->tag == LDKEvent_PaymentForwarded);
1805                         int8_tArray next_channel_id_arr = init_int8_tArray(32, __LINE__);
1806                         memcpy(next_channel_id_arr->elems, obj->payment_forwarded.next_channel_id.data, 32);
1807         return next_channel_id_arr;
1808 }
1809 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_fee_earned_msat"))) TS_LDKEvent_PaymentForwarded_get_fee_earned_msat(uint32_t ptr) {
1810         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1811         assert(obj->tag == LDKEvent_PaymentForwarded);
1812                         uint32_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1813         return fee_earned_msat_ref;
1814 }
1815 jboolean __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx"))) TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(uint32_t ptr) {
1816         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1817         assert(obj->tag == LDKEvent_PaymentForwarded);
1818                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
1819         return claim_from_onchain_tx_conv;
1820 }
1821 int8_tArray __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_channel_id"))) TS_LDKEvent_ChannelClosed_get_channel_id(uint32_t ptr) {
1822         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1823         assert(obj->tag == LDKEvent_ChannelClosed);
1824                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1825                         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
1826         return channel_id_arr;
1827 }
1828 int64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_user_channel_id"))) TS_LDKEvent_ChannelClosed_get_user_channel_id(uint32_t ptr) {
1829         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1830         assert(obj->tag == LDKEvent_ChannelClosed);
1831                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
1832         return user_channel_id_conv;
1833 }
1834 uint32_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_reason"))) TS_LDKEvent_ChannelClosed_get_reason(uint32_t ptr) {
1835         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1836         assert(obj->tag == LDKEvent_ChannelClosed);
1837                         uint32_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
1838         return reason_ref;
1839 }
1840 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_channel_id"))) TS_LDKEvent_DiscardFunding_get_channel_id(uint32_t ptr) {
1841         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1842         assert(obj->tag == LDKEvent_DiscardFunding);
1843                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1844                         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
1845         return channel_id_arr;
1846 }
1847 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_transaction"))) TS_LDKEvent_DiscardFunding_get_transaction(uint32_t ptr) {
1848         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1849         assert(obj->tag == LDKEvent_DiscardFunding);
1850                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1851                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
1852                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
1853         return transaction_arr;
1854 }
1855 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id"))) TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id(uint32_t ptr) {
1856         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1857         assert(obj->tag == LDKEvent_OpenChannelRequest);
1858                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1859                         memcpy(temporary_channel_id_arr->elems, obj->open_channel_request.temporary_channel_id.data, 32);
1860         return temporary_channel_id_arr;
1861 }
1862 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id"))) TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id(uint32_t ptr) {
1863         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1864         assert(obj->tag == LDKEvent_OpenChannelRequest);
1865                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
1866                         memcpy(counterparty_node_id_arr->elems, obj->open_channel_request.counterparty_node_id.compressed_form, 33);
1867         return counterparty_node_id_arr;
1868 }
1869 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_funding_satoshis"))) TS_LDKEvent_OpenChannelRequest_get_funding_satoshis(uint32_t ptr) {
1870         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1871         assert(obj->tag == LDKEvent_OpenChannelRequest);
1872                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
1873         return funding_satoshis_conv;
1874 }
1875 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_push_msat"))) TS_LDKEvent_OpenChannelRequest_get_push_msat(uint32_t ptr) {
1876         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1877         assert(obj->tag == LDKEvent_OpenChannelRequest);
1878                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
1879         return push_msat_conv;
1880 }
1881 uint32_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_channel_type"))) TS_LDKEvent_OpenChannelRequest_get_channel_type(uint32_t ptr) {
1882         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1883         assert(obj->tag == LDKEvent_OpenChannelRequest);
1884                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
1885                         uint32_t channel_type_ref = 0;
1886                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1887                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1888                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
1889                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
1890         return channel_type_ref;
1891 }
1892 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_ty_from_ptr"))) TS_LDKCOption_EventZ_ty_from_ptr(uint32_t ptr) {
1893         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1894         switch(obj->tag) {
1895                 case LDKCOption_EventZ_Some: return 0;
1896                 case LDKCOption_EventZ_None: return 1;
1897                 default: abort();
1898         }
1899 }
1900 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_Some_get_some"))) TS_LDKCOption_EventZ_Some_get_some(uint32_t ptr) {
1901         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1902         assert(obj->tag == LDKCOption_EventZ_Some);
1903                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1904         return some_ref;
1905 }
1906 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1907 CHECK(owner->result_ok);
1908         return COption_EventZ_clone(&*owner->contents.result);
1909 }
1910 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_ok"))) TS_CResult_COption_EventZDecodeErrorZ_get_ok(uint32_t owner) {
1911         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1912         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
1913         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
1914         uint32_t ret_ref = (uintptr_t)ret_copy;
1915         return ret_ref;
1916 }
1917
1918 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1919 CHECK(!owner->result_ok);
1920         return DecodeError_clone(&*owner->contents.err);
1921 }
1922 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_err"))) TS_CResult_COption_EventZDecodeErrorZ_get_err(uint32_t owner) {
1923         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1924         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
1925         uint32_t ret_ref = 0;
1926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1929         ret_ref = (uintptr_t)ret_var.inner;
1930         if (ret_var.is_owned) {
1931                 ret_ref |= 1;
1932         }
1933         return ret_ref;
1934 }
1935
1936 uint32_t __attribute__((export_name("TS_LDKErrorAction_ty_from_ptr"))) TS_LDKErrorAction_ty_from_ptr(uint32_t ptr) {
1937         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1938         switch(obj->tag) {
1939                 case LDKErrorAction_DisconnectPeer: return 0;
1940                 case LDKErrorAction_IgnoreError: return 1;
1941                 case LDKErrorAction_IgnoreAndLog: return 2;
1942                 case LDKErrorAction_IgnoreDuplicateGossip: return 3;
1943                 case LDKErrorAction_SendErrorMessage: return 4;
1944                 case LDKErrorAction_SendWarningMessage: return 5;
1945                 default: abort();
1946         }
1947 }
1948 uint32_t __attribute__((export_name("TS_LDKErrorAction_DisconnectPeer_get_msg"))) TS_LDKErrorAction_DisconnectPeer_get_msg(uint32_t ptr) {
1949         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1950         assert(obj->tag == LDKErrorAction_DisconnectPeer);
1951                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1952                         uint32_t msg_ref = 0;
1953                         if ((uintptr_t)msg_var.inner > 4096) {
1954                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1955                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1956                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1957                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
1958                         }
1959         return msg_ref;
1960 }
1961 uint32_t __attribute__((export_name("TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log"))) TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(uint32_t ptr) {
1962         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1963         assert(obj->tag == LDKErrorAction_IgnoreAndLog);
1964                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
1965         return ignore_and_log_conv;
1966 }
1967 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendErrorMessage_get_msg"))) TS_LDKErrorAction_SendErrorMessage_get_msg(uint32_t ptr) {
1968         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1969         assert(obj->tag == LDKErrorAction_SendErrorMessage);
1970                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1971                         uint32_t msg_ref = 0;
1972                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1973                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1974                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1975                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1976         return msg_ref;
1977 }
1978 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_msg"))) TS_LDKErrorAction_SendWarningMessage_get_msg(uint32_t ptr) {
1979         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1980         assert(obj->tag == LDKErrorAction_SendWarningMessage);
1981                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
1982                         uint32_t msg_ref = 0;
1983                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1984                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1985                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1986                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1987         return msg_ref;
1988 }
1989 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_log_level"))) TS_LDKErrorAction_SendWarningMessage_get_log_level(uint32_t ptr) {
1990         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1991         assert(obj->tag == LDKErrorAction_SendWarningMessage);
1992                         uint32_t log_level_conv = LDKLevel_to_js(obj->send_warning_message.log_level);
1993         return log_level_conv;
1994 }
1995 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_ty_from_ptr"))) TS_LDKMessageSendEvent_ty_from_ptr(uint32_t ptr) {
1996         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1997         switch(obj->tag) {
1998                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
1999                 case LDKMessageSendEvent_SendOpenChannel: return 1;
2000                 case LDKMessageSendEvent_SendFundingCreated: return 2;
2001                 case LDKMessageSendEvent_SendFundingSigned: return 3;
2002                 case LDKMessageSendEvent_SendChannelReady: return 4;
2003                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 5;
2004                 case LDKMessageSendEvent_UpdateHTLCs: return 6;
2005                 case LDKMessageSendEvent_SendRevokeAndACK: return 7;
2006                 case LDKMessageSendEvent_SendClosingSigned: return 8;
2007                 case LDKMessageSendEvent_SendShutdown: return 9;
2008                 case LDKMessageSendEvent_SendChannelReestablish: return 10;
2009                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 11;
2010                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 12;
2011                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 13;
2012                 case LDKMessageSendEvent_SendChannelUpdate: return 14;
2013                 case LDKMessageSendEvent_HandleError: return 15;
2014                 case LDKMessageSendEvent_SendChannelRangeQuery: return 16;
2015                 case LDKMessageSendEvent_SendShortIdsQuery: return 17;
2016                 case LDKMessageSendEvent_SendReplyChannelRange: return 18;
2017                 case LDKMessageSendEvent_SendGossipTimestampFilter: return 19;
2018                 default: abort();
2019         }
2020 }
2021 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id(uint32_t ptr) {
2022         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2023         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2024                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2025                         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
2026         return node_id_arr;
2027 }
2028 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_msg"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_msg(uint32_t ptr) {
2029         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2030         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2031                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2032                         uint32_t msg_ref = 0;
2033                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2034                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2035                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2036                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2037         return msg_ref;
2038 }
2039 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_node_id"))) TS_LDKMessageSendEvent_SendOpenChannel_get_node_id(uint32_t ptr) {
2040         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2041         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2042                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2043                         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
2044         return node_id_arr;
2045 }
2046 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_msg"))) TS_LDKMessageSendEvent_SendOpenChannel_get_msg(uint32_t ptr) {
2047         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2048         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2049                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2050                         uint32_t msg_ref = 0;
2051                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2052                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2053                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2054                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2055         return msg_ref;
2056 }
2057 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_node_id"))) TS_LDKMessageSendEvent_SendFundingCreated_get_node_id(uint32_t ptr) {
2058         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2059         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2060                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2061                         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
2062         return node_id_arr;
2063 }
2064 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_msg"))) TS_LDKMessageSendEvent_SendFundingCreated_get_msg(uint32_t ptr) {
2065         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2066         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2067                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2068                         uint32_t msg_ref = 0;
2069                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2070                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2071                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2072                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2073         return msg_ref;
2074 }
2075 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendFundingSigned_get_node_id(uint32_t ptr) {
2076         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2077         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2078                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2079                         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
2080         return node_id_arr;
2081 }
2082 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_msg"))) TS_LDKMessageSendEvent_SendFundingSigned_get_msg(uint32_t ptr) {
2083         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2084         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2085                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2086                         uint32_t msg_ref = 0;
2087                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2088                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2089                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2090                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2091         return msg_ref;
2092 }
2093 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReady_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReady_get_node_id(uint32_t ptr) {
2094         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2095         assert(obj->tag == LDKMessageSendEvent_SendChannelReady);
2096                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2097                         memcpy(node_id_arr->elems, obj->send_channel_ready.node_id.compressed_form, 33);
2098         return node_id_arr;
2099 }
2100 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReady_get_msg"))) TS_LDKMessageSendEvent_SendChannelReady_get_msg(uint32_t ptr) {
2101         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2102         assert(obj->tag == LDKMessageSendEvent_SendChannelReady);
2103                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
2104                         uint32_t msg_ref = 0;
2105                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2106                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2107                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2108                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2109         return msg_ref;
2110 }
2111 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(uint32_t ptr) {
2112         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2113         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2114                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2115                         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
2116         return node_id_arr;
2117 }
2118 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(uint32_t ptr) {
2119         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2120         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2121                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2122                         uint32_t msg_ref = 0;
2123                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2124                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2125                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2126                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2127         return msg_ref;
2128 }
2129 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id(uint32_t ptr) {
2130         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2131         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2132                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2133                         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
2134         return node_id_arr;
2135 }
2136 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_updates"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_updates(uint32_t ptr) {
2137         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2138         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2139                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2140                         uint32_t updates_ref = 0;
2141                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2142                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2143                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2144                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2145         return updates_ref;
2146 }
2147 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(uint32_t ptr) {
2148         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2149         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2150                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2151                         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
2152         return node_id_arr;
2153 }
2154 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg(uint32_t ptr) {
2155         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2156         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2157                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2158                         uint32_t msg_ref = 0;
2159                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2160                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2161                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2162                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2163         return msg_ref;
2164 }
2165 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendClosingSigned_get_node_id(uint32_t ptr) {
2166         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2167         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2168                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2169                         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
2170         return node_id_arr;
2171 }
2172 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_msg"))) TS_LDKMessageSendEvent_SendClosingSigned_get_msg(uint32_t ptr) {
2173         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2174         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2175                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2176                         uint32_t msg_ref = 0;
2177                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2178                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2179                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2180                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2181         return msg_ref;
2182 }
2183 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_node_id"))) TS_LDKMessageSendEvent_SendShutdown_get_node_id(uint32_t ptr) {
2184         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2185         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2186                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2187                         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
2188         return node_id_arr;
2189 }
2190 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_msg"))) TS_LDKMessageSendEvent_SendShutdown_get_msg(uint32_t ptr) {
2191         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2192         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2193                         LDKShutdown msg_var = obj->send_shutdown.msg;
2194                         uint32_t msg_ref = 0;
2195                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2196                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2197                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2198                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2199         return msg_ref;
2200 }
2201 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id(uint32_t ptr) {
2202         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2203         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2204                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2205                         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
2206         return node_id_arr;
2207 }
2208 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_msg"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_msg(uint32_t ptr) {
2209         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2210         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2211                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2212                         uint32_t msg_ref = 0;
2213                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2214                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2215                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2216                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2217         return msg_ref;
2218 }
2219 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(uint32_t ptr) {
2220         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2221         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2222                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2223                         uint32_t msg_ref = 0;
2224                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2225                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2226                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2227                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2228         return msg_ref;
2229 }
2230 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(uint32_t ptr) {
2231         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2232         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2233                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2234                         uint32_t update_msg_ref = 0;
2235                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2236                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2237                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2238                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2239         return update_msg_ref;
2240 }
2241 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(uint32_t ptr) {
2242         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2243         assert(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
2244                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2245                         uint32_t msg_ref = 0;
2246                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2247                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2248                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2249                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2250         return msg_ref;
2251 }
2252 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(uint32_t ptr) {
2253         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2254         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
2255                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2256                         uint32_t msg_ref = 0;
2257                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2258                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2259                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2260                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2261         return msg_ref;
2262 }
2263 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id(uint32_t ptr) {
2264         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2265         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2266                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2267                         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
2268         return node_id_arr;
2269 }
2270 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_msg(uint32_t ptr) {
2271         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2272         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2273                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2274                         uint32_t msg_ref = 0;
2275                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2276                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2277                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2278                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2279         return msg_ref;
2280 }
2281 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_node_id"))) TS_LDKMessageSendEvent_HandleError_get_node_id(uint32_t ptr) {
2282         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2283         assert(obj->tag == LDKMessageSendEvent_HandleError);
2284                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2285                         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
2286         return node_id_arr;
2287 }
2288 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_action"))) TS_LDKMessageSendEvent_HandleError_get_action(uint32_t ptr) {
2289         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2290         assert(obj->tag == LDKMessageSendEvent_HandleError);
2291                         uint32_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2292         return action_ref;
2293 }
2294 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(uint32_t ptr) {
2295         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2296         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2297                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2298                         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
2299         return node_id_arr;
2300 }
2301 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(uint32_t ptr) {
2302         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2303         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2304                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2305                         uint32_t msg_ref = 0;
2306                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2307                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2308                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2309                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2310         return msg_ref;
2311 }
2312 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(uint32_t ptr) {
2313         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2314         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2315                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2316                         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
2317         return node_id_arr;
2318 }
2319 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg(uint32_t ptr) {
2320         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2321         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2322                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2323                         uint32_t msg_ref = 0;
2324                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2325                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2326                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2327                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2328         return msg_ref;
2329 }
2330 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(uint32_t ptr) {
2331         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2332         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2333                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2334                         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
2335         return node_id_arr;
2336 }
2337 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg(uint32_t ptr) {
2338         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2339         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2340                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2341                         uint32_t msg_ref = 0;
2342                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2343                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2344                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2345                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2346         return msg_ref;
2347 }
2348 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id(uint32_t ptr) {
2349         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2350         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2351                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2352                         memcpy(node_id_arr->elems, obj->send_gossip_timestamp_filter.node_id.compressed_form, 33);
2353         return node_id_arr;
2354 }
2355 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg(uint32_t ptr) {
2356         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2357         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2358                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
2359                         uint32_t msg_ref = 0;
2360                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2361                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2362                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2363                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2364         return msg_ref;
2365 }
2366 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2367         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2368         for (size_t i = 0; i < ret.datalen; i++) {
2369                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2370         }
2371         return ret;
2372 }
2373 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
2374 CHECK(owner->result_ok);
2375         return TxOut_clone(&*owner->contents.result);
2376 }
2377 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_ok"))) TS_CResult_TxOutAccessErrorZ_get_ok(uint32_t owner) {
2378         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
2379         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
2380         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
2381         return (uint32_t)ret_ref;
2382 }
2383
2384 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
2385 CHECK(!owner->result_ok);
2386         return AccessError_clone(&*owner->contents.err);
2387 }
2388 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_err"))) TS_CResult_TxOutAccessErrorZ_get_err(uint32_t owner) {
2389         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
2390         uint32_t ret_conv = LDKAccessError_to_js(CResult_TxOutAccessErrorZ_get_err(owner_conv));
2391         return ret_conv;
2392 }
2393
2394 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2395         return owner->a;
2396 }
2397 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_a"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t owner) {
2398         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
2399         uint32_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
2400         return ret_conv;
2401 }
2402
2403 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2404         return owner->b;
2405 }
2406 int8_tArray  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_b"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t owner) {
2407         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
2408         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
2409         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2410         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2411         return ret_arr;
2412 }
2413
2414 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
2415         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
2416         for (size_t i = 0; i < ret.datalen; i++) {
2417                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
2418         }
2419         return ret;
2420 }
2421 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
2422         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
2423         for (size_t i = 0; i < ret.datalen; i++) {
2424                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
2425         }
2426         return ret;
2427 }
2428 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
2429 CHECK(owner->result_ok);
2430         return *owner->contents.result;
2431 }
2432 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t owner) {
2433         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
2434         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
2435 }
2436
2437 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
2438 CHECK(!owner->result_ok);
2439         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
2440 }
2441 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t owner) {
2442         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
2443         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
2444         return ret_conv;
2445 }
2446
2447 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_ty_from_ptr"))) TS_LDKMonitorEvent_ty_from_ptr(uint32_t ptr) {
2448         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2449         switch(obj->tag) {
2450                 case LDKMonitorEvent_HTLCEvent: return 0;
2451                 case LDKMonitorEvent_CommitmentTxConfirmed: return 1;
2452                 case LDKMonitorEvent_UpdateCompleted: return 2;
2453                 case LDKMonitorEvent_UpdateFailed: return 3;
2454                 default: abort();
2455         }
2456 }
2457 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_HTLCEvent_get_htlc_event"))) TS_LDKMonitorEvent_HTLCEvent_get_htlc_event(uint32_t ptr) {
2458         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2459         assert(obj->tag == LDKMonitorEvent_HTLCEvent);
2460                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
2461                         uint32_t htlc_event_ref = 0;
2462                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2463                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2464                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
2465                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
2466         return htlc_event_ref;
2467 }
2468 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed"))) TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(uint32_t ptr) {
2469         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2470         assert(obj->tag == LDKMonitorEvent_CommitmentTxConfirmed);
2471                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
2472                         uint32_t commitment_tx_confirmed_ref = 0;
2473                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2474                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2475                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
2476                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
2477         return commitment_tx_confirmed_ref;
2478 }
2479 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo"))) TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo(uint32_t ptr) {
2480         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2481         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
2482                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
2483                         uint32_t funding_txo_ref = 0;
2484                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2485                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2486                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
2487                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
2488         return funding_txo_ref;
2489 }
2490 int64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id"))) TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id(uint32_t ptr) {
2491         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2492         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
2493                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
2494         return monitor_update_id_conv;
2495 }
2496 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateFailed_get_update_failed"))) TS_LDKMonitorEvent_UpdateFailed_get_update_failed(uint32_t ptr) {
2497         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2498         assert(obj->tag == LDKMonitorEvent_UpdateFailed);
2499                         LDKOutPoint update_failed_var = obj->update_failed;
2500                         uint32_t update_failed_ref = 0;
2501                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2502                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2503                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
2504                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
2505         return update_failed_ref;
2506 }
2507 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
2508         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
2509         for (size_t i = 0; i < ret.datalen; i++) {
2510                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
2511         }
2512         return ret;
2513 }
2514 static inline struct LDKOutPoint C2Tuple_OutPointCVec_MonitorEventZZ_get_a(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR owner){
2515         return OutPoint_clone(&owner->a);
2516 }
2517 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_get_a"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_get_a(uint32_t owner) {
2518         LDKC2Tuple_OutPointCVec_MonitorEventZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(owner & ~1);
2519         LDKOutPoint ret_var = C2Tuple_OutPointCVec_MonitorEventZZ_get_a(owner_conv);
2520         uint32_t ret_ref = 0;
2521         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2522         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2524         ret_ref = (uintptr_t)ret_var.inner;
2525         if (ret_var.is_owned) {
2526                 ret_ref |= 1;
2527         }
2528         return ret_ref;
2529 }
2530
2531 static inline struct LDKCVec_MonitorEventZ C2Tuple_OutPointCVec_MonitorEventZZ_get_b(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR owner){
2532         return CVec_MonitorEventZ_clone(&owner->b);
2533 }
2534 uint32_tArray  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_get_b"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_get_b(uint32_t owner) {
2535         LDKC2Tuple_OutPointCVec_MonitorEventZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(owner & ~1);
2536         LDKCVec_MonitorEventZ ret_var = C2Tuple_OutPointCVec_MonitorEventZZ_get_b(owner_conv);
2537         uint32_tArray ret_arr = NULL;
2538         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
2539         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
2540         for (size_t o = 0; o < ret_var.datalen; o++) {
2541                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2542                 *ret_conv_14_copy = ret_var.data[o];
2543                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
2544                 ret_arr_ptr[o] = ret_conv_14_ref;
2545         }
2546         
2547         FREE(ret_var.data);
2548         return ret_arr;
2549 }
2550
2551 static inline LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_clone(const LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ *orig) {
2552         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ) * orig->datalen, "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ clone bytes"), .datalen = orig->datalen };
2553         for (size_t i = 0; i < ret.datalen; i++) {
2554                 ret.data[i] = C2Tuple_OutPointCVec_MonitorEventZZ_clone(&orig->data[i]);
2555         }
2556         return ret;
2557 }
2558 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr(uint32_t ptr) {
2559         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2560         switch(obj->tag) {
2561                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: return 0;
2562                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: return 1;
2563                 default: abort();
2564         }
2565 }
2566 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some(uint32_t ptr) {
2567         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2568         assert(obj->tag == LDKCOption_C2Tuple_usizeTransactionZZ_Some);
2569                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
2570                         *some_conv = obj->some;
2571                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
2572         return ((uint32_t)some_conv);
2573 }
2574 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2575 CHECK(owner->result_ok);
2576         return FixedPenaltyScorer_clone(&*owner->contents.result);
2577 }
2578 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(uint32_t owner) {
2579         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2580         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
2581         uint32_t ret_ref = 0;
2582         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2583         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2585         ret_ref = (uintptr_t)ret_var.inner;
2586         if (ret_var.is_owned) {
2587                 ret_ref |= 1;
2588         }
2589         return ret_ref;
2590 }
2591
2592 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2593 CHECK(!owner->result_ok);
2594         return DecodeError_clone(&*owner->contents.err);
2595 }
2596 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err(uint32_t owner) {
2597         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2598         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
2599         uint32_t ret_ref = 0;
2600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2603         ret_ref = (uintptr_t)ret_var.inner;
2604         if (ret_var.is_owned) {
2605                 ret_ref |= 1;
2606         }
2607         return ret_ref;
2608 }
2609
2610 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
2611         return owner->a;
2612 }
2613 int64_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_get_a"))) TS_C2Tuple_u64u64Z_get_a(uint32_t owner) {
2614         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
2615         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
2616         return ret_conv;
2617 }
2618
2619 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
2620         return owner->b;
2621 }
2622 int64_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_get_b"))) TS_C2Tuple_u64u64Z_get_b(uint32_t owner) {
2623         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
2624         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
2625         return ret_conv;
2626 }
2627
2628 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_u64u64ZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_u64u64ZZ_ty_from_ptr(uint32_t ptr) {
2629         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)(ptr & ~1);
2630         switch(obj->tag) {
2631                 case LDKCOption_C2Tuple_u64u64ZZ_Some: return 0;
2632                 case LDKCOption_C2Tuple_u64u64ZZ_None: return 1;
2633                 default: abort();
2634         }
2635 }
2636 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_u64u64ZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_u64u64ZZ_Some_get_some(uint32_t ptr) {
2637         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)(ptr & ~1);
2638         assert(obj->tag == LDKCOption_C2Tuple_u64u64ZZ_Some);
2639                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
2640                         *some_conv = obj->some;
2641                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
2642         return ((uint32_t)some_conv);
2643 }
2644 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
2645         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
2646         for (size_t i = 0; i < ret.datalen; i++) {
2647                 ret.data[i] = NodeId_clone(&orig->data[i]);
2648         }
2649         return ret;
2650 }
2651 typedef struct LDKLogger_JCalls {
2652         atomic_size_t refcnt;
2653         uint32_t instance_ptr;
2654 } LDKLogger_JCalls;
2655 static void LDKLogger_JCalls_free(void* this_arg) {
2656         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2657         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2658                 FREE(j_calls);
2659         }
2660 }
2661 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
2662         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2663         LDKRecord record_var = *record;
2664         uint32_t record_ref = 0;
2665         record_var = Record_clone(&record_var);
2666         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2667         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2668         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
2669         record_ref = (uintptr_t)record_var.inner;
2670         if (record_var.is_owned) {
2671                 record_ref |= 1;
2672         }
2673         js_invoke_function_u_u(j_calls->instance_ptr, 0, (uint32_t)record_ref);
2674 }
2675 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
2676         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
2677         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2678 }
2679 static inline LDKLogger LDKLogger_init (JSValue o) {
2680         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2681         atomic_init(&calls->refcnt, 1);
2682         calls->instance_ptr = o;
2683
2684         LDKLogger ret = {
2685                 .this_arg = (void*) calls,
2686                 .log = log_LDKLogger_jcall,
2687                 .free = LDKLogger_JCalls_free,
2688         };
2689         return ret;
2690 }
2691 long  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
2692         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2693         *res_ptr = LDKLogger_init(o);
2694         return (long)res_ptr;
2695 }
2696 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2697 CHECK(owner->result_ok);
2698         return &*owner->contents.result;
2699 }
2700 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok(uint32_t owner) {
2701         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2702         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
2703         uint32_t ret_ref = 0;
2704         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2705         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2707         ret_ref = (uintptr_t)ret_var.inner & ~1;
2708         return ret_ref;
2709 }
2710
2711 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2712 CHECK(!owner->result_ok);
2713         return DecodeError_clone(&*owner->contents.err);
2714 }
2715 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err(uint32_t owner) {
2716         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2717         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
2718         uint32_t ret_ref = 0;
2719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2722         ret_ref = (uintptr_t)ret_var.inner;
2723         if (ret_var.is_owned) {
2724                 ret_ref |= 1;
2725         }
2726         return ret_ref;
2727 }
2728
2729 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2730 CHECK(owner->result_ok);
2731         return InitFeatures_clone(&*owner->contents.result);
2732 }
2733 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2734         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2735         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
2736         uint32_t ret_ref = 0;
2737         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2738         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2740         ret_ref = (uintptr_t)ret_var.inner;
2741         if (ret_var.is_owned) {
2742                 ret_ref |= 1;
2743         }
2744         return ret_ref;
2745 }
2746
2747 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2748 CHECK(!owner->result_ok);
2749         return DecodeError_clone(&*owner->contents.err);
2750 }
2751 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2752         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2753         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
2754         uint32_t ret_ref = 0;
2755         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2756         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2758         ret_ref = (uintptr_t)ret_var.inner;
2759         if (ret_var.is_owned) {
2760                 ret_ref |= 1;
2761         }
2762         return ret_ref;
2763 }
2764
2765 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2766 CHECK(owner->result_ok);
2767         return ChannelFeatures_clone(&*owner->contents.result);
2768 }
2769 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2770         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2771         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
2772         uint32_t ret_ref = 0;
2773         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2774         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2776         ret_ref = (uintptr_t)ret_var.inner;
2777         if (ret_var.is_owned) {
2778                 ret_ref |= 1;
2779         }
2780         return ret_ref;
2781 }
2782
2783 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2784 CHECK(!owner->result_ok);
2785         return DecodeError_clone(&*owner->contents.err);
2786 }
2787 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2788         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2789         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
2790         uint32_t ret_ref = 0;
2791         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2792         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2794         ret_ref = (uintptr_t)ret_var.inner;
2795         if (ret_var.is_owned) {
2796                 ret_ref |= 1;
2797         }
2798         return ret_ref;
2799 }
2800
2801 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2802 CHECK(owner->result_ok);
2803         return NodeFeatures_clone(&*owner->contents.result);
2804 }
2805 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2806         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2807         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
2808         uint32_t ret_ref = 0;
2809         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2810         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2812         ret_ref = (uintptr_t)ret_var.inner;
2813         if (ret_var.is_owned) {
2814                 ret_ref |= 1;
2815         }
2816         return ret_ref;
2817 }
2818
2819 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2820 CHECK(!owner->result_ok);
2821         return DecodeError_clone(&*owner->contents.err);
2822 }
2823 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2824         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2825         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
2826         uint32_t ret_ref = 0;
2827         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2828         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2830         ret_ref = (uintptr_t)ret_var.inner;
2831         if (ret_var.is_owned) {
2832                 ret_ref |= 1;
2833         }
2834         return ret_ref;
2835 }
2836
2837 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2838 CHECK(owner->result_ok);
2839         return InvoiceFeatures_clone(&*owner->contents.result);
2840 }
2841 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2842         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2843         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
2844         uint32_t ret_ref = 0;
2845         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2846         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2848         ret_ref = (uintptr_t)ret_var.inner;
2849         if (ret_var.is_owned) {
2850                 ret_ref |= 1;
2851         }
2852         return ret_ref;
2853 }
2854
2855 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2856 CHECK(!owner->result_ok);
2857         return DecodeError_clone(&*owner->contents.err);
2858 }
2859 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2860         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2861         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
2862         uint32_t ret_ref = 0;
2863         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2864         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2866         ret_ref = (uintptr_t)ret_var.inner;
2867         if (ret_var.is_owned) {
2868                 ret_ref |= 1;
2869         }
2870         return ret_ref;
2871 }
2872
2873 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2874 CHECK(owner->result_ok);
2875         return ChannelTypeFeatures_clone(&*owner->contents.result);
2876 }
2877 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2878         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2879         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
2880         uint32_t ret_ref = 0;
2881         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2882         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2884         ret_ref = (uintptr_t)ret_var.inner;
2885         if (ret_var.is_owned) {
2886                 ret_ref |= 1;
2887         }
2888         return ret_ref;
2889 }
2890
2891 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2892 CHECK(!owner->result_ok);
2893         return DecodeError_clone(&*owner->contents.err);
2894 }
2895 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2896         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2897         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
2898         uint32_t ret_ref = 0;
2899         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2900         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2902         ret_ref = (uintptr_t)ret_var.inner;
2903         if (ret_var.is_owned) {
2904                 ret_ref |= 1;
2905         }
2906         return ret_ref;
2907 }
2908
2909 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
2910 CHECK(owner->result_ok);
2911         return NodeId_clone(&*owner->contents.result);
2912 }
2913 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint32_t owner) {
2914         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
2915         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
2916         uint32_t ret_ref = 0;
2917         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2918         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2920         ret_ref = (uintptr_t)ret_var.inner;
2921         if (ret_var.is_owned) {
2922                 ret_ref |= 1;
2923         }
2924         return ret_ref;
2925 }
2926
2927 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
2928 CHECK(!owner->result_ok);
2929         return DecodeError_clone(&*owner->contents.err);
2930 }
2931 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint32_t owner) {
2932         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
2933         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
2934         uint32_t ret_ref = 0;
2935         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2936         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2938         ret_ref = (uintptr_t)ret_var.inner;
2939         if (ret_var.is_owned) {
2940                 ret_ref |= 1;
2941         }
2942         return ret_ref;
2943 }
2944
2945 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
2946 CHECK(owner->result_ok);
2947         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
2948 }
2949 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t owner) {
2950         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
2951         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
2952         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
2953         uint32_t ret_ref = (uintptr_t)ret_copy;
2954         return ret_ref;
2955 }
2956
2957 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
2958 CHECK(!owner->result_ok);
2959         return DecodeError_clone(&*owner->contents.err);
2960 }
2961 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t owner) {
2962         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
2963         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
2964         uint32_t ret_ref = 0;
2965         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2966         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2968         ret_ref = (uintptr_t)ret_var.inner;
2969         if (ret_var.is_owned) {
2970                 ret_ref |= 1;
2971         }
2972         return ret_ref;
2973 }
2974
2975 typedef struct LDKAccess_JCalls {
2976         atomic_size_t refcnt;
2977         uint32_t instance_ptr;
2978 } LDKAccess_JCalls;
2979 static void LDKAccess_JCalls_free(void* this_arg) {
2980         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
2981         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2982                 FREE(j_calls);
2983         }
2984 }
2985 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
2986         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
2987         int8_tArray genesis_hash_arr = init_int8_tArray(32, __LINE__);
2988         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
2989         int64_t short_channel_id_conv = short_channel_id;
2990         uint32_t ret = js_invoke_function_u_bb(j_calls->instance_ptr, 1, (uint32_t)genesis_hash_arr, (uint32_t)short_channel_id_conv);
2991         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2992         CHECK_ACCESS(ret_ptr);
2993         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
2994         FREE((void*)ret);
2995         return ret_conv;
2996 }
2997 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
2998         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
2999         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3000 }
3001 static inline LDKAccess LDKAccess_init (JSValue o) {
3002         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3003         atomic_init(&calls->refcnt, 1);
3004         calls->instance_ptr = o;
3005
3006         LDKAccess ret = {
3007                 .this_arg = (void*) calls,
3008                 .get_utxo = get_utxo_LDKAccess_jcall,
3009                 .free = LDKAccess_JCalls_free,
3010         };
3011         return ret;
3012 }
3013 long  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
3014         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3015         *res_ptr = LDKAccess_init(o);
3016         return (long)res_ptr;
3017 }
3018 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) {
3019         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3020         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3021         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
3022         unsigned char genesis_hash_arr[32];
3023         CHECK(genesis_hash->arr_len == 32);
3024         memcpy(genesis_hash_arr, genesis_hash->elems, 32); FREE(genesis_hash);
3025         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3026         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3027         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3028         return (uint32_t)ret_conv;
3029 }
3030
3031 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint32_t ptr) {
3032         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3033         switch(obj->tag) {
3034                 case LDKCOption_AccessZ_Some: return 0;
3035                 case LDKCOption_AccessZ_None: return 1;
3036                 default: abort();
3037         }
3038 }
3039 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint32_t ptr) {
3040         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3041         assert(obj->tag == LDKCOption_AccessZ_Some);
3042                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
3043                         *some_ret = obj->some;
3044                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
3045                         if ((*some_ret).free == LDKAccess_JCalls_free) {
3046                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
3047                                 LDKAccess_JCalls_cloned(&(*some_ret));
3048                         }
3049         return (uint32_t)some_ret;
3050 }
3051 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3052 CHECK(owner->result_ok);
3053         return *owner->contents.result;
3054 }
3055 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint32_t owner) {
3056         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3057         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
3058         return ret_conv;
3059 }
3060
3061 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3062 CHECK(!owner->result_ok);
3063         return LightningError_clone(&*owner->contents.err);
3064 }
3065 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint32_t owner) {
3066         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3067         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
3068         uint32_t ret_ref = 0;
3069         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3070         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3072         ret_ref = (uintptr_t)ret_var.inner;
3073         if (ret_var.is_owned) {
3074                 ret_ref |= 1;
3075         }
3076         return ret_ref;
3077 }
3078
3079 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3080         return ChannelAnnouncement_clone(&owner->a);
3081 }
3082 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t owner) {
3083         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3084         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
3085         uint32_t ret_ref = 0;
3086         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3087         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3089         ret_ref = (uintptr_t)ret_var.inner;
3090         if (ret_var.is_owned) {
3091                 ret_ref |= 1;
3092         }
3093         return ret_ref;
3094 }
3095
3096 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3097         return ChannelUpdate_clone(&owner->b);
3098 }
3099 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t owner) {
3100         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3101         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
3102         uint32_t ret_ref = 0;
3103         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3104         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3106         ret_ref = (uintptr_t)ret_var.inner;
3107         if (ret_var.is_owned) {
3108                 ret_ref |= 1;
3109         }
3110         return ret_ref;
3111 }
3112
3113 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3114         return ChannelUpdate_clone(&owner->c);
3115 }
3116 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t owner) {
3117         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3118         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
3119         uint32_t ret_ref = 0;
3120         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3121         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3123         ret_ref = (uintptr_t)ret_var.inner;
3124         if (ret_var.is_owned) {
3125                 ret_ref |= 1;
3126         }
3127         return ret_ref;
3128 }
3129
3130 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3131         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3132         for (size_t i = 0; i < ret.datalen; i++) {
3133                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3134         }
3135         return ret;
3136 }
3137 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3138         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3139         for (size_t i = 0; i < ret.datalen; i++) {
3140                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3141         }
3142         return ret;
3143 }
3144 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3145 CHECK(owner->result_ok);
3146         return *owner->contents.result;
3147 }
3148 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
3149         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3150         CResult_NoneLightningErrorZ_get_ok(owner_conv);
3151 }
3152
3153 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3154 CHECK(!owner->result_ok);
3155         return LightningError_clone(&*owner->contents.err);
3156 }
3157 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
3158         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3159         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
3160         uint32_t ret_ref = 0;
3161         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3162         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3164         ret_ref = (uintptr_t)ret_var.inner;
3165         if (ret_var.is_owned) {
3166                 ret_ref |= 1;
3167         }
3168         return ret_ref;
3169 }
3170
3171 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3172 CHECK(owner->result_ok);
3173         return ChannelUpdateInfo_clone(&*owner->contents.result);
3174 }
3175 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(uint32_t owner) {
3176         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3177         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
3178         uint32_t ret_ref = 0;
3179         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3180         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3182         ret_ref = (uintptr_t)ret_var.inner;
3183         if (ret_var.is_owned) {
3184                 ret_ref |= 1;
3185         }
3186         return ret_ref;
3187 }
3188
3189 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3190 CHECK(!owner->result_ok);
3191         return DecodeError_clone(&*owner->contents.err);
3192 }
3193 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err(uint32_t owner) {
3194         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3195         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
3196         uint32_t ret_ref = 0;
3197         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3198         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3200         ret_ref = (uintptr_t)ret_var.inner;
3201         if (ret_var.is_owned) {
3202                 ret_ref |= 1;
3203         }
3204         return ret_ref;
3205 }
3206
3207 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3208 CHECK(owner->result_ok);
3209         return ChannelInfo_clone(&*owner->contents.result);
3210 }
3211 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
3212         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3213         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
3214         uint32_t ret_ref = 0;
3215         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3216         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3218         ret_ref = (uintptr_t)ret_var.inner;
3219         if (ret_var.is_owned) {
3220                 ret_ref |= 1;
3221         }
3222         return ret_ref;
3223 }
3224
3225 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3226 CHECK(!owner->result_ok);
3227         return DecodeError_clone(&*owner->contents.err);
3228 }
3229 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
3230         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3231         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
3232         uint32_t ret_ref = 0;
3233         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3234         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3236         ret_ref = (uintptr_t)ret_var.inner;
3237         if (ret_var.is_owned) {
3238                 ret_ref |= 1;
3239         }
3240         return ret_ref;
3241 }
3242
3243 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3244 CHECK(owner->result_ok);
3245         return RoutingFees_clone(&*owner->contents.result);
3246 }
3247 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t owner) {
3248         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3249         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
3250         uint32_t ret_ref = 0;
3251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3254         ret_ref = (uintptr_t)ret_var.inner;
3255         if (ret_var.is_owned) {
3256                 ret_ref |= 1;
3257         }
3258         return ret_ref;
3259 }
3260
3261 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3262 CHECK(!owner->result_ok);
3263         return DecodeError_clone(&*owner->contents.err);
3264 }
3265 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint32_t owner) {
3266         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3267         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
3268         uint32_t ret_ref = 0;
3269         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3270         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3272         ret_ref = (uintptr_t)ret_var.inner;
3273         if (ret_var.is_owned) {
3274                 ret_ref |= 1;
3275         }
3276         return ret_ref;
3277 }
3278
3279 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint32_t ptr) {
3280         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3281         switch(obj->tag) {
3282                 case LDKNetAddress_IPv4: return 0;
3283                 case LDKNetAddress_IPv6: return 1;
3284                 case LDKNetAddress_OnionV2: return 2;
3285                 case LDKNetAddress_OnionV3: return 3;
3286                 default: abort();
3287         }
3288 }
3289 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint32_t ptr) {
3290         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3291         assert(obj->tag == LDKNetAddress_IPv4);
3292                         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
3293                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
3294         return addr_arr;
3295 }
3296 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint32_t ptr) {
3297         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3298         assert(obj->tag == LDKNetAddress_IPv4);
3299                         int16_t port_conv = obj->i_pv4.port;
3300         return port_conv;
3301 }
3302 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint32_t ptr) {
3303         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3304         assert(obj->tag == LDKNetAddress_IPv6);
3305                         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
3306                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
3307         return addr_arr;
3308 }
3309 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint32_t ptr) {
3310         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3311         assert(obj->tag == LDKNetAddress_IPv6);
3312                         int16_t port_conv = obj->i_pv6.port;
3313         return port_conv;
3314 }
3315 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint32_t ptr) {
3316         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3317         assert(obj->tag == LDKNetAddress_OnionV2);
3318                         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
3319                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
3320         return onion_v2_arr;
3321 }
3322 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint32_t ptr) {
3323         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3324         assert(obj->tag == LDKNetAddress_OnionV3);
3325                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
3326                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
3327         return ed25519_pubkey_arr;
3328 }
3329 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint32_t ptr) {
3330         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3331         assert(obj->tag == LDKNetAddress_OnionV3);
3332                         int16_t checksum_conv = obj->onion_v3.checksum;
3333         return checksum_conv;
3334 }
3335 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint32_t ptr) {
3336         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3337         assert(obj->tag == LDKNetAddress_OnionV3);
3338                         int8_t version_conv = obj->onion_v3.version;
3339         return version_conv;
3340 }
3341 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint32_t ptr) {
3342         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3343         assert(obj->tag == LDKNetAddress_OnionV3);
3344                         int16_t port_conv = obj->onion_v3.port;
3345         return port_conv;
3346 }
3347 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3348         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3349         for (size_t i = 0; i < ret.datalen; i++) {
3350                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3351         }
3352         return ret;
3353 }
3354 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3355 CHECK(owner->result_ok);
3356         return NodeAnnouncementInfo_clone(&*owner->contents.result);
3357 }
3358 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t owner) {
3359         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3360         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
3361         uint32_t ret_ref = 0;
3362         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3363         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3365         ret_ref = (uintptr_t)ret_var.inner;
3366         if (ret_var.is_owned) {
3367                 ret_ref |= 1;
3368         }
3369         return ret_ref;
3370 }
3371
3372 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3373 CHECK(!owner->result_ok);
3374         return DecodeError_clone(&*owner->contents.err);
3375 }
3376 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t owner) {
3377         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3378         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
3379         uint32_t ret_ref = 0;
3380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3383         ret_ref = (uintptr_t)ret_var.inner;
3384         if (ret_var.is_owned) {
3385                 ret_ref |= 1;
3386         }
3387         return ret_ref;
3388 }
3389
3390 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
3391 CHECK(owner->result_ok);
3392         return NodeAlias_clone(&*owner->contents.result);
3393 }
3394 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_get_ok"))) TS_CResult_NodeAliasDecodeErrorZ_get_ok(uint32_t owner) {
3395         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
3396         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
3397         uint32_t ret_ref = 0;
3398         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3399         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3401         ret_ref = (uintptr_t)ret_var.inner;
3402         if (ret_var.is_owned) {
3403                 ret_ref |= 1;
3404         }
3405         return ret_ref;
3406 }
3407
3408 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
3409 CHECK(!owner->result_ok);
3410         return DecodeError_clone(&*owner->contents.err);
3411 }
3412 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_get_err"))) TS_CResult_NodeAliasDecodeErrorZ_get_err(uint32_t owner) {
3413         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
3414         LDKDecodeError ret_var = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
3415         uint32_t ret_ref = 0;
3416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3419         ret_ref = (uintptr_t)ret_var.inner;
3420         if (ret_var.is_owned) {
3421                 ret_ref |= 1;
3422         }
3423         return ret_ref;
3424 }
3425
3426 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
3427         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
3428         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
3429         return ret;
3430 }
3431 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3432 CHECK(owner->result_ok);
3433         return NodeInfo_clone(&*owner->contents.result);
3434 }
3435 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint32_t owner) {
3436         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3437         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
3438         uint32_t ret_ref = 0;
3439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3442         ret_ref = (uintptr_t)ret_var.inner;
3443         if (ret_var.is_owned) {
3444                 ret_ref |= 1;
3445         }
3446         return ret_ref;
3447 }
3448
3449 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3450 CHECK(!owner->result_ok);
3451         return DecodeError_clone(&*owner->contents.err);
3452 }
3453 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint32_t owner) {
3454         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3455         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
3456         uint32_t ret_ref = 0;
3457         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3458         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3460         ret_ref = (uintptr_t)ret_var.inner;
3461         if (ret_var.is_owned) {
3462                 ret_ref |= 1;
3463         }
3464         return ret_ref;
3465 }
3466
3467 static inline struct LDKNetworkGraph *CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3468 CHECK(owner->result_ok);
3469         return &*owner->contents.result;
3470 }
3471 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t owner) {
3472         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3473         LDKNetworkGraph ret_var = *CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
3474         uint32_t ret_ref = 0;
3475         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3476         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3478         ret_ref = (uintptr_t)ret_var.inner & ~1;
3479         return ret_ref;
3480 }
3481
3482 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3483 CHECK(!owner->result_ok);
3484         return DecodeError_clone(&*owner->contents.err);
3485 }
3486 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint32_t owner) {
3487         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3488         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
3489         uint32_t ret_ref = 0;
3490         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3491         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3493         ret_ref = (uintptr_t)ret_var.inner;
3494         if (ret_var.is_owned) {
3495                 ret_ref |= 1;
3496         }
3497         return ret_ref;
3498 }
3499
3500 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint32_t ptr) {
3501         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
3502         switch(obj->tag) {
3503                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
3504                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
3505                 default: abort();
3506         }
3507 }
3508 uint32_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint32_t ptr) {
3509         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
3510         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
3511                         LDKCVec_NetAddressZ some_var = obj->some;
3512                         uint32_tArray some_arr = NULL;
3513                         some_arr = init_uint32_tArray(some_var.datalen, __LINE__);
3514                         uint32_t *some_arr_ptr = (uint32_t*)(((uint8_t*)some_arr) + 4);
3515                         for (size_t m = 0; m < some_var.datalen; m++) {
3516                                 uint32_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
3517                                 some_arr_ptr[m] = some_conv_12_ref;
3518                         }
3519                         
3520         return some_arr;
3521 }
3522 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3523 CHECK(owner->result_ok);
3524         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
3525 }
3526 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3527         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3528         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3529         uint32_t ret_ref = 0;
3530         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3531         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3533         ret_ref = (uintptr_t)ret_var.inner;
3534         if (ret_var.is_owned) {
3535                 ret_ref |= 1;
3536         }
3537         return ret_ref;
3538 }
3539
3540 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3541 CHECK(!owner->result_ok);
3542         return DecodeError_clone(&*owner->contents.err);
3543 }
3544 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3545         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3546         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3547         uint32_t ret_ref = 0;
3548         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3549         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3551         ret_ref = (uintptr_t)ret_var.inner;
3552         if (ret_var.is_owned) {
3553                 ret_ref |= 1;
3554         }
3555         return ret_ref;
3556 }
3557
3558 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3559 CHECK(owner->result_ok);
3560         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
3561 }
3562 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3563         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3564         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3565         uint32_t ret_ref = 0;
3566         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3567         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3569         ret_ref = (uintptr_t)ret_var.inner;
3570         if (ret_var.is_owned) {
3571                 ret_ref |= 1;
3572         }
3573         return ret_ref;
3574 }
3575
3576 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3577 CHECK(!owner->result_ok);
3578         return DecodeError_clone(&*owner->contents.err);
3579 }
3580 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3581         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3582         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3583         uint32_t ret_ref = 0;
3584         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3585         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3587         ret_ref = (uintptr_t)ret_var.inner;
3588         if (ret_var.is_owned) {
3589                 ret_ref |= 1;
3590         }
3591         return ret_ref;
3592 }
3593
3594 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3595 CHECK(owner->result_ok);
3596         return SpendableOutputDescriptor_clone(&*owner->contents.result);
3597 }
3598 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3599         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3600         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
3601         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3602         uint32_t ret_ref = (uintptr_t)ret_copy;
3603         return ret_ref;
3604 }
3605
3606 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3607 CHECK(!owner->result_ok);
3608         return DecodeError_clone(&*owner->contents.err);
3609 }
3610 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3611         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3612         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3613         uint32_t ret_ref = 0;
3614         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3615         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3617         ret_ref = (uintptr_t)ret_var.inner;
3618         if (ret_var.is_owned) {
3619                 ret_ref |= 1;
3620         }
3621         return ret_ref;
3622 }
3623
3624 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
3625         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
3626         for (size_t i = 0; i < ret.datalen; i++) {
3627                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3628         }
3629         return ret;
3630 }
3631 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3632         return owner->a;
3633 }
3634 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
3635         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3636         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3637         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
3638         return ret_arr;
3639 }
3640
3641 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3642         return owner->b;
3643 }
3644 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
3645         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3646         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
3647         ptrArray ret_arr = NULL;
3648         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
3649         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
3650         for (size_t m = 0; m < ret_var.datalen; m++) {
3651                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
3652                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
3653                 ret_arr_ptr[m] = ret_conv_12_arr;
3654         }
3655         
3656         return ret_arr;
3657 }
3658
3659 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3660 CHECK(owner->result_ok);
3661         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
3662 }
3663 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
3664         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3665         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
3666         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
3667         return ((uint32_t)ret_conv);
3668 }
3669
3670 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3671 CHECK(!owner->result_ok);
3672         return *owner->contents.err;
3673 }
3674 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
3675         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3676         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
3677 }
3678
3679 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3680 CHECK(owner->result_ok);
3681         return *owner->contents.result;
3682 }
3683 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
3684         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3685         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3686         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
3687         return ret_arr;
3688 }
3689
3690 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3691 CHECK(!owner->result_ok);
3692         return *owner->contents.err;
3693 }
3694 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
3695         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3696         CResult_SignatureNoneZ_get_err(owner_conv);
3697 }
3698
3699 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3700         return owner->a;
3701 }
3702 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_a"))) TS_C2Tuple_SignatureSignatureZ_get_a(uint32_t owner) {
3703         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3704         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3705         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form, 64);
3706         return ret_arr;
3707 }
3708
3709 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3710         return owner->b;
3711 }
3712 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_b"))) TS_C2Tuple_SignatureSignatureZ_get_b(uint32_t owner) {
3713         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3714         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3715         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form, 64);
3716         return ret_arr;
3717 }
3718
3719 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3720 CHECK(owner->result_ok);
3721         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
3722 }
3723 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(uint32_t owner) {
3724         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3725         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
3726         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
3727         return ((uint32_t)ret_conv);
3728 }
3729
3730 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3731 CHECK(!owner->result_ok);
3732         return *owner->contents.err;
3733 }
3734 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(uint32_t owner) {
3735         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3736         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
3737 }
3738
3739 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3740 CHECK(owner->result_ok);
3741         return *owner->contents.result;
3742 }
3743 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_ok"))) TS_CResult_SecretKeyNoneZ_get_ok(uint32_t owner) {
3744         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3745         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3746         memcpy(ret_arr->elems, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes, 32);
3747         return ret_arr;
3748 }
3749
3750 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3751 CHECK(!owner->result_ok);
3752         return *owner->contents.err;
3753 }
3754 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_err"))) TS_CResult_SecretKeyNoneZ_get_err(uint32_t owner) {
3755         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3756         CResult_SecretKeyNoneZ_get_err(owner_conv);
3757 }
3758
3759 typedef struct LDKBaseSign_JCalls {
3760         atomic_size_t refcnt;
3761         uint32_t instance_ptr;
3762 } LDKBaseSign_JCalls;
3763 static void LDKBaseSign_JCalls_free(void* this_arg) {
3764         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3765         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3766                 FREE(j_calls);
3767         }
3768 }
3769 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3770         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3771         int64_t idx_conv = idx;
3772         int8_tArray ret = (int8_tArray)js_invoke_function_u_b(j_calls->instance_ptr, 2, (uint32_t)idx_conv);
3773         LDKPublicKey ret_ref;
3774         CHECK(ret->arr_len == 33);
3775         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
3776         return ret_ref;
3777 }
3778 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3779         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3780         int64_t idx_conv = idx;
3781         int8_tArray ret = (int8_tArray)js_invoke_function_u_b(j_calls->instance_ptr, 3, (uint32_t)idx_conv);
3782         LDKThirtyTwoBytes ret_ref;
3783         CHECK(ret->arr_len == 32);
3784         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
3785         return ret_ref;
3786 }
3787 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
3788         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3789         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
3790         uint32_t holder_tx_ref = 0;
3791         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
3792         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3793         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3794         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
3795         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
3796         if (holder_tx_var.is_owned) {
3797                 holder_tx_ref |= 1;
3798         }
3799         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3800         ptrArray preimages_arr = NULL;
3801         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3802         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
3803         for (size_t m = 0; m < preimages_var.datalen; m++) {
3804                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3805                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
3806                 preimages_arr_ptr[m] = preimages_conv_12_arr;
3807         }
3808         
3809         FREE(preimages_var.data);
3810         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 4, (uint32_t)holder_tx_ref, (uint32_t)preimages_arr);
3811         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3812         CHECK_ACCESS(ret_ptr);
3813         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3814         FREE((void*)ret);
3815         return ret_conv;
3816 }
3817 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
3818         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3819         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 5);
3820         LDKThirtyTwoBytes ret_ref;
3821         CHECK(ret->arr_len == 32);
3822         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
3823         return ret_ref;
3824 }
3825 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
3826         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3827         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
3828         uint32_t commitment_tx_ref = 0;
3829         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
3830         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3831         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3832         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3833         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3834         if (commitment_tx_var.is_owned) {
3835                 commitment_tx_ref |= 1;
3836         }
3837         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3838         ptrArray preimages_arr = NULL;
3839         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3840         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
3841         for (size_t m = 0; m < preimages_var.datalen; m++) {
3842                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3843                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
3844                 preimages_arr_ptr[m] = preimages_conv_12_arr;
3845         }
3846         
3847         FREE(preimages_var.data);
3848         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 6, (uint32_t)commitment_tx_ref, (uint32_t)preimages_arr);
3849         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3850         CHECK_ACCESS(ret_ptr);
3851         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3852         FREE((void*)ret);
3853         return ret_conv;
3854 }
3855 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
3856         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3857         int64_t idx_conv = idx;
3858         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
3859         memcpy(secret_arr->elems, *secret, 32);
3860         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 7, (uint32_t)idx_conv, (uint32_t)secret_arr);
3861         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3862         CHECK_ACCESS(ret_ptr);
3863         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3864         FREE((void*)ret);
3865         return ret_conv;
3866 }
3867 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3868         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3869         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3870         uint32_t commitment_tx_ref = 0;
3871         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
3872         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3873         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3874         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3875         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3876         if (commitment_tx_var.is_owned) {
3877                 commitment_tx_ref |= 1;
3878         }
3879         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 8, (uint32_t)commitment_tx_ref);
3880         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3881         CHECK_ACCESS(ret_ptr);
3882         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3883         FREE((void*)ret);
3884         return ret_conv;
3885 }
3886 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]) {
3887         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3888         LDKTransaction justice_tx_var = justice_tx;
3889         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3890         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3891         Transaction_free(justice_tx_var);
3892         uint32_t input_conv = input;
3893         int64_t amount_conv = amount;
3894         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3895         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3896         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);
3897         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3898         CHECK_ACCESS(ret_ptr);
3899         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3900         FREE((void*)ret);
3901         return ret_conv;
3902 }
3903 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) {
3904         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3905         LDKTransaction justice_tx_var = justice_tx;
3906         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3907         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3908         Transaction_free(justice_tx_var);
3909         uint32_t input_conv = input;
3910         int64_t amount_conv = amount;
3911         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3912         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3913         LDKHTLCOutputInCommitment htlc_var = *htlc;
3914         uint32_t htlc_ref = 0;
3915         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3916         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3917         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3918         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3919         htlc_ref = (uintptr_t)htlc_var.inner;
3920         if (htlc_var.is_owned) {
3921                 htlc_ref |= 1;
3922         }
3923         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);
3924         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3925         CHECK_ACCESS(ret_ptr);
3926         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3927         FREE((void*)ret);
3928         return ret_conv;
3929 }
3930 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) {
3931         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3932         LDKTransaction htlc_tx_var = htlc_tx;
3933         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
3934         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
3935         Transaction_free(htlc_tx_var);
3936         uint32_t input_conv = input;
3937         int64_t amount_conv = amount;
3938         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
3939         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
3940         LDKHTLCOutputInCommitment htlc_var = *htlc;
3941         uint32_t htlc_ref = 0;
3942         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3943         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3944         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3945         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3946         htlc_ref = (uintptr_t)htlc_var.inner;
3947         if (htlc_var.is_owned) {
3948                 htlc_ref |= 1;
3949         }
3950         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);
3951         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3952         CHECK_ACCESS(ret_ptr);
3953         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3954         FREE((void*)ret);
3955         return ret_conv;
3956 }
3957 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
3958         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3959         LDKClosingTransaction closing_tx_var = *closing_tx;
3960         uint32_t closing_tx_ref = 0;
3961         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
3962         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3963         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3964         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
3965         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
3966         if (closing_tx_var.is_owned) {
3967                 closing_tx_ref |= 1;
3968         }
3969         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 12, (uint32_t)closing_tx_ref);
3970         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3971         CHECK_ACCESS(ret_ptr);
3972         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3973         FREE((void*)ret);
3974         return ret_conv;
3975 }
3976 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
3977         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3978         LDKUnsignedChannelAnnouncement msg_var = *msg;
3979         uint32_t msg_ref = 0;
3980         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
3981         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3982         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3983         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3984         msg_ref = (uintptr_t)msg_var.inner;
3985         if (msg_var.is_owned) {
3986                 msg_ref |= 1;
3987         }
3988         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 13, (uint32_t)msg_ref);
3989         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3990         CHECK_ACCESS(ret_ptr);
3991         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
3992         FREE((void*)ret);
3993         return ret_conv;
3994 }
3995 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
3996         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3997         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
3998         uint32_t channel_parameters_ref = 0;
3999         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
4000         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4001         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4002         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
4003         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
4004         if (channel_parameters_var.is_owned) {
4005                 channel_parameters_ref |= 1;
4006         }
4007         js_invoke_function_u_u(j_calls->instance_ptr, 14, (uint32_t)channel_parameters_ref);
4008 }
4009 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
4010         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
4011         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4012 }
4013 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint32_t pubkeys) {
4014         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
4015         atomic_init(&calls->refcnt, 1);
4016         calls->instance_ptr = o;
4017
4018         LDKChannelPublicKeys pubkeys_conv;
4019         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4020         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4021         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4022
4023         LDKBaseSign ret = {
4024                 .this_arg = (void*) calls,
4025                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
4026                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
4027                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
4028                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
4029                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
4030                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
4031                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
4032                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
4033                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
4034                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
4035                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
4036                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
4037                 .ready_channel = ready_channel_LDKBaseSign_jcall,
4038                 .free = LDKBaseSign_JCalls_free,
4039                 .pubkeys = pubkeys_conv,
4040                 .set_pubkeys = NULL,
4041         };
4042         return ret;
4043 }
4044 long  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint32_t pubkeys) {
4045         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
4046         *res_ptr = LDKBaseSign_init(o, pubkeys);
4047         return (long)res_ptr;
4048 }
4049 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
4050         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4051         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4052         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4053         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
4054         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
4055         return ret_arr;
4056 }
4057
4058 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
4059         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4060         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4061         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4062         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4063         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
4064         return ret_arr;
4065 }
4066
4067 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) {
4068         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4069         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4070         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4071         LDKHolderCommitmentTransaction holder_tx_conv;
4072         holder_tx_conv.inner = (void*)(holder_tx & (~1));
4073         holder_tx_conv.is_owned = false;
4074         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
4075         LDKCVec_PaymentPreimageZ preimages_constr;
4076         preimages_constr.datalen = preimages->arr_len;
4077         if (preimages_constr.datalen > 0)
4078                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4079         else
4080                 preimages_constr.data = NULL;
4081         int8_tArray* preimages_vals = (void*) preimages->elems;
4082         for (size_t m = 0; m < preimages_constr.datalen; m++) {
4083                 int8_tArray preimages_conv_12 = preimages_vals[m];
4084                 LDKThirtyTwoBytes preimages_conv_12_ref;
4085                 CHECK(preimages_conv_12->arr_len == 32);
4086                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
4087                 preimages_constr.data[m] = preimages_conv_12_ref;
4088         }
4089         FREE(preimages);
4090         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4091         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
4092         return (uint32_t)ret_conv;
4093 }
4094
4095 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
4096         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4097         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4098         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4099         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4100         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
4101         return ret_arr;
4102 }
4103
4104 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) {
4105         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4106         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4107         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4108         LDKCommitmentTransaction commitment_tx_conv;
4109         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4110         commitment_tx_conv.is_owned = false;
4111         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4112         LDKCVec_PaymentPreimageZ preimages_constr;
4113         preimages_constr.datalen = preimages->arr_len;
4114         if (preimages_constr.datalen > 0)
4115                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4116         else
4117                 preimages_constr.data = NULL;
4118         int8_tArray* preimages_vals = (void*) preimages->elems;
4119         for (size_t m = 0; m < preimages_constr.datalen; m++) {
4120                 int8_tArray preimages_conv_12 = preimages_vals[m];
4121                 LDKThirtyTwoBytes preimages_conv_12_ref;
4122                 CHECK(preimages_conv_12->arr_len == 32);
4123                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
4124                 preimages_constr.data[m] = preimages_conv_12_ref;
4125         }
4126         FREE(preimages);
4127         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4128         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
4129         return (uint32_t)ret_conv;
4130 }
4131
4132 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) {
4133         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4134         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4135         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4136         unsigned char secret_arr[32];
4137         CHECK(secret->arr_len == 32);
4138         memcpy(secret_arr, secret->elems, 32); FREE(secret);
4139         unsigned char (*secret_ref)[32] = &secret_arr;
4140         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4141         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
4142         return (uint32_t)ret_conv;
4143 }
4144
4145 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) {
4146         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4147         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4148         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4149         LDKHolderCommitmentTransaction commitment_tx_conv;
4150         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4151         commitment_tx_conv.is_owned = false;
4152         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4153         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4154         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
4155         return (uint32_t)ret_conv;
4156 }
4157
4158 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) {
4159         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4160         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4161         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4162         LDKTransaction justice_tx_ref;
4163         justice_tx_ref.datalen = justice_tx->arr_len;
4164         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4165         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
4166         justice_tx_ref.data_is_owned = true;
4167         unsigned char per_commitment_key_arr[32];
4168         CHECK(per_commitment_key->arr_len == 32);
4169         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
4170         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4171         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4172         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
4173         return (uint32_t)ret_conv;
4174 }
4175
4176 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) {
4177         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4178         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4179         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4180         LDKTransaction justice_tx_ref;
4181         justice_tx_ref.datalen = justice_tx->arr_len;
4182         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4183         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
4184         justice_tx_ref.data_is_owned = true;
4185         unsigned char per_commitment_key_arr[32];
4186         CHECK(per_commitment_key->arr_len == 32);
4187         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
4188         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4189         LDKHTLCOutputInCommitment htlc_conv;
4190         htlc_conv.inner = (void*)(htlc & (~1));
4191         htlc_conv.is_owned = false;
4192         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4193         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4194         *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);
4195         return (uint32_t)ret_conv;
4196 }
4197
4198 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) {
4199         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4200         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4201         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4202         LDKTransaction htlc_tx_ref;
4203         htlc_tx_ref.datalen = htlc_tx->arr_len;
4204         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
4205         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
4206         htlc_tx_ref.data_is_owned = true;
4207         LDKPublicKey per_commitment_point_ref;
4208         CHECK(per_commitment_point->arr_len == 33);
4209         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
4210         LDKHTLCOutputInCommitment htlc_conv;
4211         htlc_conv.inner = (void*)(htlc & (~1));
4212         htlc_conv.is_owned = false;
4213         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4214         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4215         *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);
4216         return (uint32_t)ret_conv;
4217 }
4218
4219 uint32_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
4220         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4221         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4222         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4223         LDKClosingTransaction closing_tx_conv;
4224         closing_tx_conv.inner = (void*)(closing_tx & (~1));
4225         closing_tx_conv.is_owned = false;
4226         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
4227         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4228         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
4229         return (uint32_t)ret_conv;
4230 }
4231
4232 uint32_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
4233         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4234         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4235         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4236         LDKUnsignedChannelAnnouncement msg_conv;
4237         msg_conv.inner = (void*)(msg & (~1));
4238         msg_conv.is_owned = false;
4239         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
4240         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
4241         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
4242         return (uint32_t)ret_conv;
4243 }
4244
4245 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
4246         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4247         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4248         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4249         LDKChannelTransactionParameters channel_parameters_conv;
4250         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
4251         channel_parameters_conv.is_owned = false;
4252         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
4253         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
4254 }
4255
4256 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
4257         if (this_arg->set_pubkeys != NULL)
4258                 this_arg->set_pubkeys(this_arg);
4259         return this_arg->pubkeys;
4260 }
4261 uint32_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
4262         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4263         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4264         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4265         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
4266         uint32_t ret_ref = 0;
4267         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4268         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4270         ret_ref = (uintptr_t)ret_var.inner;
4271         if (ret_var.is_owned) {
4272                 ret_ref |= 1;
4273         }
4274         return ret_ref;
4275 }
4276
4277 typedef struct LDKSign_JCalls {
4278         atomic_size_t refcnt;
4279         uint32_t instance_ptr;
4280         LDKBaseSign_JCalls* BaseSign;
4281 } LDKSign_JCalls;
4282 static void LDKSign_JCalls_free(void* this_arg) {
4283         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4284         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4285                 FREE(j_calls);
4286         }
4287 }
4288 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
4289         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4290         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 15);
4291         LDKCVec_u8Z ret_ref;
4292         ret_ref.datalen = ret->arr_len;
4293         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4294         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4295         return ret_ref;
4296 }
4297 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
4298         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
4299         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4300         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
4301 }
4302 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint32_t pubkeys) {
4303         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
4304         atomic_init(&calls->refcnt, 1);
4305         calls->instance_ptr = o;
4306
4307         LDKChannelPublicKeys pubkeys_conv;
4308         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4309         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4310         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4311
4312         LDKSign ret = {
4313                 .this_arg = (void*) calls,
4314                 .write = write_LDKSign_jcall,
4315                 .cloned = LDKSign_JCalls_cloned,
4316                 .free = LDKSign_JCalls_free,
4317                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
4318         };
4319         calls->BaseSign = ret.BaseSign.this_arg;
4320         return ret;
4321 }
4322 long  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint32_t pubkeys) {
4323         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
4324         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
4325         return (long)res_ptr;
4326 }
4327 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint32_t this_arg) {
4328         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4329         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4330         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
4331         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4332         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4333         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4334         CVec_u8Z_free(ret_var);
4335         return ret_arr;
4336 }
4337
4338 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4339 CHECK(owner->result_ok);
4340         return Sign_clone(&*owner->contents.result);
4341 }
4342 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint32_t owner) {
4343         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4344         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4345         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
4346         return (uint32_t)ret_ret;
4347 }
4348
4349 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4350 CHECK(!owner->result_ok);
4351         return DecodeError_clone(&*owner->contents.err);
4352 }
4353 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint32_t owner) {
4354         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4355         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
4356         uint32_t ret_ref = 0;
4357         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4358         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4360         ret_ref = (uintptr_t)ret_var.inner;
4361         if (ret_var.is_owned) {
4362                 ret_ref |= 1;
4363         }
4364         return ret_ref;
4365 }
4366
4367 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4368 CHECK(owner->result_ok);
4369         return *owner->contents.result;
4370 }
4371 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint32_t owner) {
4372         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4373         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
4374         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
4375         return ret_arr;
4376 }
4377
4378 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4379 CHECK(!owner->result_ok);
4380         return *owner->contents.err;
4381 }
4382 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint32_t owner) {
4383         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4384         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
4385 }
4386
4387 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
4388         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
4389         for (size_t i = 0; i < ret.datalen; i++) {
4390                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
4391         }
4392         return ret;
4393 }
4394 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4395 CHECK(owner->result_ok);
4396         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
4397 }
4398 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t owner) {
4399         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4400         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
4401         ptrArray ret_arr = NULL;
4402         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
4403         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
4404         for (size_t m = 0; m < ret_var.datalen; m++) {
4405                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
4406                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
4407                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
4408                 CVec_u8Z_free(ret_conv_12_var);
4409                 ret_arr_ptr[m] = ret_conv_12_arr;
4410         }
4411         
4412         FREE(ret_var.data);
4413         return ret_arr;
4414 }
4415
4416 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4417 CHECK(!owner->result_ok);
4418         return *owner->contents.err;
4419 }
4420 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t owner) {
4421         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4422         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
4423 }
4424
4425 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4426 CHECK(owner->result_ok);
4427         return InMemorySigner_clone(&*owner->contents.result);
4428 }
4429 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t owner) {
4430         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4431         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
4432         uint32_t ret_ref = 0;
4433         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4434         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4436         ret_ref = (uintptr_t)ret_var.inner;
4437         if (ret_var.is_owned) {
4438                 ret_ref |= 1;
4439         }
4440         return ret_ref;
4441 }
4442
4443 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4444 CHECK(!owner->result_ok);
4445         return DecodeError_clone(&*owner->contents.err);
4446 }
4447 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint32_t owner) {
4448         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4449         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
4450         uint32_t ret_ref = 0;
4451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4454         ret_ref = (uintptr_t)ret_var.inner;
4455         if (ret_var.is_owned) {
4456                 ret_ref |= 1;
4457         }
4458         return ret_ref;
4459 }
4460
4461 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
4462         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
4463         for (size_t i = 0; i < ret.datalen; i++) {
4464                 ret.data[i] = TxOut_clone(&orig->data[i]);
4465         }
4466         return ret;
4467 }
4468 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4469 CHECK(owner->result_ok);
4470         return *owner->contents.result;
4471 }
4472 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint32_t owner) {
4473         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4474         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
4475         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4476         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4477         return ret_arr;
4478 }
4479
4480 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4481 CHECK(!owner->result_ok);
4482         return *owner->contents.err;
4483 }
4484 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint32_t owner) {
4485         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4486         CResult_TransactionNoneZ_get_err(owner_conv);
4487 }
4488
4489 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint32_t ptr) {
4490         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4491         switch(obj->tag) {
4492                 case LDKCOption_u16Z_Some: return 0;
4493                 case LDKCOption_u16Z_None: return 1;
4494                 default: abort();
4495         }
4496 }
4497 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint32_t ptr) {
4498         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4499         assert(obj->tag == LDKCOption_u16Z_Some);
4500                         int16_t some_conv = obj->some;
4501         return some_conv;
4502 }
4503 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint32_t ptr) {
4504         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4505         switch(obj->tag) {
4506                 case LDKAPIError_APIMisuseError: return 0;
4507                 case LDKAPIError_FeeRateTooHigh: return 1;
4508                 case LDKAPIError_RouteError: return 2;
4509                 case LDKAPIError_ChannelUnavailable: return 3;
4510                 case LDKAPIError_MonitorUpdateFailed: return 4;
4511                 case LDKAPIError_IncompatibleShutdownScript: return 5;
4512                 default: abort();
4513         }
4514 }
4515 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint32_t ptr) {
4516         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4517         assert(obj->tag == LDKAPIError_APIMisuseError);
4518                         LDKStr err_str = obj->api_misuse_error.err;
4519                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4520         return err_conv;
4521 }
4522 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint32_t ptr) {
4523         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4524         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
4525                         LDKStr err_str = obj->fee_rate_too_high.err;
4526                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4527         return err_conv;
4528 }
4529 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint32_t ptr) {
4530         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4531         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
4532                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
4533         return feerate_conv;
4534 }
4535 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint32_t ptr) {
4536         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4537         assert(obj->tag == LDKAPIError_RouteError);
4538                         LDKStr err_str = obj->route_error.err;
4539                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4540         return err_conv;
4541 }
4542 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint32_t ptr) {
4543         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4544         assert(obj->tag == LDKAPIError_ChannelUnavailable);
4545                         LDKStr err_str = obj->channel_unavailable.err;
4546                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4547         return err_conv;
4548 }
4549 uint32_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint32_t ptr) {
4550         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4551         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
4552                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
4553                         uint32_t script_ref = 0;
4554                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4555                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4556                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
4557                         script_ref = (uintptr_t)script_var.inner & ~1;
4558         return script_ref;
4559 }
4560 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4561 CHECK(owner->result_ok);
4562         return *owner->contents.result;
4563 }
4564 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint32_t owner) {
4565         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4566         CResult_NoneAPIErrorZ_get_ok(owner_conv);
4567 }
4568
4569 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4570 CHECK(!owner->result_ok);
4571         return APIError_clone(&*owner->contents.err);
4572 }
4573 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint32_t owner) {
4574         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4575         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4576         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
4577         uint32_t ret_ref = (uintptr_t)ret_copy;
4578         return ret_ref;
4579 }
4580
4581 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
4582         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
4583         for (size_t i = 0; i < ret.datalen; i++) {
4584                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
4585         }
4586         return ret;
4587 }
4588 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
4589         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
4590         for (size_t i = 0; i < ret.datalen; i++) {
4591                 ret.data[i] = APIError_clone(&orig->data[i]);
4592         }
4593         return ret;
4594 }
4595 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4596 CHECK(owner->result_ok);
4597         return ThirtyTwoBytes_clone(&*owner->contents.result);
4598 }
4599 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint32_t owner) {
4600         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4601         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4602         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
4603         return ret_arr;
4604 }
4605
4606 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4607 CHECK(!owner->result_ok);
4608         return APIError_clone(&*owner->contents.err);
4609 }
4610 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint32_t owner) {
4611         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4612         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4613         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
4614         uint32_t ret_ref = (uintptr_t)ret_copy;
4615         return ret_ref;
4616 }
4617
4618 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint32_t ptr) {
4619         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4620         switch(obj->tag) {
4621                 case LDKPaymentSendFailure_ParameterError: return 0;
4622                 case LDKPaymentSendFailure_PathParameterError: return 1;
4623                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
4624                 case LDKPaymentSendFailure_PartialFailure: return 3;
4625                 default: abort();
4626         }
4627 }
4628 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint32_t ptr) {
4629         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4630         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
4631                         uint32_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
4632         return parameter_error_ref;
4633 }
4634 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint32_t ptr) {
4635         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4636         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
4637                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
4638                         uint32_tArray path_parameter_error_arr = NULL;
4639                         path_parameter_error_arr = init_uint32_tArray(path_parameter_error_var.datalen, __LINE__);
4640                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(((uint8_t*)path_parameter_error_arr) + 4);
4641                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
4642                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4643                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
4644                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
4645                                 path_parameter_error_arr_ptr[w] = (uint32_t)path_parameter_error_conv_22_conv;
4646                         }
4647                         
4648         return path_parameter_error_arr;
4649 }
4650 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint32_t ptr) {
4651         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4652         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
4653                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
4654                         uint32_tArray all_failed_retry_safe_arr = NULL;
4655                         all_failed_retry_safe_arr = init_uint32_tArray(all_failed_retry_safe_var.datalen, __LINE__);
4656                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(((uint8_t*)all_failed_retry_safe_arr) + 4);
4657                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
4658                                 uint32_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
4659                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
4660                         }
4661                         
4662         return all_failed_retry_safe_arr;
4663 }
4664 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint32_t ptr) {
4665         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4666         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4667                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
4668                         uint32_tArray results_arr = NULL;
4669                         results_arr = init_uint32_tArray(results_var.datalen, __LINE__);
4670                         uint32_t *results_arr_ptr = (uint32_t*)(((uint8_t*)results_arr) + 4);
4671                         for (size_t w = 0; w < results_var.datalen; w++) {
4672                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4673                                 *results_conv_22_conv = results_var.data[w];
4674                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
4675                                 results_arr_ptr[w] = (uint32_t)results_conv_22_conv;
4676                         }
4677                         
4678         return results_arr;
4679 }
4680 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint32_t ptr) {
4681         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4682         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4683                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
4684                         uint32_t failed_paths_retry_ref = 0;
4685                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
4686                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4687                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4688                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
4689                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
4690                         }
4691         return failed_paths_retry_ref;
4692 }
4693 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint32_t ptr) {
4694         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4695         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4696                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
4697                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
4698         return payment_id_arr;
4699 }
4700 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4701 CHECK(owner->result_ok);
4702         return ThirtyTwoBytes_clone(&*owner->contents.result);
4703 }
4704 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t owner) {
4705         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
4706         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4707         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
4708         return ret_arr;
4709 }
4710
4711 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4712 CHECK(!owner->result_ok);
4713         return PaymentSendFailure_clone(&*owner->contents.err);
4714 }
4715 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t owner) {
4716         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
4717         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4718         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
4719         uint32_t ret_ref = (uintptr_t)ret_copy;
4720         return ret_ref;
4721 }
4722
4723 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4724 CHECK(owner->result_ok);
4725         return *owner->contents.result;
4726 }
4727 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint32_t owner) {
4728         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
4729         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
4730 }
4731
4732 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4733 CHECK(!owner->result_ok);
4734         return PaymentSendFailure_clone(&*owner->contents.err);
4735 }
4736 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint32_t owner) {
4737         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
4738         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4739         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
4740         uint32_t ret_ref = (uintptr_t)ret_copy;
4741         return ret_ref;
4742 }
4743
4744 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4745         return ThirtyTwoBytes_clone(&owner->a);
4746 }
4747 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t owner) {
4748         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
4749         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4750         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
4751         return ret_arr;
4752 }
4753
4754 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4755         return ThirtyTwoBytes_clone(&owner->b);
4756 }
4757 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t owner) {
4758         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
4759         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4760         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
4761         return ret_arr;
4762 }
4763
4764 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
4765 CHECK(owner->result_ok);
4766         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
4767 }
4768 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t owner) {
4769         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
4770         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
4771         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
4772         return ((uint32_t)ret_conv);
4773 }
4774
4775 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
4776 CHECK(!owner->result_ok);
4777         return PaymentSendFailure_clone(&*owner->contents.err);
4778 }
4779 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t owner) {
4780         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
4781         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4782         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
4783         uint32_t ret_ref = (uintptr_t)ret_copy;
4784         return ret_ref;
4785 }
4786
4787 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
4788         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
4789         for (size_t i = 0; i < ret.datalen; i++) {
4790                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4791         }
4792         return ret;
4793 }
4794 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4795         return ThirtyTwoBytes_clone(&owner->a);
4796 }
4797 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t owner) {
4798         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4799         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4800         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
4801         return ret_arr;
4802 }
4803
4804 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4805         return ThirtyTwoBytes_clone(&owner->b);
4806 }
4807 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t owner) {
4808         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4809         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4810         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
4811         return ret_arr;
4812 }
4813
4814 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4815 CHECK(owner->result_ok);
4816         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4817 }
4818 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t owner) {
4819         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4820         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4821         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
4822         return ((uint32_t)ret_conv);
4823 }
4824
4825 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4826 CHECK(!owner->result_ok);
4827         return *owner->contents.err;
4828 }
4829 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t owner) {
4830         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4831         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
4832 }
4833
4834 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4835 CHECK(owner->result_ok);
4836         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4837 }
4838 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t owner) {
4839         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4840         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4841         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
4842         return ((uint32_t)ret_conv);
4843 }
4844
4845 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4846 CHECK(!owner->result_ok);
4847         return APIError_clone(&*owner->contents.err);
4848 }
4849 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t owner) {
4850         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4851         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4852         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
4853         uint32_t ret_ref = (uintptr_t)ret_copy;
4854         return ret_ref;
4855 }
4856
4857 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4858 CHECK(owner->result_ok);
4859         return ThirtyTwoBytes_clone(&*owner->contents.result);
4860 }
4861 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint32_t owner) {
4862         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4863         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4864         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
4865         return ret_arr;
4866 }
4867
4868 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4869 CHECK(!owner->result_ok);
4870         return *owner->contents.err;
4871 }
4872 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint32_t owner) {
4873         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4874         CResult_PaymentSecretNoneZ_get_err(owner_conv);
4875 }
4876
4877 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4878 CHECK(owner->result_ok);
4879         return ThirtyTwoBytes_clone(&*owner->contents.result);
4880 }
4881 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint32_t owner) {
4882         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4883         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4884         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
4885         return ret_arr;
4886 }
4887
4888 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4889 CHECK(!owner->result_ok);
4890         return APIError_clone(&*owner->contents.err);
4891 }
4892 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint32_t owner) {
4893         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4894         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4895         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
4896         uint32_t ret_ref = (uintptr_t)ret_copy;
4897         return ret_ref;
4898 }
4899
4900 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4901 CHECK(owner->result_ok);
4902         return ThirtyTwoBytes_clone(&*owner->contents.result);
4903 }
4904 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t owner) {
4905         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4906         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4907         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
4908         return ret_arr;
4909 }
4910
4911 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4912 CHECK(!owner->result_ok);
4913         return APIError_clone(&*owner->contents.err);
4914 }
4915 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint32_t owner) {
4916         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4917         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4918         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
4919         uint32_t ret_ref = (uintptr_t)ret_copy;
4920         return ret_ref;
4921 }
4922
4923 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4924 CHECK(owner->result_ok);
4925         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
4926 }
4927 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(uint32_t owner) {
4928         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4929         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
4930         uint32_t ret_ref = 0;
4931         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4932         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4934         ret_ref = (uintptr_t)ret_var.inner;
4935         if (ret_var.is_owned) {
4936                 ret_ref |= 1;
4937         }
4938         return ret_ref;
4939 }
4940
4941 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4942 CHECK(!owner->result_ok);
4943         return DecodeError_clone(&*owner->contents.err);
4944 }
4945 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(uint32_t owner) {
4946         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4947         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
4948         uint32_t ret_ref = 0;
4949         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4950         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4952         ret_ref = (uintptr_t)ret_var.inner;
4953         if (ret_var.is_owned) {
4954                 ret_ref |= 1;
4955         }
4956         return ret_ref;
4957 }
4958
4959 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4960 CHECK(owner->result_ok);
4961         return ChannelCounterparty_clone(&*owner->contents.result);
4962 }
4963 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok(uint32_t owner) {
4964         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4965         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
4966         uint32_t ret_ref = 0;
4967         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4968         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4970         ret_ref = (uintptr_t)ret_var.inner;
4971         if (ret_var.is_owned) {
4972                 ret_ref |= 1;
4973         }
4974         return ret_ref;
4975 }
4976
4977 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4978 CHECK(!owner->result_ok);
4979         return DecodeError_clone(&*owner->contents.err);
4980 }
4981 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err(uint32_t owner) {
4982         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4983         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
4984         uint32_t ret_ref = 0;
4985         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4986         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4988         ret_ref = (uintptr_t)ret_var.inner;
4989         if (ret_var.is_owned) {
4990                 ret_ref |= 1;
4991         }
4992         return ret_ref;
4993 }
4994
4995 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4996 CHECK(owner->result_ok);
4997         return ChannelDetails_clone(&*owner->contents.result);
4998 }
4999 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_ok(uint32_t owner) {
5000         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5001         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
5002         uint32_t ret_ref = 0;
5003         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5004         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5006         ret_ref = (uintptr_t)ret_var.inner;
5007         if (ret_var.is_owned) {
5008                 ret_ref |= 1;
5009         }
5010         return ret_ref;
5011 }
5012
5013 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5014 CHECK(!owner->result_ok);
5015         return DecodeError_clone(&*owner->contents.err);
5016 }
5017 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_err(uint32_t owner) {
5018         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5019         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
5020         uint32_t ret_ref = 0;
5021         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5022         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5024         ret_ref = (uintptr_t)ret_var.inner;
5025         if (ret_var.is_owned) {
5026                 ret_ref |= 1;
5027         }
5028         return ret_ref;
5029 }
5030
5031 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5032 CHECK(owner->result_ok);
5033         return PhantomRouteHints_clone(&*owner->contents.result);
5034 }
5035 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok(uint32_t owner) {
5036         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5037         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
5038         uint32_t ret_ref = 0;
5039         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5040         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5042         ret_ref = (uintptr_t)ret_var.inner;
5043         if (ret_var.is_owned) {
5044                 ret_ref |= 1;
5045         }
5046         return ret_ref;
5047 }
5048
5049 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5050 CHECK(!owner->result_ok);
5051         return DecodeError_clone(&*owner->contents.err);
5052 }
5053 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err(uint32_t owner) {
5054         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5055         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
5056         uint32_t ret_ref = 0;
5057         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5058         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5060         ret_ref = (uintptr_t)ret_var.inner;
5061         if (ret_var.is_owned) {
5062                 ret_ref |= 1;
5063         }
5064         return ret_ref;
5065 }
5066
5067 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
5068         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
5069         for (size_t i = 0; i < ret.datalen; i++) {
5070                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
5071         }
5072         return ret;
5073 }
5074 typedef struct LDKWatch_JCalls {
5075         atomic_size_t refcnt;
5076         uint32_t instance_ptr;
5077 } LDKWatch_JCalls;
5078 static void LDKWatch_JCalls_free(void* this_arg) {
5079         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5080         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5081                 FREE(j_calls);
5082         }
5083 }
5084 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
5085         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5086         LDKOutPoint funding_txo_var = funding_txo;
5087         uint32_t funding_txo_ref = 0;
5088         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5089         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5090         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5091         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5092         if (funding_txo_var.is_owned) {
5093                 funding_txo_ref |= 1;
5094         }
5095         LDKChannelMonitor monitor_var = monitor;
5096         uint32_t monitor_ref = 0;
5097         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5098         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5099         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
5100         monitor_ref = (uintptr_t)monitor_var.inner;
5101         if (monitor_var.is_owned) {
5102                 monitor_ref |= 1;
5103         }
5104         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 16, (uint32_t)funding_txo_ref, (uint32_t)monitor_ref);
5105         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5106         CHECK_ACCESS(ret_ptr);
5107         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5108         FREE((void*)ret);
5109         return ret_conv;
5110 }
5111 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
5112         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5113         LDKOutPoint funding_txo_var = funding_txo;
5114         uint32_t funding_txo_ref = 0;
5115         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5116         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5117         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5118         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5119         if (funding_txo_var.is_owned) {
5120                 funding_txo_ref |= 1;
5121         }
5122         LDKChannelMonitorUpdate update_var = update;
5123         uint32_t update_ref = 0;
5124         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5125         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5126         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5127         update_ref = (uintptr_t)update_var.inner;
5128         if (update_var.is_owned) {
5129                 update_ref |= 1;
5130         }
5131         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 17, (uint32_t)funding_txo_ref, (uint32_t)update_ref);
5132         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5133         CHECK_ACCESS(ret_ptr);
5134         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5135         FREE((void*)ret);
5136         return ret_conv;
5137 }
5138 LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
5139         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5140         uint32_tArray ret = (uint32_tArray)js_invoke_function_u_(j_calls->instance_ptr, 18);
5141         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret_constr;
5142         ret_constr.datalen = ret->arr_len;
5143         if (ret_constr.datalen > 0)
5144                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ Elements");
5145         else
5146                 ret_constr.data = NULL;
5147         uint32_t* ret_vals = ret->elems;
5148         for (size_t m = 0; m < ret_constr.datalen; m++) {
5149                 uint32_t ret_conv_38 = ret_vals[m];
5150                 void* ret_conv_38_ptr = (void*)(((uintptr_t)ret_conv_38) & ~1);
5151                 CHECK_ACCESS(ret_conv_38_ptr);
5152                 LDKC2Tuple_OutPointCVec_MonitorEventZZ ret_conv_38_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(ret_conv_38_ptr);
5153                 FREE((void*)ret_conv_38);
5154                 ret_constr.data[m] = ret_conv_38_conv;
5155         }
5156         FREE(ret);
5157         return ret_constr;
5158 }
5159 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
5160         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
5161         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5162 }
5163 static inline LDKWatch LDKWatch_init (JSValue o) {
5164         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
5165         atomic_init(&calls->refcnt, 1);
5166         calls->instance_ptr = o;
5167
5168         LDKWatch ret = {
5169                 .this_arg = (void*) calls,
5170                 .watch_channel = watch_channel_LDKWatch_jcall,
5171                 .update_channel = update_channel_LDKWatch_jcall,
5172                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
5173                 .free = LDKWatch_JCalls_free,
5174         };
5175         return ret;
5176 }
5177 long  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
5178         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
5179         *res_ptr = LDKWatch_init(o);
5180         return (long)res_ptr;
5181 }
5182 uint32_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
5183         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5184         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5185         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5186         LDKOutPoint funding_txo_conv;
5187         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5188         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5189         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5190         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5191         LDKChannelMonitor monitor_conv;
5192         monitor_conv.inner = (void*)(monitor & (~1));
5193         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
5194         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
5195         monitor_conv = ChannelMonitor_clone(&monitor_conv);
5196         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5197         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
5198         return (uint32_t)ret_conv;
5199 }
5200
5201 uint32_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
5202         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5203         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5204         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5205         LDKOutPoint funding_txo_conv;
5206         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5207         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5208         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5209         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5210         LDKChannelMonitorUpdate update_conv;
5211         update_conv.inner = (void*)(update & (~1));
5212         update_conv.is_owned = (update & 1) || (update == 0);
5213         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
5214         update_conv = ChannelMonitorUpdate_clone(&update_conv);
5215         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5216         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
5217         return (uint32_t)ret_conv;
5218 }
5219
5220 uint32_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
5221         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5222         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5223         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5224         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
5225         uint32_tArray ret_arr = NULL;
5226         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5227         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5228         for (size_t m = 0; m < ret_var.datalen; m++) {
5229                 LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv_38_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
5230                 *ret_conv_38_conv = ret_var.data[m];
5231                 ret_arr_ptr[m] = ((uint32_t)ret_conv_38_conv);
5232         }
5233         
5234         FREE(ret_var.data);
5235         return ret_arr;
5236 }
5237
5238 typedef struct LDKBroadcasterInterface_JCalls {
5239         atomic_size_t refcnt;
5240         uint32_t instance_ptr;
5241 } LDKBroadcasterInterface_JCalls;
5242 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
5243         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5244         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5245                 FREE(j_calls);
5246         }
5247 }
5248 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
5249         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5250         LDKTransaction tx_var = tx;
5251         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
5252         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
5253         Transaction_free(tx_var);
5254         js_invoke_function_u_u(j_calls->instance_ptr, 19, (uint32_t)tx_arr);
5255 }
5256 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
5257         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
5258         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5259 }
5260 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
5261         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
5262         atomic_init(&calls->refcnt, 1);
5263         calls->instance_ptr = o;
5264
5265         LDKBroadcasterInterface ret = {
5266                 .this_arg = (void*) calls,
5267                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
5268                 .free = LDKBroadcasterInterface_JCalls_free,
5269         };
5270         return ret;
5271 }
5272 long  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
5273         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
5274         *res_ptr = LDKBroadcasterInterface_init(o);
5275         return (long)res_ptr;
5276 }
5277 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
5278         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5279         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5280         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
5281         LDKTransaction tx_ref;
5282         tx_ref.datalen = tx->arr_len;
5283         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
5284         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
5285         tx_ref.data_is_owned = true;
5286         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
5287 }
5288
5289 typedef struct LDKKeysInterface_JCalls {
5290         atomic_size_t refcnt;
5291         uint32_t instance_ptr;
5292 } LDKKeysInterface_JCalls;
5293 static void LDKKeysInterface_JCalls_free(void* this_arg) {
5294         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5295         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5296                 FREE(j_calls);
5297         }
5298 }
5299 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
5300         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5301         uint32_t recipient_conv = LDKRecipient_to_js(recipient);
5302         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 20, (uint32_t)recipient_conv);
5303         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5304         CHECK_ACCESS(ret_ptr);
5305         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
5306         FREE((void*)ret);
5307         return ret_conv;
5308 }
5309 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
5310         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5311         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 21);
5312         LDKCVec_u8Z ret_ref;
5313         ret_ref.datalen = ret->arr_len;
5314         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5315         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5316         return ret_ref;
5317 }
5318 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
5319         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5320         uint32_t ret = js_invoke_function_u_(j_calls->instance_ptr, 22);
5321         LDKShutdownScript ret_conv;
5322         ret_conv.inner = (void*)(ret & (~1));
5323         ret_conv.is_owned = (ret & 1) || (ret == 0);
5324         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
5325         return ret_conv;
5326 }
5327 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
5328         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5329         jboolean inbound_conv = inbound;
5330         int64_t channel_value_satoshis_conv = channel_value_satoshis;
5331         uint32_t ret = js_invoke_function_u_bb(j_calls->instance_ptr, 23, (uint32_t)inbound_conv, (uint32_t)channel_value_satoshis_conv);
5332         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5333         CHECK_ACCESS(ret_ptr);
5334         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
5335         FREE((void*)ret);
5336         return ret_conv;
5337 }
5338 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
5339         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5340         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 24);
5341         LDKThirtyTwoBytes ret_ref;
5342         CHECK(ret->arr_len == 32);
5343         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
5344         return ret_ref;
5345 }
5346 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
5347         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5348         LDKu8slice reader_var = reader;
5349         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
5350         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
5351         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 25, (uint32_t)reader_arr);
5352         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5353         CHECK_ACCESS(ret_ptr);
5354         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
5355         FREE((void*)ret);
5356         return ret_conv;
5357 }
5358 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
5359         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5360         LDKu8slice hrp_bytes_var = hrp_bytes;
5361         int8_tArray hrp_bytes_arr = init_int8_tArray(hrp_bytes_var.datalen, __LINE__);
5362         memcpy(hrp_bytes_arr->elems, hrp_bytes_var.data, hrp_bytes_var.datalen);
5363         LDKCVec_u5Z invoice_data_var = invoice_data;
5364         ptrArray invoice_data_arr = NULL;
5365         invoice_data_arr = init_ptrArray(invoice_data_var.datalen, __LINE__);
5366         int8_t *invoice_data_arr_ptr = (int8_t*)(((uint8_t*)invoice_data_arr) + 4);
5367         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
5368                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
5369                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
5370         }
5371         
5372         FREE(invoice_data_var.data);
5373         uint32_t receipient_conv = LDKRecipient_to_js(receipient);
5374         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);
5375         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5376         CHECK_ACCESS(ret_ptr);
5377         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
5378         FREE((void*)ret);
5379         return ret_conv;
5380 }
5381 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
5382         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5383         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 27);
5384         LDKThirtyTwoBytes ret_ref;
5385         CHECK(ret->arr_len == 32);
5386         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
5387         return ret_ref;
5388 }
5389 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
5390         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
5391         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5392 }
5393 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
5394         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
5395         atomic_init(&calls->refcnt, 1);
5396         calls->instance_ptr = o;
5397
5398         LDKKeysInterface ret = {
5399                 .this_arg = (void*) calls,
5400                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
5401                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
5402                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
5403                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
5404                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
5405                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
5406                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
5407                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
5408                 .free = LDKKeysInterface_JCalls_free,
5409         };
5410         return ret;
5411 }
5412 long  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
5413         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
5414         *res_ptr = LDKKeysInterface_init(o);
5415         return (long)res_ptr;
5416 }
5417 uint32_t  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint32_t this_arg, uint32_t recipient) {
5418         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5419         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5420         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5421         LDKRecipient recipient_conv = LDKRecipient_from_js(recipient);
5422         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
5423         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
5424         return (uint32_t)ret_conv;
5425 }
5426
5427 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
5428         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5429         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5430         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5431         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
5432         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5433         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5434         CVec_u8Z_free(ret_var);
5435         return ret_arr;
5436 }
5437
5438 uint32_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
5439         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5440         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5441         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5442         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
5443         uint32_t ret_ref = 0;
5444         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5445         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5447         ret_ref = (uintptr_t)ret_var.inner;
5448         if (ret_var.is_owned) {
5449                 ret_ref |= 1;
5450         }
5451         return ret_ref;
5452 }
5453
5454 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) {
5455         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5456         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5457         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5458         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5459         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
5460         return (uint32_t)ret_ret;
5461 }
5462
5463 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
5464         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5465         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5466         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5467         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5468         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
5469         return ret_arr;
5470 }
5471
5472 uint32_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
5473         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5474         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5475         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5476         LDKu8slice reader_ref;
5477         reader_ref.datalen = reader->arr_len;
5478         reader_ref.data = reader->elems;
5479         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
5480         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
5481         FREE(reader);
5482         return (uint32_t)ret_conv;
5483 }
5484
5485 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) {
5486         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5487         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5488         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5489         LDKu8slice hrp_bytes_ref;
5490         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
5491         hrp_bytes_ref.data = hrp_bytes->elems;
5492         LDKCVec_u5Z invoice_data_constr;
5493         invoice_data_constr.datalen = invoice_data->arr_len;
5494         if (invoice_data_constr.datalen > 0)
5495                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
5496         else
5497                 invoice_data_constr.data = NULL;
5498         int8_t* invoice_data_vals = (void*) invoice_data->elems;
5499         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
5500                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
5501                 
5502                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
5503         }
5504         FREE(invoice_data);
5505         LDKRecipient receipient_conv = LDKRecipient_from_js(receipient);
5506         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
5507         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
5508         FREE(hrp_bytes);
5509         return (uint32_t)ret_conv;
5510 }
5511
5512 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
5513         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5514         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5515         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5516         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5517         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
5518         return ret_arr;
5519 }
5520
5521 typedef struct LDKFeeEstimator_JCalls {
5522         atomic_size_t refcnt;
5523         uint32_t instance_ptr;
5524 } LDKFeeEstimator_JCalls;
5525 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
5526         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5527         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5528                 FREE(j_calls);
5529         }
5530 }
5531 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
5532         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5533         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
5534         return js_invoke_function_u_u(j_calls->instance_ptr, 28, (uint32_t)confirmation_target_conv);
5535 }
5536 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
5537         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
5538         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5539 }
5540 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
5541         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
5542         atomic_init(&calls->refcnt, 1);
5543         calls->instance_ptr = o;
5544
5545         LDKFeeEstimator ret = {
5546                 .this_arg = (void*) calls,
5547                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
5548                 .free = LDKFeeEstimator_JCalls_free,
5549         };
5550         return ret;
5551 }
5552 long  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
5553         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
5554         *res_ptr = LDKFeeEstimator_init(o);
5555         return (long)res_ptr;
5556 }
5557 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) {
5558         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5559         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5560         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
5561         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
5562         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
5563         return ret_conv;
5564 }
5565
5566 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
5567         return ThirtyTwoBytes_clone(&owner->a);
5568 }
5569 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t owner) {
5570         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
5571         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5572         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
5573         return ret_arr;
5574 }
5575
5576 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
5577         return &owner->b;
5578 }
5579 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t owner) {
5580         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
5581         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
5582         uint32_t ret_ref = 0;
5583         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5584         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5586         ret_ref = (uintptr_t)ret_var.inner & ~1;
5587         return ret_ref;
5588 }
5589
5590 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
5591 CHECK(owner->result_ok);
5592         return &*owner->contents.result;
5593 }
5594 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t owner) {
5595         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
5596         uint32_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
5597         return ret_ret;
5598 }
5599
5600 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
5601 CHECK(!owner->result_ok);
5602         return DecodeError_clone(&*owner->contents.err);
5603 }
5604 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t owner) {
5605         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
5606         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
5607         uint32_t ret_ref = 0;
5608         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5609         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5611         ret_ref = (uintptr_t)ret_var.inner;
5612         if (ret_var.is_owned) {
5613                 ret_ref |= 1;
5614         }
5615         return ret_ref;
5616 }
5617
5618 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
5619 CHECK(owner->result_ok);
5620         return ChannelConfig_clone(&*owner->contents.result);
5621 }
5622 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t owner) {
5623         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
5624         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
5625         uint32_t ret_ref = 0;
5626         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5627         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5629         ret_ref = (uintptr_t)ret_var.inner;
5630         if (ret_var.is_owned) {
5631                 ret_ref |= 1;
5632         }
5633         return ret_ref;
5634 }
5635
5636 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
5637 CHECK(!owner->result_ok);
5638         return DecodeError_clone(&*owner->contents.err);
5639 }
5640 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint32_t owner) {
5641         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
5642         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
5643         uint32_t ret_ref = 0;
5644         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5645         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5647         ret_ref = (uintptr_t)ret_var.inner;
5648         if (ret_var.is_owned) {
5649                 ret_ref |= 1;
5650         }
5651         return ret_ref;
5652 }
5653
5654 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
5655 CHECK(owner->result_ok);
5656         return OutPoint_clone(&*owner->contents.result);
5657 }
5658 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint32_t owner) {
5659         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
5660         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
5661         uint32_t ret_ref = 0;
5662         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5663         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5664         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5665         ret_ref = (uintptr_t)ret_var.inner;
5666         if (ret_var.is_owned) {
5667                 ret_ref |= 1;
5668         }
5669         return ret_ref;
5670 }
5671
5672 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
5673 CHECK(!owner->result_ok);
5674         return DecodeError_clone(&*owner->contents.err);
5675 }
5676 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint32_t owner) {
5677         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
5678         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
5679         uint32_t ret_ref = 0;
5680         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5681         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5683         ret_ref = (uintptr_t)ret_var.inner;
5684         if (ret_var.is_owned) {
5685                 ret_ref |= 1;
5686         }
5687         return ret_ref;
5688 }
5689
5690 typedef struct LDKType_JCalls {
5691         atomic_size_t refcnt;
5692         uint32_t instance_ptr;
5693 } LDKType_JCalls;
5694 static void LDKType_JCalls_free(void* this_arg) {
5695         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5696         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5697                 FREE(j_calls);
5698         }
5699 }
5700 uint16_t type_id_LDKType_jcall(const void* this_arg) {
5701         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5702         return js_invoke_function_u_(j_calls->instance_ptr, 29);
5703 }
5704 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
5705         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5706         jstring ret = (jstring)js_invoke_function_u_(j_calls->instance_ptr, 30);
5707         LDKStr ret_conv = str_ref_to_owned_c(ret);
5708         return ret_conv;
5709 }
5710 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
5711         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5712         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 31);
5713         LDKCVec_u8Z ret_ref;
5714         ret_ref.datalen = ret->arr_len;
5715         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5716         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5717         return ret_ref;
5718 }
5719 static void LDKType_JCalls_cloned(LDKType* new_obj) {
5720         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
5721         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5722 }
5723 static inline LDKType LDKType_init (JSValue o) {
5724         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
5725         atomic_init(&calls->refcnt, 1);
5726         calls->instance_ptr = o;
5727
5728         LDKType ret = {
5729                 .this_arg = (void*) calls,
5730                 .type_id = type_id_LDKType_jcall,
5731                 .debug_str = debug_str_LDKType_jcall,
5732                 .write = write_LDKType_jcall,
5733                 .cloned = LDKType_JCalls_cloned,
5734                 .free = LDKType_JCalls_free,
5735         };
5736         return ret;
5737 }
5738 long  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
5739         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
5740         *res_ptr = LDKType_init(o);
5741         return (long)res_ptr;
5742 }
5743 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint32_t this_arg) {
5744         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5745         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5746         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5747         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
5748         return ret_conv;
5749 }
5750
5751 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(uint32_t this_arg) {
5752         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5753         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5754         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5755         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
5756         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5757         Str_free(ret_str);
5758         return ret_conv;
5759 }
5760
5761 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint32_t this_arg) {
5762         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5763         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5764         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5765         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5766         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5767         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5768         CVec_u8Z_free(ret_var);
5769         return ret_arr;
5770 }
5771
5772 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint32_t ptr) {
5773         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5774         switch(obj->tag) {
5775                 case LDKCOption_TypeZ_Some: return 0;
5776                 case LDKCOption_TypeZ_None: return 1;
5777                 default: abort();
5778         }
5779 }
5780 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint32_t ptr) {
5781         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5782         assert(obj->tag == LDKCOption_TypeZ_Some);
5783                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5784                         *some_ret = Type_clone(&obj->some);
5785         return (uint32_t)some_ret;
5786 }
5787 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5788 CHECK(owner->result_ok);
5789         return COption_TypeZ_clone(&*owner->contents.result);
5790 }
5791 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
5792         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5793         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
5794         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
5795         uint32_t ret_ref = (uintptr_t)ret_copy;
5796         return ret_ref;
5797 }
5798
5799 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5800 CHECK(!owner->result_ok);
5801         return DecodeError_clone(&*owner->contents.err);
5802 }
5803 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
5804         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5805         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
5806         uint32_t ret_ref = 0;
5807         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5808         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5810         ret_ref = (uintptr_t)ret_var.inner;
5811         if (ret_var.is_owned) {
5812                 ret_ref |= 1;
5813         }
5814         return ret_ref;
5815 }
5816
5817 uint32_t __attribute__((export_name("TS_LDKPaymentError_ty_from_ptr"))) TS_LDKPaymentError_ty_from_ptr(uint32_t ptr) {
5818         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5819         switch(obj->tag) {
5820                 case LDKPaymentError_Invoice: return 0;
5821                 case LDKPaymentError_Routing: return 1;
5822                 case LDKPaymentError_Sending: return 2;
5823                 default: abort();
5824         }
5825 }
5826 jstring __attribute__((export_name("TS_LDKPaymentError_Invoice_get_invoice"))) TS_LDKPaymentError_Invoice_get_invoice(uint32_t ptr) {
5827         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5828         assert(obj->tag == LDKPaymentError_Invoice);
5829                         LDKStr invoice_str = obj->invoice;
5830                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
5831         return invoice_conv;
5832 }
5833 uint32_t __attribute__((export_name("TS_LDKPaymentError_Routing_get_routing"))) TS_LDKPaymentError_Routing_get_routing(uint32_t ptr) {
5834         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5835         assert(obj->tag == LDKPaymentError_Routing);
5836                         LDKLightningError routing_var = obj->routing;
5837                         uint32_t routing_ref = 0;
5838                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5839                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5840                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
5841                         routing_ref = (uintptr_t)routing_var.inner & ~1;
5842         return routing_ref;
5843 }
5844 uint32_t __attribute__((export_name("TS_LDKPaymentError_Sending_get_sending"))) TS_LDKPaymentError_Sending_get_sending(uint32_t ptr) {
5845         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5846         assert(obj->tag == LDKPaymentError_Sending);
5847                         uint32_t sending_ref = ((uintptr_t)&obj->sending) | 1;
5848         return sending_ref;
5849 }
5850 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5851 CHECK(owner->result_ok);
5852         return ThirtyTwoBytes_clone(&*owner->contents.result);
5853 }
5854 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_ok"))) TS_CResult_PaymentIdPaymentErrorZ_get_ok(uint32_t owner) {
5855         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5856         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5857         memcpy(ret_arr->elems, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data, 32);
5858         return ret_arr;
5859 }
5860
5861 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5862 CHECK(!owner->result_ok);
5863         return PaymentError_clone(&*owner->contents.err);
5864 }
5865 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_err"))) TS_CResult_PaymentIdPaymentErrorZ_get_err(uint32_t owner) {
5866         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5867         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
5868         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
5869         uint32_t ret_ref = (uintptr_t)ret_copy;
5870         return ret_ref;
5871 }
5872
5873 uint32_t __attribute__((export_name("TS_LDKParseError_ty_from_ptr"))) TS_LDKParseError_ty_from_ptr(uint32_t ptr) {
5874         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5875         switch(obj->tag) {
5876                 case LDKParseError_Bech32Error: return 0;
5877                 case LDKParseError_ParseAmountError: return 1;
5878                 case LDKParseError_MalformedSignature: return 2;
5879                 case LDKParseError_BadPrefix: return 3;
5880                 case LDKParseError_UnknownCurrency: return 4;
5881                 case LDKParseError_UnknownSiPrefix: return 5;
5882                 case LDKParseError_MalformedHRP: return 6;
5883                 case LDKParseError_TooShortDataPart: return 7;
5884                 case LDKParseError_UnexpectedEndOfTaggedFields: return 8;
5885                 case LDKParseError_DescriptionDecodeError: return 9;
5886                 case LDKParseError_PaddingError: return 10;
5887                 case LDKParseError_IntegerOverflowError: return 11;
5888                 case LDKParseError_InvalidSegWitProgramLength: return 12;
5889                 case LDKParseError_InvalidPubKeyHashLength: return 13;
5890                 case LDKParseError_InvalidScriptHashLength: return 14;
5891                 case LDKParseError_InvalidRecoveryId: return 15;
5892                 case LDKParseError_InvalidSliceLength: return 16;
5893                 case LDKParseError_Skip: return 17;
5894                 default: abort();
5895         }
5896 }
5897 uint32_t __attribute__((export_name("TS_LDKParseError_Bech32Error_get_bech32_error"))) TS_LDKParseError_Bech32Error_get_bech32_error(uint32_t ptr) {
5898         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5899         assert(obj->tag == LDKParseError_Bech32Error);
5900                         uint32_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
5901         return bech32_error_ref;
5902 }
5903 int32_t __attribute__((export_name("TS_LDKParseError_ParseAmountError_get_parse_amount_error"))) TS_LDKParseError_ParseAmountError_get_parse_amount_error(uint32_t ptr) {
5904         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5905         assert(obj->tag == LDKParseError_ParseAmountError);
5906                         /*obj->parse_amount_error*/
5907         return 0;
5908 }
5909 uint32_t __attribute__((export_name("TS_LDKParseError_MalformedSignature_get_malformed_signature"))) TS_LDKParseError_MalformedSignature_get_malformed_signature(uint32_t ptr) {
5910         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5911         assert(obj->tag == LDKParseError_MalformedSignature);
5912                         uint32_t malformed_signature_conv = LDKSecp256k1Error_to_js(obj->malformed_signature);
5913         return malformed_signature_conv;
5914 }
5915 int32_t __attribute__((export_name("TS_LDKParseError_DescriptionDecodeError_get_description_decode_error"))) TS_LDKParseError_DescriptionDecodeError_get_description_decode_error(uint32_t ptr) {
5916         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5917         assert(obj->tag == LDKParseError_DescriptionDecodeError);
5918                         /*obj->description_decode_error*/
5919         return 0;
5920 }
5921 jstring __attribute__((export_name("TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length"))) TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length(uint32_t ptr) {
5922         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5923         assert(obj->tag == LDKParseError_InvalidSliceLength);
5924                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
5925                         jstring invalid_slice_length_conv = str_ref_to_ts(invalid_slice_length_str.chars, invalid_slice_length_str.len);
5926         return invalid_slice_length_conv;
5927 }
5928 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
5929 CHECK(owner->result_ok);
5930         return SiPrefix_clone(&*owner->contents.result);
5931 }
5932 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_ok"))) TS_CResult_SiPrefixParseErrorZ_get_ok(uint32_t owner) {
5933         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
5934         uint32_t ret_conv = LDKSiPrefix_to_js(CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
5935         return ret_conv;
5936 }
5937
5938 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
5939 CHECK(!owner->result_ok);
5940         return ParseError_clone(&*owner->contents.err);
5941 }
5942 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_err"))) TS_CResult_SiPrefixParseErrorZ_get_err(uint32_t owner) {
5943         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
5944         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
5945         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
5946         uint32_t ret_ref = (uintptr_t)ret_copy;
5947         return ret_ref;
5948 }
5949
5950 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ty_from_ptr"))) TS_LDKParseOrSemanticError_ty_from_ptr(uint32_t ptr) {
5951         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5952         switch(obj->tag) {
5953                 case LDKParseOrSemanticError_ParseError: return 0;
5954                 case LDKParseOrSemanticError_SemanticError: return 1;
5955                 default: abort();
5956         }
5957 }
5958 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ParseError_get_parse_error"))) TS_LDKParseOrSemanticError_ParseError_get_parse_error(uint32_t ptr) {
5959         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5960         assert(obj->tag == LDKParseOrSemanticError_ParseError);
5961                         uint32_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
5962         return parse_error_ref;
5963 }
5964 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_SemanticError_get_semantic_error"))) TS_LDKParseOrSemanticError_SemanticError_get_semantic_error(uint32_t ptr) {
5965         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5966         assert(obj->tag == LDKParseOrSemanticError_SemanticError);
5967                         uint32_t semantic_error_conv = LDKSemanticError_to_js(obj->semantic_error);
5968         return semantic_error_conv;
5969 }
5970 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
5971 CHECK(owner->result_ok);
5972         return Invoice_clone(&*owner->contents.result);
5973 }
5974 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok(uint32_t owner) {
5975         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
5976         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
5977         uint32_t ret_ref = 0;
5978         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5979         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5981         ret_ref = (uintptr_t)ret_var.inner;
5982         if (ret_var.is_owned) {
5983                 ret_ref |= 1;
5984         }
5985         return ret_ref;
5986 }
5987
5988 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
5989 CHECK(!owner->result_ok);
5990         return ParseOrSemanticError_clone(&*owner->contents.err);
5991 }
5992 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_err(uint32_t owner) {
5993         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
5994         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
5995         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
5996         uint32_t ret_ref = (uintptr_t)ret_copy;
5997         return ret_ref;
5998 }
5999
6000 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
6001 CHECK(owner->result_ok);
6002         return SignedRawInvoice_clone(&*owner->contents.result);
6003 }
6004 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_ok(uint32_t owner) {
6005         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
6006         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
6007         uint32_t ret_ref = 0;
6008         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6009         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6011         ret_ref = (uintptr_t)ret_var.inner;
6012         if (ret_var.is_owned) {
6013                 ret_ref |= 1;
6014         }
6015         return ret_ref;
6016 }
6017
6018 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
6019 CHECK(!owner->result_ok);
6020         return ParseError_clone(&*owner->contents.err);
6021 }
6022 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_err(uint32_t owner) {
6023         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
6024         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
6025         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
6026         uint32_t ret_ref = (uintptr_t)ret_copy;
6027         return ret_ref;
6028 }
6029
6030 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6031         return RawInvoice_clone(&owner->a);
6032 }
6033 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t owner) {
6034         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6035         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
6036         uint32_t ret_ref = 0;
6037         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6038         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6040         ret_ref = (uintptr_t)ret_var.inner;
6041         if (ret_var.is_owned) {
6042                 ret_ref |= 1;
6043         }
6044         return ret_ref;
6045 }
6046
6047 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6048         return ThirtyTwoBytes_clone(&owner->b);
6049 }
6050 int8_tArray  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t owner) {
6051         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6052         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6053         memcpy(ret_arr->elems, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data, 32);
6054         return ret_arr;
6055 }
6056
6057 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6058         return InvoiceSignature_clone(&owner->c);
6059 }
6060 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t owner) {
6061         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6062         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
6063         uint32_t ret_ref = 0;
6064         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6065         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6067         ret_ref = (uintptr_t)ret_var.inner;
6068         if (ret_var.is_owned) {
6069                 ret_ref |= 1;
6070         }
6071         return ret_ref;
6072 }
6073
6074 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6075 CHECK(owner->result_ok);
6076         return PayeePubKey_clone(&*owner->contents.result);
6077 }
6078 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_ok"))) TS_CResult_PayeePubKeyErrorZ_get_ok(uint32_t owner) {
6079         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6080         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
6081         uint32_t ret_ref = 0;
6082         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6083         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6085         ret_ref = (uintptr_t)ret_var.inner;
6086         if (ret_var.is_owned) {
6087                 ret_ref |= 1;
6088         }
6089         return ret_ref;
6090 }
6091
6092 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6093 CHECK(!owner->result_ok);
6094         return *owner->contents.err;
6095 }
6096 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_err"))) TS_CResult_PayeePubKeyErrorZ_get_err(uint32_t owner) {
6097         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6098         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PayeePubKeyErrorZ_get_err(owner_conv));
6099         return ret_conv;
6100 }
6101
6102 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
6103         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
6104         for (size_t i = 0; i < ret.datalen; i++) {
6105                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
6106         }
6107         return ret;
6108 }
6109 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6110 CHECK(owner->result_ok);
6111         return PositiveTimestamp_clone(&*owner->contents.result);
6112 }
6113 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t owner) {
6114         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6115         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
6116         uint32_t ret_ref = 0;
6117         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6118         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6120         ret_ref = (uintptr_t)ret_var.inner;
6121         if (ret_var.is_owned) {
6122                 ret_ref |= 1;
6123         }
6124         return ret_ref;
6125 }
6126
6127 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6128 CHECK(!owner->result_ok);
6129         return CreationError_clone(&*owner->contents.err);
6130 }
6131 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_err"))) TS_CResult_PositiveTimestampCreationErrorZ_get_err(uint32_t owner) {
6132         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6133         uint32_t ret_conv = LDKCreationError_to_js(CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
6134         return ret_conv;
6135 }
6136
6137 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6138 CHECK(owner->result_ok);
6139         return *owner->contents.result;
6140 }
6141 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_ok"))) TS_CResult_NoneSemanticErrorZ_get_ok(uint32_t owner) {
6142         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6143         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
6144 }
6145
6146 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6147 CHECK(!owner->result_ok);
6148         return SemanticError_clone(&*owner->contents.err);
6149 }
6150 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_err"))) TS_CResult_NoneSemanticErrorZ_get_err(uint32_t owner) {
6151         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6152         uint32_t ret_conv = LDKSemanticError_to_js(CResult_NoneSemanticErrorZ_get_err(owner_conv));
6153         return ret_conv;
6154 }
6155
6156 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6157 CHECK(owner->result_ok);
6158         return Invoice_clone(&*owner->contents.result);
6159 }
6160 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_ok"))) TS_CResult_InvoiceSemanticErrorZ_get_ok(uint32_t owner) {
6161         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6162         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
6163         uint32_t ret_ref = 0;
6164         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6165         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6167         ret_ref = (uintptr_t)ret_var.inner;
6168         if (ret_var.is_owned) {
6169                 ret_ref |= 1;
6170         }
6171         return ret_ref;
6172 }
6173
6174 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6175 CHECK(!owner->result_ok);
6176         return SemanticError_clone(&*owner->contents.err);
6177 }
6178 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_err"))) TS_CResult_InvoiceSemanticErrorZ_get_err(uint32_t owner) {
6179         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6180         uint32_t ret_conv = LDKSemanticError_to_js(CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
6181         return ret_conv;
6182 }
6183
6184 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6185 CHECK(owner->result_ok);
6186         return Description_clone(&*owner->contents.result);
6187 }
6188 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_ok"))) TS_CResult_DescriptionCreationErrorZ_get_ok(uint32_t owner) {
6189         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6190         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
6191         uint32_t ret_ref = 0;
6192         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6193         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6195         ret_ref = (uintptr_t)ret_var.inner;
6196         if (ret_var.is_owned) {
6197                 ret_ref |= 1;
6198         }
6199         return ret_ref;
6200 }
6201
6202 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6203 CHECK(!owner->result_ok);
6204         return CreationError_clone(&*owner->contents.err);
6205 }
6206 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_err"))) TS_CResult_DescriptionCreationErrorZ_get_err(uint32_t owner) {
6207         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6208         uint32_t ret_conv = LDKCreationError_to_js(CResult_DescriptionCreationErrorZ_get_err(owner_conv));
6209         return ret_conv;
6210 }
6211
6212 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6213 CHECK(owner->result_ok);
6214         return PrivateRoute_clone(&*owner->contents.result);
6215 }
6216 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_ok"))) TS_CResult_PrivateRouteCreationErrorZ_get_ok(uint32_t owner) {
6217         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6218         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
6219         uint32_t ret_ref = 0;
6220         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6221         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6222         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6223         ret_ref = (uintptr_t)ret_var.inner;
6224         if (ret_var.is_owned) {
6225                 ret_ref |= 1;
6226         }
6227         return ret_ref;
6228 }
6229
6230 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6231 CHECK(!owner->result_ok);
6232         return CreationError_clone(&*owner->contents.err);
6233 }
6234 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_err"))) TS_CResult_PrivateRouteCreationErrorZ_get_err(uint32_t owner) {
6235         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6236         uint32_t ret_conv = LDKCreationError_to_js(CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
6237         return ret_conv;
6238 }
6239
6240 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6241 CHECK(owner->result_ok);
6242         return *owner->contents.result;
6243 }
6244 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
6245         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
6246         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
6247         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6248         return ret_conv;
6249 }
6250
6251 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6252 CHECK(!owner->result_ok);
6253         return *owner->contents.err;
6254 }
6255 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
6256         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
6257         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
6258         return ret_conv;
6259 }
6260
6261 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6262 CHECK(owner->result_ok);
6263         return ChannelMonitorUpdate_clone(&*owner->contents.result);
6264 }
6265 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
6266         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
6267         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
6268         uint32_t ret_ref = 0;
6269         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6270         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6272         ret_ref = (uintptr_t)ret_var.inner;
6273         if (ret_var.is_owned) {
6274                 ret_ref |= 1;
6275         }
6276         return ret_ref;
6277 }
6278
6279 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6280 CHECK(!owner->result_ok);
6281         return DecodeError_clone(&*owner->contents.err);
6282 }
6283 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
6284         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
6285         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
6286         uint32_t ret_ref = 0;
6287         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6288         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6290         ret_ref = (uintptr_t)ret_var.inner;
6291         if (ret_var.is_owned) {
6292                 ret_ref |= 1;
6293         }
6294         return ret_ref;
6295 }
6296
6297 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint32_t ptr) {
6298         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
6299         switch(obj->tag) {
6300                 case LDKCOption_MonitorEventZ_Some: return 0;
6301                 case LDKCOption_MonitorEventZ_None: return 1;
6302                 default: abort();
6303         }
6304 }
6305 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint32_t ptr) {
6306         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
6307         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
6308                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
6309         return some_ref;
6310 }
6311 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
6312 CHECK(owner->result_ok);
6313         return COption_MonitorEventZ_clone(&*owner->contents.result);
6314 }
6315 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
6316         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
6317         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
6318         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
6319         uint32_t ret_ref = (uintptr_t)ret_copy;
6320         return ret_ref;
6321 }
6322
6323 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
6324 CHECK(!owner->result_ok);
6325         return DecodeError_clone(&*owner->contents.err);
6326 }
6327 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
6328         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
6329         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
6330         uint32_t ret_ref = 0;
6331         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6332         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6334         ret_ref = (uintptr_t)ret_var.inner;
6335         if (ret_var.is_owned) {
6336                 ret_ref |= 1;
6337         }
6338         return ret_ref;
6339 }
6340
6341 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
6342 CHECK(owner->result_ok);
6343         return HTLCUpdate_clone(&*owner->contents.result);
6344 }
6345 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
6346         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
6347         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
6348         uint32_t ret_ref = 0;
6349         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6350         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6352         ret_ref = (uintptr_t)ret_var.inner;
6353         if (ret_var.is_owned) {
6354                 ret_ref |= 1;
6355         }
6356         return ret_ref;
6357 }
6358
6359 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
6360 CHECK(!owner->result_ok);
6361         return DecodeError_clone(&*owner->contents.err);
6362 }
6363 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
6364         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
6365         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
6366         uint32_t ret_ref = 0;
6367         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6368         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6370         ret_ref = (uintptr_t)ret_var.inner;
6371         if (ret_var.is_owned) {
6372                 ret_ref |= 1;
6373         }
6374         return ret_ref;
6375 }
6376
6377 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
6378         return OutPoint_clone(&owner->a);
6379 }
6380 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
6381         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
6382         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
6383         uint32_t ret_ref = 0;
6384         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6385         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6387         ret_ref = (uintptr_t)ret_var.inner;
6388         if (ret_var.is_owned) {
6389                 ret_ref |= 1;
6390         }
6391         return ret_ref;
6392 }
6393
6394 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
6395         return CVec_u8Z_clone(&owner->b);
6396 }
6397 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
6398         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
6399         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
6400         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6401         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6402         CVec_u8Z_free(ret_var);
6403         return ret_arr;
6404 }
6405
6406 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
6407         return owner->a;
6408 }
6409 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
6410         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
6411         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
6412         return ret_conv;
6413 }
6414
6415 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
6416         return CVec_u8Z_clone(&owner->b);
6417 }
6418 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
6419         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
6420         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
6421         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6422         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6423         CVec_u8Z_free(ret_var);
6424         return ret_arr;
6425 }
6426
6427 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
6428         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
6429         for (size_t i = 0; i < ret.datalen; i++) {
6430                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
6431         }
6432         return ret;
6433 }
6434 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
6435         return ThirtyTwoBytes_clone(&owner->a);
6436 }
6437 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
6438         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
6439         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6440         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
6441         return ret_arr;
6442 }
6443
6444 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
6445         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
6446 }
6447 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
6448         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
6449         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
6450         uint32_tArray ret_arr = NULL;
6451         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
6452         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
6453         for (size_t v = 0; v < ret_var.datalen; v++) {
6454                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
6455                 *ret_conv_21_conv = ret_var.data[v];
6456                 ret_arr_ptr[v] = ((uint32_t)ret_conv_21_conv);
6457         }
6458         
6459         FREE(ret_var.data);
6460         return ret_arr;
6461 }
6462
6463 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
6464         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 };
6465         for (size_t i = 0; i < ret.datalen; i++) {
6466                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
6467         }
6468         return ret;
6469 }
6470 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
6471         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
6472         for (size_t i = 0; i < ret.datalen; i++) {
6473                 ret.data[i] = Event_clone(&orig->data[i]);
6474         }
6475         return ret;
6476 }
6477 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
6478         return owner->a;
6479 }
6480 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
6481         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
6482         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
6483         return ret_conv;
6484 }
6485
6486 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
6487         return TxOut_clone(&owner->b);
6488 }
6489 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
6490         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
6491         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6492         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
6493         return (uint32_t)ret_ref;
6494 }
6495
6496 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
6497         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
6498         for (size_t i = 0; i < ret.datalen; i++) {
6499                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
6500         }
6501         return ret;
6502 }
6503 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
6504         return ThirtyTwoBytes_clone(&owner->a);
6505 }
6506 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
6507         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
6508         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6509         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
6510         return ret_arr;
6511 }
6512
6513 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
6514         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
6515 }
6516 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
6517         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
6518         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
6519         uint32_tArray ret_arr = NULL;
6520         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
6521         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
6522         for (size_t u = 0; u < ret_var.datalen; u++) {
6523                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
6524                 *ret_conv_20_conv = ret_var.data[u];
6525                 ret_arr_ptr[u] = ((uint32_t)ret_conv_20_conv);
6526         }
6527         
6528         FREE(ret_var.data);
6529         return ret_arr;
6530 }
6531
6532 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
6533         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 };
6534         for (size_t i = 0; i < ret.datalen; i++) {
6535                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
6536         }
6537         return ret;
6538 }
6539 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint32_t ptr) {
6540         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6541         switch(obj->tag) {
6542                 case LDKBalance_ClaimableOnChannelClose: return 0;
6543                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
6544                 case LDKBalance_ContentiousClaimable: return 2;
6545                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: return 3;
6546                 default: abort();
6547         }
6548 }
6549 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint32_t ptr) {
6550         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6551         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
6552                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
6553         return claimable_amount_satoshis_conv;
6554 }
6555 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint32_t ptr) {
6556         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6557         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
6558                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
6559         return claimable_amount_satoshis_conv;
6560 }
6561 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint32_t ptr) {
6562         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6563         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
6564                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
6565         return confirmation_height_conv;
6566 }
6567 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint32_t ptr) {
6568         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6569         assert(obj->tag == LDKBalance_ContentiousClaimable);
6570                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
6571         return claimable_amount_satoshis_conv;
6572 }
6573 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint32_t ptr) {
6574         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6575         assert(obj->tag == LDKBalance_ContentiousClaimable);
6576                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
6577         return timeout_height_conv;
6578 }
6579 int64_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(uint32_t ptr) {
6580         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6581         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
6582                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
6583         return claimable_amount_satoshis_conv;
6584 }
6585 int32_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(uint32_t ptr) {
6586         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6587         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
6588                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
6589         return claimable_height_conv;
6590 }
6591 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
6592         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
6593         for (size_t i = 0; i < ret.datalen; i++) {
6594                 ret.data[i] = Balance_clone(&orig->data[i]);
6595         }
6596         return ret;
6597 }
6598 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6599         return ThirtyTwoBytes_clone(&owner->a);
6600 }
6601 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
6602         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
6603         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6604         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
6605         return ret_arr;
6606 }
6607
6608 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6609         return ChannelMonitor_clone(&owner->b);
6610 }
6611 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
6612         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
6613         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
6614         uint32_t ret_ref = 0;
6615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6618         ret_ref = (uintptr_t)ret_var.inner;
6619         if (ret_var.is_owned) {
6620                 ret_ref |= 1;
6621         }
6622         return ret_ref;
6623 }
6624
6625 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
6626 CHECK(owner->result_ok);
6627         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
6628 }
6629 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
6630         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
6631         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6632         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
6633         return ((uint32_t)ret_conv);
6634 }
6635
6636 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
6637 CHECK(!owner->result_ok);
6638         return DecodeError_clone(&*owner->contents.err);
6639 }
6640 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
6641         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
6642         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
6643         uint32_t ret_ref = 0;
6644         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6645         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6647         ret_ref = (uintptr_t)ret_var.inner;
6648         if (ret_var.is_owned) {
6649                 ret_ref |= 1;
6650         }
6651         return ret_ref;
6652 }
6653
6654 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6655         return owner->a;
6656 }
6657 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
6658         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
6659         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
6660         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
6661         return ret_arr;
6662 }
6663
6664 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6665         return Type_clone(&owner->b);
6666 }
6667 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
6668         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
6669         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
6670         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
6671         return (uint32_t)ret_ret;
6672 }
6673
6674 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
6675         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
6676         for (size_t i = 0; i < ret.datalen; i++) {
6677                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
6678         }
6679         return ret;
6680 }
6681 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_ty_from_ptr"))) TS_LDKCOption_NetAddressZ_ty_from_ptr(uint32_t ptr) {
6682         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6683         switch(obj->tag) {
6684                 case LDKCOption_NetAddressZ_Some: return 0;
6685                 case LDKCOption_NetAddressZ_None: return 1;
6686                 default: abort();
6687         }
6688 }
6689 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_Some_get_some"))) TS_LDKCOption_NetAddressZ_Some_get_some(uint32_t ptr) {
6690         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6691         assert(obj->tag == LDKCOption_NetAddressZ_Some);
6692                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
6693         return some_ref;
6694 }
6695 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6696 CHECK(owner->result_ok);
6697         return CVec_u8Z_clone(&*owner->contents.result);
6698 }
6699 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t owner) {
6700         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6701         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
6702         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6703         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6704         CVec_u8Z_free(ret_var);
6705         return ret_arr;
6706 }
6707
6708 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6709 CHECK(!owner->result_ok);
6710         return PeerHandleError_clone(&*owner->contents.err);
6711 }
6712 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t owner) {
6713         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6714         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
6715         uint32_t ret_ref = 0;
6716         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6717         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6719         ret_ref = (uintptr_t)ret_var.inner;
6720         if (ret_var.is_owned) {
6721                 ret_ref |= 1;
6722         }
6723         return ret_ref;
6724 }
6725
6726 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6727 CHECK(owner->result_ok);
6728         return *owner->contents.result;
6729 }
6730 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint32_t owner) {
6731         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6732         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
6733 }
6734
6735 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6736 CHECK(!owner->result_ok);
6737         return PeerHandleError_clone(&*owner->contents.err);
6738 }
6739 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint32_t owner) {
6740         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6741         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
6742         uint32_t ret_ref = 0;
6743         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6744         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6746         ret_ref = (uintptr_t)ret_var.inner;
6747         if (ret_var.is_owned) {
6748                 ret_ref |= 1;
6749         }
6750         return ret_ref;
6751 }
6752
6753 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6754 CHECK(owner->result_ok);
6755         return *owner->contents.result;
6756 }
6757 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint32_t owner) {
6758         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6759         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
6760         return ret_conv;
6761 }
6762
6763 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6764 CHECK(!owner->result_ok);
6765         return PeerHandleError_clone(&*owner->contents.err);
6766 }
6767 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint32_t owner) {
6768         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6769         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
6770         uint32_t ret_ref = 0;
6771         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6772         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6774         ret_ref = (uintptr_t)ret_var.inner;
6775         if (ret_var.is_owned) {
6776                 ret_ref |= 1;
6777         }
6778         return ret_ref;
6779 }
6780
6781 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
6782 CHECK(owner->result_ok);
6783         return *owner->contents.result;
6784 }
6785 void  __attribute__((export_name("TS_CResult_NoneErrorZ_get_ok"))) TS_CResult_NoneErrorZ_get_ok(uint32_t owner) {
6786         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
6787         CResult_NoneErrorZ_get_ok(owner_conv);
6788 }
6789
6790 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
6791 CHECK(!owner->result_ok);
6792         return *owner->contents.err;
6793 }
6794 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_get_err"))) TS_CResult_NoneErrorZ_get_err(uint32_t owner) {
6795         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
6796         uint32_t ret_conv = LDKIOError_to_js(CResult_NoneErrorZ_get_err(owner_conv));
6797         return ret_conv;
6798 }
6799
6800 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6801 CHECK(owner->result_ok);
6802         return NetAddress_clone(&*owner->contents.result);
6803 }
6804 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint32_t owner) {
6805         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6806         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
6807         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
6808         uint32_t ret_ref = (uintptr_t)ret_copy;
6809         return ret_ref;
6810 }
6811
6812 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6813 CHECK(!owner->result_ok);
6814         return DecodeError_clone(&*owner->contents.err);
6815 }
6816 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint32_t owner) {
6817         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6818         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
6819         uint32_t ret_ref = 0;
6820         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6821         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6823         ret_ref = (uintptr_t)ret_var.inner;
6824         if (ret_var.is_owned) {
6825                 ret_ref |= 1;
6826         }
6827         return ret_ref;
6828 }
6829
6830 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6831         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6832         for (size_t i = 0; i < ret.datalen; i++) {
6833                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6834         }
6835         return ret;
6836 }
6837 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6838         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6839         for (size_t i = 0; i < ret.datalen; i++) {
6840                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6841         }
6842         return ret;
6843 }
6844 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6845         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6846         for (size_t i = 0; i < ret.datalen; i++) {
6847                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6848         }
6849         return ret;
6850 }
6851 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6852         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6853         for (size_t i = 0; i < ret.datalen; i++) {
6854                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6855         }
6856         return ret;
6857 }
6858 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6859 CHECK(owner->result_ok);
6860         return AcceptChannel_clone(&*owner->contents.result);
6861 }
6862 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t owner) {
6863         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6864         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
6865         uint32_t ret_ref = 0;
6866         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6867         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6869         ret_ref = (uintptr_t)ret_var.inner;
6870         if (ret_var.is_owned) {
6871                 ret_ref |= 1;
6872         }
6873         return ret_ref;
6874 }
6875
6876 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6877 CHECK(!owner->result_ok);
6878         return DecodeError_clone(&*owner->contents.err);
6879 }
6880 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint32_t owner) {
6881         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6882         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
6883         uint32_t ret_ref = 0;
6884         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6885         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6887         ret_ref = (uintptr_t)ret_var.inner;
6888         if (ret_var.is_owned) {
6889                 ret_ref |= 1;
6890         }
6891         return ret_ref;
6892 }
6893
6894 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6895 CHECK(owner->result_ok);
6896         return AnnouncementSignatures_clone(&*owner->contents.result);
6897 }
6898 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t owner) {
6899         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6900         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
6901         uint32_t ret_ref = 0;
6902         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6903         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6905         ret_ref = (uintptr_t)ret_var.inner;
6906         if (ret_var.is_owned) {
6907                 ret_ref |= 1;
6908         }
6909         return ret_ref;
6910 }
6911
6912 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6913 CHECK(!owner->result_ok);
6914         return DecodeError_clone(&*owner->contents.err);
6915 }
6916 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t owner) {
6917         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6918         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
6919         uint32_t ret_ref = 0;
6920         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6921         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6922         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6923         ret_ref = (uintptr_t)ret_var.inner;
6924         if (ret_var.is_owned) {
6925                 ret_ref |= 1;
6926         }
6927         return ret_ref;
6928 }
6929
6930 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6931 CHECK(owner->result_ok);
6932         return ChannelReestablish_clone(&*owner->contents.result);
6933 }
6934 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t owner) {
6935         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6936         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
6937         uint32_t ret_ref = 0;
6938         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6939         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6941         ret_ref = (uintptr_t)ret_var.inner;
6942         if (ret_var.is_owned) {
6943                 ret_ref |= 1;
6944         }
6945         return ret_ref;
6946 }
6947
6948 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6949 CHECK(!owner->result_ok);
6950         return DecodeError_clone(&*owner->contents.err);
6951 }
6952 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t owner) {
6953         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6954         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
6955         uint32_t ret_ref = 0;
6956         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6957         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6959         ret_ref = (uintptr_t)ret_var.inner;
6960         if (ret_var.is_owned) {
6961                 ret_ref |= 1;
6962         }
6963         return ret_ref;
6964 }
6965
6966 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6967 CHECK(owner->result_ok);
6968         return ClosingSigned_clone(&*owner->contents.result);
6969 }
6970 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6971         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6972         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
6973         uint32_t ret_ref = 0;
6974         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6975         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6976         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6977         ret_ref = (uintptr_t)ret_var.inner;
6978         if (ret_var.is_owned) {
6979                 ret_ref |= 1;
6980         }
6981         return ret_ref;
6982 }
6983
6984 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6985 CHECK(!owner->result_ok);
6986         return DecodeError_clone(&*owner->contents.err);
6987 }
6988 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint32_t owner) {
6989         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6990         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
6991         uint32_t ret_ref = 0;
6992         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6993         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6995         ret_ref = (uintptr_t)ret_var.inner;
6996         if (ret_var.is_owned) {
6997                 ret_ref |= 1;
6998         }
6999         return ret_ref;
7000 }
7001
7002 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
7003 CHECK(owner->result_ok);
7004         return ClosingSignedFeeRange_clone(&*owner->contents.result);
7005 }
7006 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t owner) {
7007         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
7008         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
7009         uint32_t ret_ref = 0;
7010         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7011         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7013         ret_ref = (uintptr_t)ret_var.inner;
7014         if (ret_var.is_owned) {
7015                 ret_ref |= 1;
7016         }
7017         return ret_ref;
7018 }
7019
7020 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
7021 CHECK(!owner->result_ok);
7022         return DecodeError_clone(&*owner->contents.err);
7023 }
7024 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t owner) {
7025         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
7026         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
7027         uint32_t ret_ref = 0;
7028         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7029         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7031         ret_ref = (uintptr_t)ret_var.inner;
7032         if (ret_var.is_owned) {
7033                 ret_ref |= 1;
7034         }
7035         return ret_ref;
7036 }
7037
7038 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
7039 CHECK(owner->result_ok);
7040         return CommitmentSigned_clone(&*owner->contents.result);
7041 }
7042 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t owner) {
7043         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
7044         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
7045         uint32_t ret_ref = 0;
7046         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7047         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7049         ret_ref = (uintptr_t)ret_var.inner;
7050         if (ret_var.is_owned) {
7051                 ret_ref |= 1;
7052         }
7053         return ret_ref;
7054 }
7055
7056 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
7057 CHECK(!owner->result_ok);
7058         return DecodeError_clone(&*owner->contents.err);
7059 }
7060 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t owner) {
7061         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
7062         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
7063         uint32_t ret_ref = 0;
7064         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7065         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7067         ret_ref = (uintptr_t)ret_var.inner;
7068         if (ret_var.is_owned) {
7069                 ret_ref |= 1;
7070         }
7071         return ret_ref;
7072 }
7073
7074 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
7075 CHECK(owner->result_ok);
7076         return FundingCreated_clone(&*owner->contents.result);
7077 }
7078 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t owner) {
7079         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
7080         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
7081         uint32_t ret_ref = 0;
7082         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7083         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7085         ret_ref = (uintptr_t)ret_var.inner;
7086         if (ret_var.is_owned) {
7087                 ret_ref |= 1;
7088         }
7089         return ret_ref;
7090 }
7091
7092 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
7093 CHECK(!owner->result_ok);
7094         return DecodeError_clone(&*owner->contents.err);
7095 }
7096 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint32_t owner) {
7097         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
7098         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
7099         uint32_t ret_ref = 0;
7100         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7101         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7103         ret_ref = (uintptr_t)ret_var.inner;
7104         if (ret_var.is_owned) {
7105                 ret_ref |= 1;
7106         }
7107         return ret_ref;
7108 }
7109
7110 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
7111 CHECK(owner->result_ok);
7112         return FundingSigned_clone(&*owner->contents.result);
7113 }
7114 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint32_t owner) {
7115         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
7116         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
7117         uint32_t ret_ref = 0;
7118         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7119         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7121         ret_ref = (uintptr_t)ret_var.inner;
7122         if (ret_var.is_owned) {
7123                 ret_ref |= 1;
7124         }
7125         return ret_ref;
7126 }
7127
7128 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
7129 CHECK(!owner->result_ok);
7130         return DecodeError_clone(&*owner->contents.err);
7131 }
7132 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint32_t owner) {
7133         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
7134         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
7135         uint32_t ret_ref = 0;
7136         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7137         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7139         ret_ref = (uintptr_t)ret_var.inner;
7140         if (ret_var.is_owned) {
7141                 ret_ref |= 1;
7142         }
7143         return ret_ref;
7144 }
7145
7146 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
7147 CHECK(owner->result_ok);
7148         return ChannelReady_clone(&*owner->contents.result);
7149 }
7150 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_get_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_get_ok(uint32_t owner) {
7151         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
7152         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
7153         uint32_t ret_ref = 0;
7154         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7155         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7157         ret_ref = (uintptr_t)ret_var.inner;
7158         if (ret_var.is_owned) {
7159                 ret_ref |= 1;
7160         }
7161         return ret_ref;
7162 }
7163
7164 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
7165 CHECK(!owner->result_ok);
7166         return DecodeError_clone(&*owner->contents.err);
7167 }
7168 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_get_err"))) TS_CResult_ChannelReadyDecodeErrorZ_get_err(uint32_t owner) {
7169         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
7170         LDKDecodeError ret_var = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
7171         uint32_t ret_ref = 0;
7172         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7173         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7175         ret_ref = (uintptr_t)ret_var.inner;
7176         if (ret_var.is_owned) {
7177                 ret_ref |= 1;
7178         }
7179         return ret_ref;
7180 }
7181
7182 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
7183 CHECK(owner->result_ok);
7184         return Init_clone(&*owner->contents.result);
7185 }
7186 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint32_t owner) {
7187         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
7188         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
7189         uint32_t ret_ref = 0;
7190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7193         ret_ref = (uintptr_t)ret_var.inner;
7194         if (ret_var.is_owned) {
7195                 ret_ref |= 1;
7196         }
7197         return ret_ref;
7198 }
7199
7200 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
7201 CHECK(!owner->result_ok);
7202         return DecodeError_clone(&*owner->contents.err);
7203 }
7204 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint32_t owner) {
7205         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
7206         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
7207         uint32_t ret_ref = 0;
7208         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7209         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7211         ret_ref = (uintptr_t)ret_var.inner;
7212         if (ret_var.is_owned) {
7213                 ret_ref |= 1;
7214         }
7215         return ret_ref;
7216 }
7217
7218 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7219 CHECK(owner->result_ok);
7220         return OpenChannel_clone(&*owner->contents.result);
7221 }
7222 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint32_t owner) {
7223         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
7224         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
7225         uint32_t ret_ref = 0;
7226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7229         ret_ref = (uintptr_t)ret_var.inner;
7230         if (ret_var.is_owned) {
7231                 ret_ref |= 1;
7232         }
7233         return ret_ref;
7234 }
7235
7236 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7237 CHECK(!owner->result_ok);
7238         return DecodeError_clone(&*owner->contents.err);
7239 }
7240 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint32_t owner) {
7241         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
7242         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
7243         uint32_t ret_ref = 0;
7244         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7245         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7247         ret_ref = (uintptr_t)ret_var.inner;
7248         if (ret_var.is_owned) {
7249                 ret_ref |= 1;
7250         }
7251         return ret_ref;
7252 }
7253
7254 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7255 CHECK(owner->result_ok);
7256         return RevokeAndACK_clone(&*owner->contents.result);
7257 }
7258 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t owner) {
7259         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7260         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
7261         uint32_t ret_ref = 0;
7262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7265         ret_ref = (uintptr_t)ret_var.inner;
7266         if (ret_var.is_owned) {
7267                 ret_ref |= 1;
7268         }
7269         return ret_ref;
7270 }
7271
7272 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7273 CHECK(!owner->result_ok);
7274         return DecodeError_clone(&*owner->contents.err);
7275 }
7276 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t owner) {
7277         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7278         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
7279         uint32_t ret_ref = 0;
7280         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7281         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7283         ret_ref = (uintptr_t)ret_var.inner;
7284         if (ret_var.is_owned) {
7285                 ret_ref |= 1;
7286         }
7287         return ret_ref;
7288 }
7289
7290 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7291 CHECK(owner->result_ok);
7292         return Shutdown_clone(&*owner->contents.result);
7293 }
7294 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint32_t owner) {
7295         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7296         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
7297         uint32_t ret_ref = 0;
7298         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7299         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7300         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7301         ret_ref = (uintptr_t)ret_var.inner;
7302         if (ret_var.is_owned) {
7303                 ret_ref |= 1;
7304         }
7305         return ret_ref;
7306 }
7307
7308 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7309 CHECK(!owner->result_ok);
7310         return DecodeError_clone(&*owner->contents.err);
7311 }
7312 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint32_t owner) {
7313         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7314         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
7315         uint32_t ret_ref = 0;
7316         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7317         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7319         ret_ref = (uintptr_t)ret_var.inner;
7320         if (ret_var.is_owned) {
7321                 ret_ref |= 1;
7322         }
7323         return ret_ref;
7324 }
7325
7326 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7327 CHECK(owner->result_ok);
7328         return UpdateFailHTLC_clone(&*owner->contents.result);
7329 }
7330 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7331         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7332         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
7333         uint32_t ret_ref = 0;
7334         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7335         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7337         ret_ref = (uintptr_t)ret_var.inner;
7338         if (ret_var.is_owned) {
7339                 ret_ref |= 1;
7340         }
7341         return ret_ref;
7342 }
7343
7344 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7345 CHECK(!owner->result_ok);
7346         return DecodeError_clone(&*owner->contents.err);
7347 }
7348 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t owner) {
7349         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7350         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
7351         uint32_t ret_ref = 0;
7352         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7353         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7355         ret_ref = (uintptr_t)ret_var.inner;
7356         if (ret_var.is_owned) {
7357                 ret_ref |= 1;
7358         }
7359         return ret_ref;
7360 }
7361
7362 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7363 CHECK(owner->result_ok);
7364         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
7365 }
7366 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7367         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7368         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
7369         uint32_t ret_ref = 0;
7370         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7371         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7373         ret_ref = (uintptr_t)ret_var.inner;
7374         if (ret_var.is_owned) {
7375                 ret_ref |= 1;
7376         }
7377         return ret_ref;
7378 }
7379
7380 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7381 CHECK(!owner->result_ok);
7382         return DecodeError_clone(&*owner->contents.err);
7383 }
7384 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t owner) {
7385         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7386         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
7387         uint32_t ret_ref = 0;
7388         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7389         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7391         ret_ref = (uintptr_t)ret_var.inner;
7392         if (ret_var.is_owned) {
7393                 ret_ref |= 1;
7394         }
7395         return ret_ref;
7396 }
7397
7398 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7399 CHECK(owner->result_ok);
7400         return UpdateFee_clone(&*owner->contents.result);
7401 }
7402 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t owner) {
7403         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7404         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
7405         uint32_t ret_ref = 0;
7406         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7407         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7409         ret_ref = (uintptr_t)ret_var.inner;
7410         if (ret_var.is_owned) {
7411                 ret_ref |= 1;
7412         }
7413         return ret_ref;
7414 }
7415
7416 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7417 CHECK(!owner->result_ok);
7418         return DecodeError_clone(&*owner->contents.err);
7419 }
7420 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint32_t owner) {
7421         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7422         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
7423         uint32_t ret_ref = 0;
7424         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7425         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7427         ret_ref = (uintptr_t)ret_var.inner;
7428         if (ret_var.is_owned) {
7429                 ret_ref |= 1;
7430         }
7431         return ret_ref;
7432 }
7433
7434 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7435 CHECK(owner->result_ok);
7436         return UpdateFulfillHTLC_clone(&*owner->contents.result);
7437 }
7438 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7439         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7440         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
7441         uint32_t ret_ref = 0;
7442         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7443         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7445         ret_ref = (uintptr_t)ret_var.inner;
7446         if (ret_var.is_owned) {
7447                 ret_ref |= 1;
7448         }
7449         return ret_ref;
7450 }
7451
7452 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7453 CHECK(!owner->result_ok);
7454         return DecodeError_clone(&*owner->contents.err);
7455 }
7456 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t owner) {
7457         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7458         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
7459         uint32_t ret_ref = 0;
7460         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7461         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7463         ret_ref = (uintptr_t)ret_var.inner;
7464         if (ret_var.is_owned) {
7465                 ret_ref |= 1;
7466         }
7467         return ret_ref;
7468 }
7469
7470 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7471 CHECK(owner->result_ok);
7472         return UpdateAddHTLC_clone(&*owner->contents.result);
7473 }
7474 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7475         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7476         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
7477         uint32_t ret_ref = 0;
7478         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7479         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7481         ret_ref = (uintptr_t)ret_var.inner;
7482         if (ret_var.is_owned) {
7483                 ret_ref |= 1;
7484         }
7485         return ret_ref;
7486 }
7487
7488 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7489 CHECK(!owner->result_ok);
7490         return DecodeError_clone(&*owner->contents.err);
7491 }
7492 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t owner) {
7493         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7494         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
7495         uint32_t ret_ref = 0;
7496         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7497         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7499         ret_ref = (uintptr_t)ret_var.inner;
7500         if (ret_var.is_owned) {
7501                 ret_ref |= 1;
7502         }
7503         return ret_ref;
7504 }
7505
7506 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7507 CHECK(owner->result_ok);
7508         return Ping_clone(&*owner->contents.result);
7509 }
7510 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint32_t owner) {
7511         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7512         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
7513         uint32_t ret_ref = 0;
7514         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7515         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7517         ret_ref = (uintptr_t)ret_var.inner;
7518         if (ret_var.is_owned) {
7519                 ret_ref |= 1;
7520         }
7521         return ret_ref;
7522 }
7523
7524 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7525 CHECK(!owner->result_ok);
7526         return DecodeError_clone(&*owner->contents.err);
7527 }
7528 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint32_t owner) {
7529         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7530         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
7531         uint32_t ret_ref = 0;
7532         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7533         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7535         ret_ref = (uintptr_t)ret_var.inner;
7536         if (ret_var.is_owned) {
7537                 ret_ref |= 1;
7538         }
7539         return ret_ref;
7540 }
7541
7542 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7543 CHECK(owner->result_ok);
7544         return Pong_clone(&*owner->contents.result);
7545 }
7546 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint32_t owner) {
7547         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7548         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
7549         uint32_t ret_ref = 0;
7550         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7551         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7553         ret_ref = (uintptr_t)ret_var.inner;
7554         if (ret_var.is_owned) {
7555                 ret_ref |= 1;
7556         }
7557         return ret_ref;
7558 }
7559
7560 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7561 CHECK(!owner->result_ok);
7562         return DecodeError_clone(&*owner->contents.err);
7563 }
7564 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint32_t owner) {
7565         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7566         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
7567         uint32_t ret_ref = 0;
7568         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7569         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7571         ret_ref = (uintptr_t)ret_var.inner;
7572         if (ret_var.is_owned) {
7573                 ret_ref |= 1;
7574         }
7575         return ret_ref;
7576 }
7577
7578 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7579 CHECK(owner->result_ok);
7580         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
7581 }
7582 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7583         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7584         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7585         uint32_t ret_ref = 0;
7586         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7587         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7589         ret_ref = (uintptr_t)ret_var.inner;
7590         if (ret_var.is_owned) {
7591                 ret_ref |= 1;
7592         }
7593         return ret_ref;
7594 }
7595
7596 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7597 CHECK(!owner->result_ok);
7598         return DecodeError_clone(&*owner->contents.err);
7599 }
7600 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7601         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7602         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7603         uint32_t ret_ref = 0;
7604         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7605         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7607         ret_ref = (uintptr_t)ret_var.inner;
7608         if (ret_var.is_owned) {
7609                 ret_ref |= 1;
7610         }
7611         return ret_ref;
7612 }
7613
7614 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7615 CHECK(owner->result_ok);
7616         return ChannelAnnouncement_clone(&*owner->contents.result);
7617 }
7618 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7619         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7620         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7621         uint32_t ret_ref = 0;
7622         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7623         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7625         ret_ref = (uintptr_t)ret_var.inner;
7626         if (ret_var.is_owned) {
7627                 ret_ref |= 1;
7628         }
7629         return ret_ref;
7630 }
7631
7632 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7633 CHECK(!owner->result_ok);
7634         return DecodeError_clone(&*owner->contents.err);
7635 }
7636 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7637         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7638         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7639         uint32_t ret_ref = 0;
7640         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7641         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7643         ret_ref = (uintptr_t)ret_var.inner;
7644         if (ret_var.is_owned) {
7645                 ret_ref |= 1;
7646         }
7647         return ret_ref;
7648 }
7649
7650 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7651 CHECK(owner->result_ok);
7652         return UnsignedChannelUpdate_clone(&*owner->contents.result);
7653 }
7654 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7655         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7656         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7657         uint32_t ret_ref = 0;
7658         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7659         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7661         ret_ref = (uintptr_t)ret_var.inner;
7662         if (ret_var.is_owned) {
7663                 ret_ref |= 1;
7664         }
7665         return ret_ref;
7666 }
7667
7668 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7669 CHECK(!owner->result_ok);
7670         return DecodeError_clone(&*owner->contents.err);
7671 }
7672 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7673         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7674         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
7675         uint32_t ret_ref = 0;
7676         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7677         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7679         ret_ref = (uintptr_t)ret_var.inner;
7680         if (ret_var.is_owned) {
7681                 ret_ref |= 1;
7682         }
7683         return ret_ref;
7684 }
7685
7686 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7687 CHECK(owner->result_ok);
7688         return ChannelUpdate_clone(&*owner->contents.result);
7689 }
7690 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7691         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7692         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7693         uint32_t ret_ref = 0;
7694         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7695         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7697         ret_ref = (uintptr_t)ret_var.inner;
7698         if (ret_var.is_owned) {
7699                 ret_ref |= 1;
7700         }
7701         return ret_ref;
7702 }
7703
7704 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7705 CHECK(!owner->result_ok);
7706         return DecodeError_clone(&*owner->contents.err);
7707 }
7708 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7709         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7710         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
7711         uint32_t ret_ref = 0;
7712         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7713         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7715         ret_ref = (uintptr_t)ret_var.inner;
7716         if (ret_var.is_owned) {
7717                 ret_ref |= 1;
7718         }
7719         return ret_ref;
7720 }
7721
7722 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7723 CHECK(owner->result_ok);
7724         return ErrorMessage_clone(&*owner->contents.result);
7725 }
7726 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t owner) {
7727         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7728         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
7729         uint32_t ret_ref = 0;
7730         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7731         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7733         ret_ref = (uintptr_t)ret_var.inner;
7734         if (ret_var.is_owned) {
7735                 ret_ref |= 1;
7736         }
7737         return ret_ref;
7738 }
7739
7740 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7741 CHECK(!owner->result_ok);
7742         return DecodeError_clone(&*owner->contents.err);
7743 }
7744 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint32_t owner) {
7745         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7746         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
7747         uint32_t ret_ref = 0;
7748         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7749         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7751         ret_ref = (uintptr_t)ret_var.inner;
7752         if (ret_var.is_owned) {
7753                 ret_ref |= 1;
7754         }
7755         return ret_ref;
7756 }
7757
7758 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7759 CHECK(owner->result_ok);
7760         return WarningMessage_clone(&*owner->contents.result);
7761 }
7762 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_ok"))) TS_CResult_WarningMessageDecodeErrorZ_get_ok(uint32_t owner) {
7763         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7764         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
7765         uint32_t ret_ref = 0;
7766         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7767         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7769         ret_ref = (uintptr_t)ret_var.inner;
7770         if (ret_var.is_owned) {
7771                 ret_ref |= 1;
7772         }
7773         return ret_ref;
7774 }
7775
7776 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7777 CHECK(!owner->result_ok);
7778         return DecodeError_clone(&*owner->contents.err);
7779 }
7780 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_err"))) TS_CResult_WarningMessageDecodeErrorZ_get_err(uint32_t owner) {
7781         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7782         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
7783         uint32_t ret_ref = 0;
7784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7787         ret_ref = (uintptr_t)ret_var.inner;
7788         if (ret_var.is_owned) {
7789                 ret_ref |= 1;
7790         }
7791         return ret_ref;
7792 }
7793
7794 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7795 CHECK(owner->result_ok);
7796         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
7797 }
7798 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7799         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7800         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7801         uint32_t ret_ref = 0;
7802         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7803         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7805         ret_ref = (uintptr_t)ret_var.inner;
7806         if (ret_var.is_owned) {
7807                 ret_ref |= 1;
7808         }
7809         return ret_ref;
7810 }
7811
7812 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7813 CHECK(!owner->result_ok);
7814         return DecodeError_clone(&*owner->contents.err);
7815 }
7816 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7817         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7818         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7819         uint32_t ret_ref = 0;
7820         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7821         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7823         ret_ref = (uintptr_t)ret_var.inner;
7824         if (ret_var.is_owned) {
7825                 ret_ref |= 1;
7826         }
7827         return ret_ref;
7828 }
7829
7830 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7831 CHECK(owner->result_ok);
7832         return NodeAnnouncement_clone(&*owner->contents.result);
7833 }
7834 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7835         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7836         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7837         uint32_t ret_ref = 0;
7838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7841         ret_ref = (uintptr_t)ret_var.inner;
7842         if (ret_var.is_owned) {
7843                 ret_ref |= 1;
7844         }
7845         return ret_ref;
7846 }
7847
7848 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7849 CHECK(!owner->result_ok);
7850         return DecodeError_clone(&*owner->contents.err);
7851 }
7852 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7853         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7854         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7855         uint32_t ret_ref = 0;
7856         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7857         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7859         ret_ref = (uintptr_t)ret_var.inner;
7860         if (ret_var.is_owned) {
7861                 ret_ref |= 1;
7862         }
7863         return ret_ref;
7864 }
7865
7866 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7867 CHECK(owner->result_ok);
7868         return QueryShortChannelIds_clone(&*owner->contents.result);
7869 }
7870 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t owner) {
7871         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7872         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
7873         uint32_t ret_ref = 0;
7874         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7875         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7877         ret_ref = (uintptr_t)ret_var.inner;
7878         if (ret_var.is_owned) {
7879                 ret_ref |= 1;
7880         }
7881         return ret_ref;
7882 }
7883
7884 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7885 CHECK(!owner->result_ok);
7886         return DecodeError_clone(&*owner->contents.err);
7887 }
7888 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t owner) {
7889         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7890         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
7891         uint32_t ret_ref = 0;
7892         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7893         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7895         ret_ref = (uintptr_t)ret_var.inner;
7896         if (ret_var.is_owned) {
7897                 ret_ref |= 1;
7898         }
7899         return ret_ref;
7900 }
7901
7902 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7903 CHECK(owner->result_ok);
7904         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
7905 }
7906 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t owner) {
7907         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7908         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
7909         uint32_t ret_ref = 0;
7910         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7911         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7913         ret_ref = (uintptr_t)ret_var.inner;
7914         if (ret_var.is_owned) {
7915                 ret_ref |= 1;
7916         }
7917         return ret_ref;
7918 }
7919
7920 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7921 CHECK(!owner->result_ok);
7922         return DecodeError_clone(&*owner->contents.err);
7923 }
7924 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t owner) {
7925         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7926         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
7927         uint32_t ret_ref = 0;
7928         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7929         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7931         ret_ref = (uintptr_t)ret_var.inner;
7932         if (ret_var.is_owned) {
7933                 ret_ref |= 1;
7934         }
7935         return ret_ref;
7936 }
7937
7938 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7939 CHECK(owner->result_ok);
7940         return QueryChannelRange_clone(&*owner->contents.result);
7941 }
7942 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7943         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7944         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
7945         uint32_t ret_ref = 0;
7946         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7947         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7949         ret_ref = (uintptr_t)ret_var.inner;
7950         if (ret_var.is_owned) {
7951                 ret_ref |= 1;
7952         }
7953         return ret_ref;
7954 }
7955
7956 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7957 CHECK(!owner->result_ok);
7958         return DecodeError_clone(&*owner->contents.err);
7959 }
7960 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7961         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7962         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
7963         uint32_t ret_ref = 0;
7964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7967         ret_ref = (uintptr_t)ret_var.inner;
7968         if (ret_var.is_owned) {
7969                 ret_ref |= 1;
7970         }
7971         return ret_ref;
7972 }
7973
7974 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7975 CHECK(owner->result_ok);
7976         return ReplyChannelRange_clone(&*owner->contents.result);
7977 }
7978 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7979         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7980         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
7981         uint32_t ret_ref = 0;
7982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7985         ret_ref = (uintptr_t)ret_var.inner;
7986         if (ret_var.is_owned) {
7987                 ret_ref |= 1;
7988         }
7989         return ret_ref;
7990 }
7991
7992 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7993 CHECK(!owner->result_ok);
7994         return DecodeError_clone(&*owner->contents.err);
7995 }
7996 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7997         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7998         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
7999         uint32_t ret_ref = 0;
8000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8003         ret_ref = (uintptr_t)ret_var.inner;
8004         if (ret_var.is_owned) {
8005                 ret_ref |= 1;
8006         }
8007         return ret_ref;
8008 }
8009
8010 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
8011 CHECK(owner->result_ok);
8012         return GossipTimestampFilter_clone(&*owner->contents.result);
8013 }
8014 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t owner) {
8015         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
8016         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
8017         uint32_t ret_ref = 0;
8018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8021         ret_ref = (uintptr_t)ret_var.inner;
8022         if (ret_var.is_owned) {
8023                 ret_ref |= 1;
8024         }
8025         return ret_ref;
8026 }
8027
8028 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
8029 CHECK(!owner->result_ok);
8030         return DecodeError_clone(&*owner->contents.err);
8031 }
8032 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t owner) {
8033         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
8034         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
8035         uint32_t ret_ref = 0;
8036         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8037         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8039         ret_ref = (uintptr_t)ret_var.inner;
8040         if (ret_var.is_owned) {
8041                 ret_ref |= 1;
8042         }
8043         return ret_ref;
8044 }
8045
8046 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_ty_from_ptr"))) TS_LDKSignOrCreationError_ty_from_ptr(uint32_t ptr) {
8047         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
8048         switch(obj->tag) {
8049                 case LDKSignOrCreationError_SignError: return 0;
8050                 case LDKSignOrCreationError_CreationError: return 1;
8051                 default: abort();
8052         }
8053 }
8054 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_CreationError_get_creation_error"))) TS_LDKSignOrCreationError_CreationError_get_creation_error(uint32_t ptr) {
8055         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
8056         assert(obj->tag == LDKSignOrCreationError_CreationError);
8057                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
8058         return creation_error_conv;
8059 }
8060 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
8061 CHECK(owner->result_ok);
8062         return Invoice_clone(&*owner->contents.result);
8063 }
8064 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t owner) {
8065         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
8066         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
8067         uint32_t ret_ref = 0;
8068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8071         ret_ref = (uintptr_t)ret_var.inner;
8072         if (ret_var.is_owned) {
8073                 ret_ref |= 1;
8074         }
8075         return ret_ref;
8076 }
8077
8078 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
8079 CHECK(!owner->result_ok);
8080         return SignOrCreationError_clone(&*owner->contents.err);
8081 }
8082 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t owner) {
8083         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
8084         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
8085         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
8086         uint32_t ret_ref = (uintptr_t)ret_copy;
8087         return ret_ref;
8088 }
8089
8090 typedef struct LDKFilter_JCalls {
8091         atomic_size_t refcnt;
8092         uint32_t instance_ptr;
8093 } LDKFilter_JCalls;
8094 static void LDKFilter_JCalls_free(void* this_arg) {
8095         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8096         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8097                 FREE(j_calls);
8098         }
8099 }
8100 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
8101         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8102         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8103         memcpy(txid_arr->elems, *txid, 32);
8104         LDKu8slice script_pubkey_var = script_pubkey;
8105         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
8106         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
8107         js_invoke_function_u_uu(j_calls->instance_ptr, 32, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr);
8108 }
8109 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
8110         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8111         LDKWatchedOutput output_var = output;
8112         uint32_t output_ref = 0;
8113         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8114         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8115         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
8116         output_ref = (uintptr_t)output_var.inner;
8117         if (output_var.is_owned) {
8118                 output_ref |= 1;
8119         }
8120         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 33, (uint32_t)output_ref);
8121         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8122         CHECK_ACCESS(ret_ptr);
8123         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
8124         FREE((void*)ret);
8125         return ret_conv;
8126 }
8127 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
8128         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
8129         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8130 }
8131 static inline LDKFilter LDKFilter_init (JSValue o) {
8132         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
8133         atomic_init(&calls->refcnt, 1);
8134         calls->instance_ptr = o;
8135
8136         LDKFilter ret = {
8137                 .this_arg = (void*) calls,
8138                 .register_tx = register_tx_LDKFilter_jcall,
8139                 .register_output = register_output_LDKFilter_jcall,
8140                 .free = LDKFilter_JCalls_free,
8141         };
8142         return ret;
8143 }
8144 long  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
8145         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
8146         *res_ptr = LDKFilter_init(o);
8147         return (long)res_ptr;
8148 }
8149 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
8150         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8151         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8152         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
8153         unsigned char txid_arr[32];
8154         CHECK(txid->arr_len == 32);
8155         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8156         unsigned char (*txid_ref)[32] = &txid_arr;
8157         LDKu8slice script_pubkey_ref;
8158         script_pubkey_ref.datalen = script_pubkey->arr_len;
8159         script_pubkey_ref.data = script_pubkey->elems;
8160         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
8161         FREE(script_pubkey);
8162 }
8163
8164 uint32_t  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
8165         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8166         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8167         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
8168         LDKWatchedOutput output_conv;
8169         output_conv.inner = (void*)(output & (~1));
8170         output_conv.is_owned = (output & 1) || (output == 0);
8171         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
8172         output_conv = WatchedOutput_clone(&output_conv);
8173         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8174         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
8175         uint32_t ret_ref = (uintptr_t)ret_copy;
8176         return ret_ref;
8177 }
8178
8179 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint32_t ptr) {
8180         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
8181         switch(obj->tag) {
8182                 case LDKCOption_FilterZ_Some: return 0;
8183                 case LDKCOption_FilterZ_None: return 1;
8184                 default: abort();
8185         }
8186 }
8187 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint32_t ptr) {
8188         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
8189         assert(obj->tag == LDKCOption_FilterZ_Some);
8190                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
8191                         *some_ret = obj->some;
8192                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
8193                         if ((*some_ret).free == LDKFilter_JCalls_free) {
8194                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8195                                 LDKFilter_JCalls_cloned(&(*some_ret));
8196                         }
8197         return (uint32_t)some_ret;
8198 }
8199 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
8200 CHECK(owner->result_ok);
8201         return &*owner->contents.result;
8202 }
8203 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint32_t owner) {
8204         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
8205         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
8206         uint32_t ret_ref = 0;
8207         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8208         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8210         ret_ref = (uintptr_t)ret_var.inner & ~1;
8211         return ret_ref;
8212 }
8213
8214 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
8215 CHECK(!owner->result_ok);
8216         return *owner->contents.err;
8217 }
8218 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint32_t owner) {
8219         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
8220         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
8221 }
8222
8223 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
8224         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
8225         for (size_t i = 0; i < ret.datalen; i++) {
8226                 ret.data[i] = OutPoint_clone(&orig->data[i]);
8227         }
8228         return ret;
8229 }
8230 typedef struct LDKMessageSendEventsProvider_JCalls {
8231         atomic_size_t refcnt;
8232         uint32_t instance_ptr;
8233 } LDKMessageSendEventsProvider_JCalls;
8234 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
8235         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
8236         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8237                 FREE(j_calls);
8238         }
8239 }
8240 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
8241         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
8242         uint32_tArray ret = (uint32_tArray)js_invoke_function_u_(j_calls->instance_ptr, 34);
8243         LDKCVec_MessageSendEventZ ret_constr;
8244         ret_constr.datalen = ret->arr_len;
8245         if (ret_constr.datalen > 0)
8246                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
8247         else
8248                 ret_constr.data = NULL;
8249         uint32_t* ret_vals = ret->elems;
8250         for (size_t s = 0; s < ret_constr.datalen; s++) {
8251                 uint32_t ret_conv_18 = ret_vals[s];
8252                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
8253                 CHECK_ACCESS(ret_conv_18_ptr);
8254                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
8255                 FREE((void*)ret_conv_18);
8256                 ret_constr.data[s] = ret_conv_18_conv;
8257         }
8258         FREE(ret);
8259         return ret_constr;
8260 }
8261 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
8262         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
8263         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8264 }
8265 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
8266         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
8267         atomic_init(&calls->refcnt, 1);
8268         calls->instance_ptr = o;
8269
8270         LDKMessageSendEventsProvider ret = {
8271                 .this_arg = (void*) calls,
8272                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
8273                 .free = LDKMessageSendEventsProvider_JCalls_free,
8274         };
8275         return ret;
8276 }
8277 long  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
8278         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
8279         *res_ptr = LDKMessageSendEventsProvider_init(o);
8280         return (long)res_ptr;
8281 }
8282 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) {
8283         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8284         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8285         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
8286         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
8287         uint32_tArray ret_arr = NULL;
8288         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
8289         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8290         for (size_t s = 0; s < ret_var.datalen; s++) {
8291                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
8292                 *ret_conv_18_copy = ret_var.data[s];
8293                 uint32_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
8294                 ret_arr_ptr[s] = ret_conv_18_ref;
8295         }
8296         
8297         FREE(ret_var.data);
8298         return ret_arr;
8299 }
8300
8301 typedef struct LDKEventHandler_JCalls {
8302         atomic_size_t refcnt;
8303         uint32_t instance_ptr;
8304 } LDKEventHandler_JCalls;
8305 static void LDKEventHandler_JCalls_free(void* this_arg) {
8306         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8307         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8308                 FREE(j_calls);
8309         }
8310 }
8311 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
8312         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8313         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
8314         *ret_event = Event_clone(event);
8315         js_invoke_function_u_u(j_calls->instance_ptr, 35, (uint32_t)(uint32_t)ret_event);
8316 }
8317 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
8318         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
8319         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8320 }
8321 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
8322         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
8323         atomic_init(&calls->refcnt, 1);
8324         calls->instance_ptr = o;
8325
8326         LDKEventHandler ret = {
8327                 .this_arg = (void*) calls,
8328                 .handle_event = handle_event_LDKEventHandler_jcall,
8329                 .free = LDKEventHandler_JCalls_free,
8330         };
8331         return ret;
8332 }
8333 long  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
8334         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8335         *res_ptr = LDKEventHandler_init(o);
8336         return (long)res_ptr;
8337 }
8338 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
8339         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8340         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8341         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
8342         LDKEvent* event_conv = (LDKEvent*)event;
8343         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
8344 }
8345
8346 typedef struct LDKEventsProvider_JCalls {
8347         atomic_size_t refcnt;
8348         uint32_t instance_ptr;
8349 } LDKEventsProvider_JCalls;
8350 static void LDKEventsProvider_JCalls_free(void* this_arg) {
8351         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8352         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8353                 FREE(j_calls);
8354         }
8355 }
8356 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
8357         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8358         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8359         *handler_ret = handler;
8360         js_invoke_function_u_u(j_calls->instance_ptr, 36, (uint32_t)(uint32_t)handler_ret);
8361 }
8362 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
8363         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
8364         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8365 }
8366 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
8367         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
8368         atomic_init(&calls->refcnt, 1);
8369         calls->instance_ptr = o;
8370
8371         LDKEventsProvider ret = {
8372                 .this_arg = (void*) calls,
8373                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
8374                 .free = LDKEventsProvider_JCalls_free,
8375         };
8376         return ret;
8377 }
8378 long  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
8379         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
8380         *res_ptr = LDKEventsProvider_init(o);
8381         return (long)res_ptr;
8382 }
8383 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
8384         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8385         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8386         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
8387         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
8388         CHECK_ACCESS(handler_ptr);
8389         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
8390         if (handler_conv.free == LDKEventHandler_JCalls_free) {
8391                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8392                 LDKEventHandler_JCalls_cloned(&handler_conv);
8393         }
8394         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
8395 }
8396
8397 typedef struct LDKScore_JCalls {
8398         atomic_size_t refcnt;
8399         uint32_t instance_ptr;
8400 } LDKScore_JCalls;
8401 static void LDKScore_JCalls_free(void* this_arg) {
8402         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8403         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8404                 FREE(j_calls);
8405         }
8406 }
8407 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
8408         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8409         int64_t short_channel_id_conv = short_channel_id;
8410         LDKNodeId source_var = *source;
8411         uint32_t source_ref = 0;
8412         source_var = NodeId_clone(&source_var);
8413         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8414         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8415         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
8416         source_ref = (uintptr_t)source_var.inner;
8417         if (source_var.is_owned) {
8418                 source_ref |= 1;
8419         }
8420         LDKNodeId target_var = *target;
8421         uint32_t target_ref = 0;
8422         target_var = NodeId_clone(&target_var);
8423         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8424         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8425         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
8426         target_ref = (uintptr_t)target_var.inner;
8427         if (target_var.is_owned) {
8428                 target_ref |= 1;
8429         }
8430         LDKChannelUsage usage_var = usage;
8431         uint32_t usage_ref = 0;
8432         CHECK((((uintptr_t)usage_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8433         CHECK((((uintptr_t)&usage_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8434         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
8435         usage_ref = (uintptr_t)usage_var.inner;
8436         if (usage_var.is_owned) {
8437                 usage_ref |= 1;
8438         }
8439         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);
8440 }
8441 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
8442         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8443         LDKCVec_RouteHopZ path_var = path;
8444         uint32_tArray path_arr = NULL;
8445         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8446         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
8447         for (size_t k = 0; k < path_var.datalen; k++) {
8448                 LDKRouteHop path_conv_10_var = path_var.data[k];
8449                 uint32_t path_conv_10_ref = 0;
8450                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8451                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8452                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8453                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8454                 if (path_conv_10_var.is_owned) {
8455                         path_conv_10_ref |= 1;
8456                 }
8457                 path_arr_ptr[k] = path_conv_10_ref;
8458         }
8459         
8460         FREE(path_var.data);
8461         int64_t short_channel_id_conv = short_channel_id;
8462         js_invoke_function_u_bb(j_calls->instance_ptr, 38, (uint32_t)path_arr, (uint32_t)short_channel_id_conv);
8463 }
8464 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
8465         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8466         LDKCVec_RouteHopZ path_var = path;
8467         uint32_tArray path_arr = NULL;
8468         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8469         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
8470         for (size_t k = 0; k < path_var.datalen; k++) {
8471                 LDKRouteHop path_conv_10_var = path_var.data[k];
8472                 uint32_t path_conv_10_ref = 0;
8473                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8474                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8475                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8476                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8477                 if (path_conv_10_var.is_owned) {
8478                         path_conv_10_ref |= 1;
8479                 }
8480                 path_arr_ptr[k] = path_conv_10_ref;
8481         }
8482         
8483         FREE(path_var.data);
8484         js_invoke_function_u_u(j_calls->instance_ptr, 39, (uint32_t)path_arr);
8485 }
8486 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
8487         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8488         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 40);
8489         LDKCVec_u8Z ret_ref;
8490         ret_ref.datalen = ret->arr_len;
8491         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8492         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
8493         return ret_ref;
8494 }
8495 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
8496         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
8497         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8498 }
8499 static inline LDKScore LDKScore_init (JSValue o) {
8500         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
8501         atomic_init(&calls->refcnt, 1);
8502         calls->instance_ptr = o;
8503
8504         LDKScore ret = {
8505                 .this_arg = (void*) calls,
8506                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
8507                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
8508                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
8509                 .write = write_LDKScore_jcall,
8510                 .free = LDKScore_JCalls_free,
8511         };
8512         return ret;
8513 }
8514 long  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
8515         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
8516         *res_ptr = LDKScore_init(o);
8517         return (long)res_ptr;
8518 }
8519 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) {
8520         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8521         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8522         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8523         LDKNodeId source_conv;
8524         source_conv.inner = (void*)(source & (~1));
8525         source_conv.is_owned = false;
8526         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
8527         LDKNodeId target_conv;
8528         target_conv.inner = (void*)(target & (~1));
8529         target_conv.is_owned = false;
8530         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
8531         LDKChannelUsage usage_conv;
8532         usage_conv.inner = (void*)(usage & (~1));
8533         usage_conv.is_owned = (usage & 1) || (usage == 0);
8534         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
8535         usage_conv = ChannelUsage_clone(&usage_conv);
8536         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
8537         return ret_conv;
8538 }
8539
8540 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) {
8541         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8542         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8543         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8544         LDKCVec_RouteHopZ path_constr;
8545         path_constr.datalen = path->arr_len;
8546         if (path_constr.datalen > 0)
8547                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8548         else
8549                 path_constr.data = NULL;
8550         uint32_t* path_vals = path->elems;
8551         for (size_t k = 0; k < path_constr.datalen; k++) {
8552                 uint32_t path_conv_10 = path_vals[k];
8553                 LDKRouteHop path_conv_10_conv;
8554                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8555                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8556                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8557                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8558                 path_constr.data[k] = path_conv_10_conv;
8559         }
8560         FREE(path);
8561         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
8562 }
8563
8564 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
8565         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8566         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8567         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8568         LDKCVec_RouteHopZ path_constr;
8569         path_constr.datalen = path->arr_len;
8570         if (path_constr.datalen > 0)
8571                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8572         else
8573                 path_constr.data = NULL;
8574         uint32_t* path_vals = path->elems;
8575         for (size_t k = 0; k < path_constr.datalen; k++) {
8576                 uint32_t path_conv_10 = path_vals[k];
8577                 LDKRouteHop path_conv_10_conv;
8578                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8579                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8580                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8581                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8582                 path_constr.data[k] = path_conv_10_conv;
8583         }
8584         FREE(path);
8585         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
8586 }
8587
8588 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint32_t this_arg) {
8589         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8590         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8591         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8592         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
8593         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
8594         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
8595         CVec_u8Z_free(ret_var);
8596         return ret_arr;
8597 }
8598
8599 typedef struct LDKPersister_JCalls {
8600         atomic_size_t refcnt;
8601         uint32_t instance_ptr;
8602 } LDKPersister_JCalls;
8603 static void LDKPersister_JCalls_free(void* this_arg) {
8604         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8605         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8606                 FREE(j_calls);
8607         }
8608 }
8609 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8610         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8611         LDKChannelManager channel_manager_var = *channel_manager;
8612         uint32_t channel_manager_ref = 0;
8613         // WARNING: we may need a move here but no clone is available for LDKChannelManager
8614         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8615         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8616         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
8617         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
8618         if (channel_manager_var.is_owned) {
8619                 channel_manager_ref |= 1;
8620         }
8621         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 41, (uint32_t)channel_manager_ref);
8622         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8623         CHECK_ACCESS(ret_ptr);
8624         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8625         FREE((void*)ret);
8626         return ret_conv;
8627 }
8628 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
8629         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8630         LDKNetworkGraph network_graph_var = *network_graph;
8631         uint32_t network_graph_ref = 0;
8632         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
8633         CHECK((((uintptr_t)network_graph_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8634         CHECK((((uintptr_t)&network_graph_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8635         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
8636         network_graph_ref = (uintptr_t)network_graph_var.inner;
8637         if (network_graph_var.is_owned) {
8638                 network_graph_ref |= 1;
8639         }
8640         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 42, (uint32_t)network_graph_ref);
8641         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8642         CHECK_ACCESS(ret_ptr);
8643         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8644         FREE((void*)ret);
8645         return ret_conv;
8646 }
8647 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKMultiThreadedLockableScore * scorer) {
8648         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8649         LDKMultiThreadedLockableScore scorer_var = *scorer;
8650         uint32_t scorer_ref = 0;
8651         // WARNING: we may need a move here but no clone is available for LDKMultiThreadedLockableScore
8652         CHECK((((uintptr_t)scorer_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8653         CHECK((((uintptr_t)&scorer_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8654         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_var);
8655         scorer_ref = (uintptr_t)scorer_var.inner;
8656         if (scorer_var.is_owned) {
8657                 scorer_ref |= 1;
8658         }
8659         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 43, (uint32_t)scorer_ref);
8660         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8661         CHECK_ACCESS(ret_ptr);
8662         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8663         FREE((void*)ret);
8664         return ret_conv;
8665 }
8666 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
8667         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
8668         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8669 }
8670 static inline LDKPersister LDKPersister_init (JSValue o) {
8671         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
8672         atomic_init(&calls->refcnt, 1);
8673         calls->instance_ptr = o;
8674
8675         LDKPersister ret = {
8676                 .this_arg = (void*) calls,
8677                 .persist_manager = persist_manager_LDKPersister_jcall,
8678                 .persist_graph = persist_graph_LDKPersister_jcall,
8679                 .persist_scorer = persist_scorer_LDKPersister_jcall,
8680                 .free = LDKPersister_JCalls_free,
8681         };
8682         return ret;
8683 }
8684 long  __attribute__((export_name("TS_LDKPersister_new"))) TS_LDKPersister_new(JSValue o) {
8685         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
8686         *res_ptr = LDKPersister_init(o);
8687         return (long)res_ptr;
8688 }
8689 uint32_t  __attribute__((export_name("TS_Persister_persist_manager"))) TS_Persister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
8690         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8691         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8692         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8693         LDKChannelManager channel_manager_conv;
8694         channel_manager_conv.inner = (void*)(channel_manager & (~1));
8695         channel_manager_conv.is_owned = false;
8696         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
8697         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8698         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
8699         return (uint32_t)ret_conv;
8700 }
8701
8702 uint32_t  __attribute__((export_name("TS_Persister_persist_graph"))) TS_Persister_persist_graph(uint32_t this_arg, uint32_t network_graph) {
8703         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8704         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8705         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8706         LDKNetworkGraph network_graph_conv;
8707         network_graph_conv.inner = (void*)(network_graph & (~1));
8708         network_graph_conv.is_owned = false;
8709         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
8710         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8711         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
8712         return (uint32_t)ret_conv;
8713 }
8714
8715 uint32_t  __attribute__((export_name("TS_Persister_persist_scorer"))) TS_Persister_persist_scorer(uint32_t this_arg, uint32_t scorer) {
8716         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8717         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8718         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8719         LDKMultiThreadedLockableScore scorer_conv;
8720         scorer_conv.inner = (void*)(scorer & (~1));
8721         scorer_conv.is_owned = false;
8722         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
8723         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8724         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, &scorer_conv);
8725         return (uint32_t)ret_conv;
8726 }
8727
8728 typedef struct LDKListen_JCalls {
8729         atomic_size_t refcnt;
8730         uint32_t instance_ptr;
8731 } LDKListen_JCalls;
8732 static void LDKListen_JCalls_free(void* this_arg) {
8733         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8734         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8735                 FREE(j_calls);
8736         }
8737 }
8738 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
8739         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8740         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8741         memcpy(header_arr->elems, *header, 80);
8742         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
8743         uint32_tArray txdata_arr = NULL;
8744         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
8745         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
8746         for (size_t c = 0; c < txdata_var.datalen; c++) {
8747                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8748                 *txdata_conv_28_conv = txdata_var.data[c];
8749                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
8750         }
8751         
8752         FREE(txdata_var.data);
8753         int32_t height_conv = height;
8754         js_invoke_function_u_uuu(j_calls->instance_ptr, 44, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height_conv);
8755 }
8756 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
8757         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8758         LDKu8slice block_var = block;
8759         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
8760         memcpy(block_arr->elems, block_var.data, block_var.datalen);
8761         int32_t height_conv = height;
8762         js_invoke_function_u_uu(j_calls->instance_ptr, 45, (uint32_t)block_arr, (uint32_t)height_conv);
8763 }
8764 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8765         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8766         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8767         memcpy(header_arr->elems, *header, 80);
8768         int32_t height_conv = height;
8769         js_invoke_function_u_uu(j_calls->instance_ptr, 46, (uint32_t)header_arr, (uint32_t)height_conv);
8770 }
8771 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
8772         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
8773         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8774 }
8775 static inline LDKListen LDKListen_init (JSValue o) {
8776         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
8777         atomic_init(&calls->refcnt, 1);
8778         calls->instance_ptr = o;
8779
8780         LDKListen ret = {
8781                 .this_arg = (void*) calls,
8782                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
8783                 .block_connected = block_connected_LDKListen_jcall,
8784                 .block_disconnected = block_disconnected_LDKListen_jcall,
8785                 .free = LDKListen_JCalls_free,
8786         };
8787         return ret;
8788 }
8789 long  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
8790         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
8791         *res_ptr = LDKListen_init(o);
8792         return (long)res_ptr;
8793 }
8794 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) {
8795         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8796         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8797         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8798         unsigned char header_arr[80];
8799         CHECK(header->arr_len == 80);
8800         memcpy(header_arr, header->elems, 80); FREE(header);
8801         unsigned char (*header_ref)[80] = &header_arr;
8802         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8803         txdata_constr.datalen = txdata->arr_len;
8804         if (txdata_constr.datalen > 0)
8805                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8806         else
8807                 txdata_constr.data = NULL;
8808         uint32_t* txdata_vals = txdata->elems;
8809         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8810                 uint32_t txdata_conv_28 = txdata_vals[c];
8811                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
8812                 CHECK_ACCESS(txdata_conv_28_ptr);
8813                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8814                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
8815                 txdata_constr.data[c] = txdata_conv_28_conv;
8816         }
8817         FREE(txdata);
8818         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8819 }
8820
8821 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
8822         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8823         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8824         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8825         LDKu8slice block_ref;
8826         block_ref.datalen = block->arr_len;
8827         block_ref.data = block->elems;
8828         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
8829         FREE(block);
8830 }
8831
8832 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
8833         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8834         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8835         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8836         unsigned char header_arr[80];
8837         CHECK(header->arr_len == 80);
8838         memcpy(header_arr, header->elems, 80); FREE(header);
8839         unsigned char (*header_ref)[80] = &header_arr;
8840         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
8841 }
8842
8843 typedef struct LDKConfirm_JCalls {
8844         atomic_size_t refcnt;
8845         uint32_t instance_ptr;
8846 } LDKConfirm_JCalls;
8847 static void LDKConfirm_JCalls_free(void* this_arg) {
8848         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8849         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8850                 FREE(j_calls);
8851         }
8852 }
8853 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
8854         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8855         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8856         memcpy(header_arr->elems, *header, 80);
8857         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
8858         uint32_tArray txdata_arr = NULL;
8859         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
8860         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
8861         for (size_t c = 0; c < txdata_var.datalen; c++) {
8862                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8863                 *txdata_conv_28_conv = txdata_var.data[c];
8864                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
8865         }
8866         
8867         FREE(txdata_var.data);
8868         int32_t height_conv = height;
8869         js_invoke_function_u_uuu(j_calls->instance_ptr, 47, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height_conv);
8870 }
8871 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
8872         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8873         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8874         memcpy(txid_arr->elems, *txid, 32);
8875         js_invoke_function_u_u(j_calls->instance_ptr, 48, (uint32_t)txid_arr);
8876 }
8877 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8878         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8879         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8880         memcpy(header_arr->elems, *header, 80);
8881         int32_t height_conv = height;
8882         js_invoke_function_u_uu(j_calls->instance_ptr, 49, (uint32_t)header_arr, (uint32_t)height_conv);
8883 }
8884 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
8885         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8886         ptrArray ret = (ptrArray)js_invoke_function_u_(j_calls->instance_ptr, 50);
8887         LDKCVec_TxidZ ret_constr;
8888         ret_constr.datalen = ret->arr_len;
8889         if (ret_constr.datalen > 0)
8890                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
8891         else
8892                 ret_constr.data = NULL;
8893         int8_tArray* ret_vals = (void*) ret->elems;
8894         for (size_t m = 0; m < ret_constr.datalen; m++) {
8895                 int8_tArray ret_conv_12 = ret_vals[m];
8896                 LDKThirtyTwoBytes ret_conv_12_ref;
8897                 CHECK(ret_conv_12->arr_len == 32);
8898                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32); FREE(ret_conv_12);
8899                 ret_constr.data[m] = ret_conv_12_ref;
8900         }
8901         FREE(ret);
8902         return ret_constr;
8903 }
8904 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
8905         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
8906         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8907 }
8908 static inline LDKConfirm LDKConfirm_init (JSValue o) {
8909         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
8910         atomic_init(&calls->refcnt, 1);
8911         calls->instance_ptr = o;
8912
8913         LDKConfirm ret = {
8914                 .this_arg = (void*) calls,
8915                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
8916                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
8917                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
8918                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
8919                 .free = LDKConfirm_JCalls_free,
8920         };
8921         return ret;
8922 }
8923 long  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
8924         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
8925         *res_ptr = LDKConfirm_init(o);
8926         return (long)res_ptr;
8927 }
8928 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) {
8929         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8930         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8931         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8932         unsigned char header_arr[80];
8933         CHECK(header->arr_len == 80);
8934         memcpy(header_arr, header->elems, 80); FREE(header);
8935         unsigned char (*header_ref)[80] = &header_arr;
8936         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8937         txdata_constr.datalen = txdata->arr_len;
8938         if (txdata_constr.datalen > 0)
8939                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8940         else
8941                 txdata_constr.data = NULL;
8942         uint32_t* txdata_vals = txdata->elems;
8943         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8944                 uint32_t txdata_conv_28 = txdata_vals[c];
8945                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
8946                 CHECK_ACCESS(txdata_conv_28_ptr);
8947                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8948                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
8949                 txdata_constr.data[c] = txdata_conv_28_conv;
8950         }
8951         FREE(txdata);
8952         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8953 }
8954
8955 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
8956         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8957         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8958         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8959         unsigned char txid_arr[32];
8960         CHECK(txid->arr_len == 32);
8961         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8962         unsigned char (*txid_ref)[32] = &txid_arr;
8963         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
8964 }
8965
8966 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
8967         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8968         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8969         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8970         unsigned char header_arr[80];
8971         CHECK(header->arr_len == 80);
8972         memcpy(header_arr, header->elems, 80); FREE(header);
8973         unsigned char (*header_ref)[80] = &header_arr;
8974         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
8975 }
8976
8977 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
8978         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8979         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8980         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8981         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
8982         ptrArray ret_arr = NULL;
8983         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
8984         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
8985         for (size_t m = 0; m < ret_var.datalen; m++) {
8986                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
8987                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
8988                 ret_arr_ptr[m] = ret_conv_12_arr;
8989         }
8990         
8991         FREE(ret_var.data);
8992         return ret_arr;
8993 }
8994
8995 typedef struct LDKPersist_JCalls {
8996         atomic_size_t refcnt;
8997         uint32_t instance_ptr;
8998 } LDKPersist_JCalls;
8999 static void LDKPersist_JCalls_free(void* this_arg) {
9000         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9001         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9002                 FREE(j_calls);
9003         }
9004 }
9005 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
9006         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9007         LDKOutPoint channel_id_var = channel_id;
9008         uint32_t channel_id_ref = 0;
9009         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9010         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9011         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
9012         channel_id_ref = (uintptr_t)channel_id_var.inner;
9013         if (channel_id_var.is_owned) {
9014                 channel_id_ref |= 1;
9015         }
9016         LDKChannelMonitor data_var = *data;
9017         uint32_t data_ref = 0;
9018         data_var = ChannelMonitor_clone(&data_var);
9019         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9020         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9021         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
9022         data_ref = (uintptr_t)data_var.inner;
9023         if (data_var.is_owned) {
9024                 data_ref |= 1;
9025         }
9026         LDKMonitorUpdateId update_id_var = update_id;
9027         uint32_t update_id_ref = 0;
9028         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9029         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9030         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
9031         update_id_ref = (uintptr_t)update_id_var.inner;
9032         if (update_id_var.is_owned) {
9033                 update_id_ref |= 1;
9034         }
9035         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);
9036         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9037         CHECK_ACCESS(ret_ptr);
9038         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
9039         FREE((void*)ret);
9040         return ret_conv;
9041 }
9042 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
9043         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9044         LDKOutPoint channel_id_var = channel_id;
9045         uint32_t channel_id_ref = 0;
9046         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9047         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9048         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
9049         channel_id_ref = (uintptr_t)channel_id_var.inner;
9050         if (channel_id_var.is_owned) {
9051                 channel_id_ref |= 1;
9052         }
9053         LDKChannelMonitorUpdate update_var = *update;
9054         uint32_t update_ref = 0;
9055         if ((uintptr_t)update_var.inner > 4096) {
9056                 update_var = ChannelMonitorUpdate_clone(&update_var);
9057                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9058                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9059         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
9060                 update_ref = (uintptr_t)update_var.inner;
9061                 if (update_var.is_owned) {
9062                         update_ref |= 1;
9063                 }
9064         }
9065         LDKChannelMonitor data_var = *data;
9066         uint32_t data_ref = 0;
9067         data_var = ChannelMonitor_clone(&data_var);
9068         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9069         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9070         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
9071         data_ref = (uintptr_t)data_var.inner;
9072         if (data_var.is_owned) {
9073                 data_ref |= 1;
9074         }
9075         LDKMonitorUpdateId update_id_var = update_id;
9076         uint32_t update_id_ref = 0;
9077         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9078         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9079         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
9080         update_id_ref = (uintptr_t)update_id_var.inner;
9081         if (update_id_var.is_owned) {
9082                 update_id_ref |= 1;
9083         }
9084         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);
9085         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9086         CHECK_ACCESS(ret_ptr);
9087         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
9088         FREE((void*)ret);
9089         return ret_conv;
9090 }
9091 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
9092         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
9093         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9094 }
9095 static inline LDKPersist LDKPersist_init (JSValue o) {
9096         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
9097         atomic_init(&calls->refcnt, 1);
9098         calls->instance_ptr = o;
9099
9100         LDKPersist ret = {
9101                 .this_arg = (void*) calls,
9102                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
9103                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
9104                 .free = LDKPersist_JCalls_free,
9105         };
9106         return ret;
9107 }
9108 long  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
9109         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
9110         *res_ptr = LDKPersist_init(o);
9111         return (long)res_ptr;
9112 }
9113 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) {
9114         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9115         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9116         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
9117         LDKOutPoint channel_id_conv;
9118         channel_id_conv.inner = (void*)(channel_id & (~1));
9119         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
9120         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
9121         channel_id_conv = OutPoint_clone(&channel_id_conv);
9122         LDKChannelMonitor data_conv;
9123         data_conv.inner = (void*)(data & (~1));
9124         data_conv.is_owned = false;
9125         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
9126         LDKMonitorUpdateId update_id_conv;
9127         update_id_conv.inner = (void*)(update_id & (~1));
9128         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
9129         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
9130         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
9131         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9132         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
9133         return (uint32_t)ret_conv;
9134 }
9135
9136 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) {
9137         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9138         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9139         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
9140         LDKOutPoint channel_id_conv;
9141         channel_id_conv.inner = (void*)(channel_id & (~1));
9142         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
9143         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
9144         channel_id_conv = OutPoint_clone(&channel_id_conv);
9145         LDKChannelMonitorUpdate update_conv;
9146         update_conv.inner = (void*)(update & (~1));
9147         update_conv.is_owned = false;
9148         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
9149         LDKChannelMonitor data_conv;
9150         data_conv.inner = (void*)(data & (~1));
9151         data_conv.is_owned = false;
9152         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
9153         LDKMonitorUpdateId update_id_conv;
9154         update_id_conv.inner = (void*)(update_id & (~1));
9155         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
9156         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
9157         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
9158         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9159         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
9160         return (uint32_t)ret_conv;
9161 }
9162
9163 typedef struct LDKChannelMessageHandler_JCalls {
9164         atomic_size_t refcnt;
9165         uint32_t instance_ptr;
9166         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9167 } LDKChannelMessageHandler_JCalls;
9168 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
9169         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9170         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9171                 FREE(j_calls);
9172         }
9173 }
9174 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
9175         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9176         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9177         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9178         LDKInitFeatures their_features_var = their_features;
9179         uint32_t their_features_ref = 0;
9180         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9181         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9182         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9183         their_features_ref = (uintptr_t)their_features_var.inner;
9184         if (their_features_var.is_owned) {
9185                 their_features_ref |= 1;
9186         }
9187         LDKOpenChannel msg_var = *msg;
9188         uint32_t msg_ref = 0;
9189         msg_var = OpenChannel_clone(&msg_var);
9190         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9191         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9192         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9193         msg_ref = (uintptr_t)msg_var.inner;
9194         if (msg_var.is_owned) {
9195                 msg_ref |= 1;
9196         }
9197         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);
9198 }
9199 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
9200         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9201         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9202         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9203         LDKInitFeatures their_features_var = their_features;
9204         uint32_t their_features_ref = 0;
9205         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9206         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9207         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9208         their_features_ref = (uintptr_t)their_features_var.inner;
9209         if (their_features_var.is_owned) {
9210                 their_features_ref |= 1;
9211         }
9212         LDKAcceptChannel msg_var = *msg;
9213         uint32_t msg_ref = 0;
9214         msg_var = AcceptChannel_clone(&msg_var);
9215         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9216         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9217         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9218         msg_ref = (uintptr_t)msg_var.inner;
9219         if (msg_var.is_owned) {
9220                 msg_ref |= 1;
9221         }
9222         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);
9223 }
9224 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
9225         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9226         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9227         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9228         LDKFundingCreated msg_var = *msg;
9229         uint32_t msg_ref = 0;
9230         msg_var = FundingCreated_clone(&msg_var);
9231         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9232         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9233         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9234         msg_ref = (uintptr_t)msg_var.inner;
9235         if (msg_var.is_owned) {
9236                 msg_ref |= 1;
9237         }
9238         js_invoke_function_u_uu(j_calls->instance_ptr, 55, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9239 }
9240 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
9241         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9242         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9243         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9244         LDKFundingSigned msg_var = *msg;
9245         uint32_t msg_ref = 0;
9246         msg_var = FundingSigned_clone(&msg_var);
9247         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9248         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9249         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9250         msg_ref = (uintptr_t)msg_var.inner;
9251         if (msg_var.is_owned) {
9252                 msg_ref |= 1;
9253         }
9254         js_invoke_function_u_uu(j_calls->instance_ptr, 56, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9255 }
9256 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
9257         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9258         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9259         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9260         LDKChannelReady msg_var = *msg;
9261         uint32_t msg_ref = 0;
9262         msg_var = ChannelReady_clone(&msg_var);
9263         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9264         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9265         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9266         msg_ref = (uintptr_t)msg_var.inner;
9267         if (msg_var.is_owned) {
9268                 msg_ref |= 1;
9269         }
9270         js_invoke_function_u_uu(j_calls->instance_ptr, 57, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9271 }
9272 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
9273         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9274         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9275         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9276         LDKInitFeatures their_features_var = *their_features;
9277         uint32_t their_features_ref = 0;
9278         their_features_var = InitFeatures_clone(&their_features_var);
9279         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9280         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9281         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9282         their_features_ref = (uintptr_t)their_features_var.inner;
9283         if (their_features_var.is_owned) {
9284                 their_features_ref |= 1;
9285         }
9286         LDKShutdown msg_var = *msg;
9287         uint32_t msg_ref = 0;
9288         msg_var = Shutdown_clone(&msg_var);
9289         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9290         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9291         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9292         msg_ref = (uintptr_t)msg_var.inner;
9293         if (msg_var.is_owned) {
9294                 msg_ref |= 1;
9295         }
9296         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);
9297 }
9298 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
9299         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9300         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9301         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9302         LDKClosingSigned msg_var = *msg;
9303         uint32_t msg_ref = 0;
9304         msg_var = ClosingSigned_clone(&msg_var);
9305         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9306         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9307         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9308         msg_ref = (uintptr_t)msg_var.inner;
9309         if (msg_var.is_owned) {
9310                 msg_ref |= 1;
9311         }
9312         js_invoke_function_u_uu(j_calls->instance_ptr, 59, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9313 }
9314 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
9315         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9316         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9317         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9318         LDKUpdateAddHTLC msg_var = *msg;
9319         uint32_t msg_ref = 0;
9320         msg_var = UpdateAddHTLC_clone(&msg_var);
9321         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9322         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9323         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9324         msg_ref = (uintptr_t)msg_var.inner;
9325         if (msg_var.is_owned) {
9326                 msg_ref |= 1;
9327         }
9328         js_invoke_function_u_uu(j_calls->instance_ptr, 60, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9329 }
9330 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
9331         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9332         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9333         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9334         LDKUpdateFulfillHTLC msg_var = *msg;
9335         uint32_t msg_ref = 0;
9336         msg_var = UpdateFulfillHTLC_clone(&msg_var);
9337         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9338         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9339         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9340         msg_ref = (uintptr_t)msg_var.inner;
9341         if (msg_var.is_owned) {
9342                 msg_ref |= 1;
9343         }
9344         js_invoke_function_u_uu(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9345 }
9346 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
9347         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9348         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9349         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9350         LDKUpdateFailHTLC msg_var = *msg;
9351         uint32_t msg_ref = 0;
9352         msg_var = UpdateFailHTLC_clone(&msg_var);
9353         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9354         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9355         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9356         msg_ref = (uintptr_t)msg_var.inner;
9357         if (msg_var.is_owned) {
9358                 msg_ref |= 1;
9359         }
9360         js_invoke_function_u_uu(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9361 }
9362 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
9363         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9364         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9365         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9366         LDKUpdateFailMalformedHTLC msg_var = *msg;
9367         uint32_t msg_ref = 0;
9368         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
9369         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9370         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9371         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9372         msg_ref = (uintptr_t)msg_var.inner;
9373         if (msg_var.is_owned) {
9374                 msg_ref |= 1;
9375         }
9376         js_invoke_function_u_uu(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9377 }
9378 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
9379         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9380         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9381         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9382         LDKCommitmentSigned msg_var = *msg;
9383         uint32_t msg_ref = 0;
9384         msg_var = CommitmentSigned_clone(&msg_var);
9385         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9386         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9387         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9388         msg_ref = (uintptr_t)msg_var.inner;
9389         if (msg_var.is_owned) {
9390                 msg_ref |= 1;
9391         }
9392         js_invoke_function_u_uu(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9393 }
9394 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
9395         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9396         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9397         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9398         LDKRevokeAndACK msg_var = *msg;
9399         uint32_t msg_ref = 0;
9400         msg_var = RevokeAndACK_clone(&msg_var);
9401         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9402         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9403         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9404         msg_ref = (uintptr_t)msg_var.inner;
9405         if (msg_var.is_owned) {
9406                 msg_ref |= 1;
9407         }
9408         js_invoke_function_u_uu(j_calls->instance_ptr, 65, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9409 }
9410 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
9411         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9412         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9413         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9414         LDKUpdateFee msg_var = *msg;
9415         uint32_t msg_ref = 0;
9416         msg_var = UpdateFee_clone(&msg_var);
9417         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9418         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9419         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9420         msg_ref = (uintptr_t)msg_var.inner;
9421         if (msg_var.is_owned) {
9422                 msg_ref |= 1;
9423         }
9424         js_invoke_function_u_uu(j_calls->instance_ptr, 66, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9425 }
9426 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
9427         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9428         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9429         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9430         LDKAnnouncementSignatures msg_var = *msg;
9431         uint32_t msg_ref = 0;
9432         msg_var = AnnouncementSignatures_clone(&msg_var);
9433         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9434         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9435         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9436         msg_ref = (uintptr_t)msg_var.inner;
9437         if (msg_var.is_owned) {
9438                 msg_ref |= 1;
9439         }
9440         js_invoke_function_u_uu(j_calls->instance_ptr, 67, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9441 }
9442 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
9443         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9444         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9445         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9446         jboolean no_connection_possible_conv = no_connection_possible;
9447         js_invoke_function_u_uu(j_calls->instance_ptr, 68, (uint32_t)their_node_id_arr, (uint32_t)no_connection_possible_conv);
9448 }
9449 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
9450         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9451         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9452         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9453         LDKInit msg_var = *msg;
9454         uint32_t msg_ref = 0;
9455         msg_var = Init_clone(&msg_var);
9456         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9457         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9458         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9459         msg_ref = (uintptr_t)msg_var.inner;
9460         if (msg_var.is_owned) {
9461                 msg_ref |= 1;
9462         }
9463         js_invoke_function_u_uu(j_calls->instance_ptr, 69, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9464 }
9465 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
9466         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9467         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9468         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9469         LDKChannelReestablish msg_var = *msg;
9470         uint32_t msg_ref = 0;
9471         msg_var = ChannelReestablish_clone(&msg_var);
9472         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9473         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9474         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9475         msg_ref = (uintptr_t)msg_var.inner;
9476         if (msg_var.is_owned) {
9477                 msg_ref |= 1;
9478         }
9479         js_invoke_function_u_uu(j_calls->instance_ptr, 70, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9480 }
9481 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
9482         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9483         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9484         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9485         LDKChannelUpdate msg_var = *msg;
9486         uint32_t msg_ref = 0;
9487         msg_var = ChannelUpdate_clone(&msg_var);
9488         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9489         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9490         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9491         msg_ref = (uintptr_t)msg_var.inner;
9492         if (msg_var.is_owned) {
9493                 msg_ref |= 1;
9494         }
9495         js_invoke_function_u_uu(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9496 }
9497 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
9498         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9499         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9500         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9501         LDKErrorMessage msg_var = *msg;
9502         uint32_t msg_ref = 0;
9503         msg_var = ErrorMessage_clone(&msg_var);
9504         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9505         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9506         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9507         msg_ref = (uintptr_t)msg_var.inner;
9508         if (msg_var.is_owned) {
9509                 msg_ref |= 1;
9510         }
9511         js_invoke_function_u_uu(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9512 }
9513 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
9514         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
9515         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9516         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9517 }
9518 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
9519         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
9520         atomic_init(&calls->refcnt, 1);
9521         calls->instance_ptr = o;
9522
9523         LDKChannelMessageHandler ret = {
9524                 .this_arg = (void*) calls,
9525                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
9526                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
9527                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
9528                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
9529                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
9530                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
9531                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
9532                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
9533                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
9534                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
9535                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
9536                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
9537                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
9538                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
9539                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
9540                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
9541                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
9542                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
9543                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
9544                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
9545                 .free = LDKChannelMessageHandler_JCalls_free,
9546                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
9547         };
9548         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9549         return ret;
9550 }
9551 long  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
9552         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
9553         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
9554         return (long)res_ptr;
9555 }
9556 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) {
9557         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9558         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9559         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9560         LDKPublicKey their_node_id_ref;
9561         CHECK(their_node_id->arr_len == 33);
9562         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9563         LDKInitFeatures their_features_conv;
9564         their_features_conv.inner = (void*)(their_features & (~1));
9565         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9566         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9567         their_features_conv = InitFeatures_clone(&their_features_conv);
9568         LDKOpenChannel msg_conv;
9569         msg_conv.inner = (void*)(msg & (~1));
9570         msg_conv.is_owned = false;
9571         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9572         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9573 }
9574
9575 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) {
9576         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9577         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9578         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9579         LDKPublicKey their_node_id_ref;
9580         CHECK(their_node_id->arr_len == 33);
9581         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9582         LDKInitFeatures their_features_conv;
9583         their_features_conv.inner = (void*)(their_features & (~1));
9584         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9585         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9586         their_features_conv = InitFeatures_clone(&their_features_conv);
9587         LDKAcceptChannel msg_conv;
9588         msg_conv.inner = (void*)(msg & (~1));
9589         msg_conv.is_owned = false;
9590         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9591         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9592 }
9593
9594 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) {
9595         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9596         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9597         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9598         LDKPublicKey their_node_id_ref;
9599         CHECK(their_node_id->arr_len == 33);
9600         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9601         LDKFundingCreated msg_conv;
9602         msg_conv.inner = (void*)(msg & (~1));
9603         msg_conv.is_owned = false;
9604         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9605         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9606 }
9607
9608 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) {
9609         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9610         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9611         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9612         LDKPublicKey their_node_id_ref;
9613         CHECK(their_node_id->arr_len == 33);
9614         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9615         LDKFundingSigned msg_conv;
9616         msg_conv.inner = (void*)(msg & (~1));
9617         msg_conv.is_owned = false;
9618         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9619         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9620 }
9621
9622 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) {
9623         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9624         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9625         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9626         LDKPublicKey their_node_id_ref;
9627         CHECK(their_node_id->arr_len == 33);
9628         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9629         LDKChannelReady msg_conv;
9630         msg_conv.inner = (void*)(msg & (~1));
9631         msg_conv.is_owned = false;
9632         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9633         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9634 }
9635
9636 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) {
9637         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9638         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9639         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9640         LDKPublicKey their_node_id_ref;
9641         CHECK(their_node_id->arr_len == 33);
9642         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9643         LDKInitFeatures their_features_conv;
9644         their_features_conv.inner = (void*)(their_features & (~1));
9645         their_features_conv.is_owned = false;
9646         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9647         LDKShutdown msg_conv;
9648         msg_conv.inner = (void*)(msg & (~1));
9649         msg_conv.is_owned = false;
9650         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9651         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9652 }
9653
9654 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) {
9655         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9656         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9657         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9658         LDKPublicKey their_node_id_ref;
9659         CHECK(their_node_id->arr_len == 33);
9660         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9661         LDKClosingSigned msg_conv;
9662         msg_conv.inner = (void*)(msg & (~1));
9663         msg_conv.is_owned = false;
9664         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9665         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9666 }
9667
9668 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) {
9669         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9670         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9671         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9672         LDKPublicKey their_node_id_ref;
9673         CHECK(their_node_id->arr_len == 33);
9674         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9675         LDKUpdateAddHTLC msg_conv;
9676         msg_conv.inner = (void*)(msg & (~1));
9677         msg_conv.is_owned = false;
9678         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9679         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9680 }
9681
9682 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) {
9683         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9684         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9685         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9686         LDKPublicKey their_node_id_ref;
9687         CHECK(their_node_id->arr_len == 33);
9688         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9689         LDKUpdateFulfillHTLC msg_conv;
9690         msg_conv.inner = (void*)(msg & (~1));
9691         msg_conv.is_owned = false;
9692         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9693         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9694 }
9695
9696 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) {
9697         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9698         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9699         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9700         LDKPublicKey their_node_id_ref;
9701         CHECK(their_node_id->arr_len == 33);
9702         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9703         LDKUpdateFailHTLC msg_conv;
9704         msg_conv.inner = (void*)(msg & (~1));
9705         msg_conv.is_owned = false;
9706         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9707         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9708 }
9709
9710 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) {
9711         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9712         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9713         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9714         LDKPublicKey their_node_id_ref;
9715         CHECK(their_node_id->arr_len == 33);
9716         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9717         LDKUpdateFailMalformedHTLC msg_conv;
9718         msg_conv.inner = (void*)(msg & (~1));
9719         msg_conv.is_owned = false;
9720         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9721         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9722 }
9723
9724 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) {
9725         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9726         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9727         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9728         LDKPublicKey their_node_id_ref;
9729         CHECK(their_node_id->arr_len == 33);
9730         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9731         LDKCommitmentSigned msg_conv;
9732         msg_conv.inner = (void*)(msg & (~1));
9733         msg_conv.is_owned = false;
9734         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9735         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9736 }
9737
9738 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) {
9739         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9740         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9741         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9742         LDKPublicKey their_node_id_ref;
9743         CHECK(their_node_id->arr_len == 33);
9744         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9745         LDKRevokeAndACK msg_conv;
9746         msg_conv.inner = (void*)(msg & (~1));
9747         msg_conv.is_owned = false;
9748         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9749         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9750 }
9751
9752 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) {
9753         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9754         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9755         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9756         LDKPublicKey their_node_id_ref;
9757         CHECK(their_node_id->arr_len == 33);
9758         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9759         LDKUpdateFee msg_conv;
9760         msg_conv.inner = (void*)(msg & (~1));
9761         msg_conv.is_owned = false;
9762         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9763         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9764 }
9765
9766 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) {
9767         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9768         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9769         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9770         LDKPublicKey their_node_id_ref;
9771         CHECK(their_node_id->arr_len == 33);
9772         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9773         LDKAnnouncementSignatures msg_conv;
9774         msg_conv.inner = (void*)(msg & (~1));
9775         msg_conv.is_owned = false;
9776         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9777         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9778 }
9779
9780 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) {
9781         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9782         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9783         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9784         LDKPublicKey their_node_id_ref;
9785         CHECK(their_node_id->arr_len == 33);
9786         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9787         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
9788 }
9789
9790 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9791         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9792         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9793         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9794         LDKPublicKey their_node_id_ref;
9795         CHECK(their_node_id->arr_len == 33);
9796         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9797         LDKInit msg_conv;
9798         msg_conv.inner = (void*)(msg & (~1));
9799         msg_conv.is_owned = false;
9800         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9801         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9802 }
9803
9804 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) {
9805         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9806         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9807         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9808         LDKPublicKey their_node_id_ref;
9809         CHECK(their_node_id->arr_len == 33);
9810         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9811         LDKChannelReestablish msg_conv;
9812         msg_conv.inner = (void*)(msg & (~1));
9813         msg_conv.is_owned = false;
9814         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9815         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9816 }
9817
9818 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) {
9819         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9820         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9821         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9822         LDKPublicKey their_node_id_ref;
9823         CHECK(their_node_id->arr_len == 33);
9824         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9825         LDKChannelUpdate msg_conv;
9826         msg_conv.inner = (void*)(msg & (~1));
9827         msg_conv.is_owned = false;
9828         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9829         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9830 }
9831
9832 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9833         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9834         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9835         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9836         LDKPublicKey their_node_id_ref;
9837         CHECK(their_node_id->arr_len == 33);
9838         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9839         LDKErrorMessage msg_conv;
9840         msg_conv.inner = (void*)(msg & (~1));
9841         msg_conv.is_owned = false;
9842         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9843         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9844 }
9845
9846 typedef struct LDKRoutingMessageHandler_JCalls {
9847         atomic_size_t refcnt;
9848         uint32_t instance_ptr;
9849         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9850 } LDKRoutingMessageHandler_JCalls;
9851 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9852         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9853         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9854                 FREE(j_calls);
9855         }
9856 }
9857 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9858         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9859         LDKNodeAnnouncement msg_var = *msg;
9860         uint32_t msg_ref = 0;
9861         msg_var = NodeAnnouncement_clone(&msg_var);
9862         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9863         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9864         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9865         msg_ref = (uintptr_t)msg_var.inner;
9866         if (msg_var.is_owned) {
9867                 msg_ref |= 1;
9868         }
9869         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 73, (uint32_t)msg_ref);
9870         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9871         CHECK_ACCESS(ret_ptr);
9872         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9873         FREE((void*)ret);
9874         return ret_conv;
9875 }
9876 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9877         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9878         LDKChannelAnnouncement msg_var = *msg;
9879         uint32_t msg_ref = 0;
9880         msg_var = ChannelAnnouncement_clone(&msg_var);
9881         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9882         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9883         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9884         msg_ref = (uintptr_t)msg_var.inner;
9885         if (msg_var.is_owned) {
9886                 msg_ref |= 1;
9887         }
9888         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 74, (uint32_t)msg_ref);
9889         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9890         CHECK_ACCESS(ret_ptr);
9891         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9892         FREE((void*)ret);
9893         return ret_conv;
9894 }
9895 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9896         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9897         LDKChannelUpdate msg_var = *msg;
9898         uint32_t msg_ref = 0;
9899         msg_var = ChannelUpdate_clone(&msg_var);
9900         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9901         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9902         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9903         msg_ref = (uintptr_t)msg_var.inner;
9904         if (msg_var.is_owned) {
9905                 msg_ref |= 1;
9906         }
9907         uint32_t ret = js_invoke_function_u_u(j_calls->instance_ptr, 75, (uint32_t)msg_ref);
9908         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9909         CHECK_ACCESS(ret_ptr);
9910         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9911         FREE((void*)ret);
9912         return ret_conv;
9913 }
9914 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9915         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9916         int64_t starting_point_conv = starting_point;
9917         int8_t batch_amount_conv = batch_amount;
9918         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);
9919         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9920         ret_constr.datalen = ret->arr_len;
9921         if (ret_constr.datalen > 0)
9922                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9923         else
9924                 ret_constr.data = NULL;
9925         uint32_t* ret_vals = ret->elems;
9926         for (size_t h = 0; h < ret_constr.datalen; h++) {
9927                 uint32_t ret_conv_59 = ret_vals[h];
9928                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
9929                 CHECK_ACCESS(ret_conv_59_ptr);
9930                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
9931                 FREE((void*)ret_conv_59);
9932                 ret_constr.data[h] = ret_conv_59_conv;
9933         }
9934         FREE(ret);
9935         return ret_constr;
9936 }
9937 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9938         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9939         int8_tArray starting_point_arr = init_int8_tArray(33, __LINE__);
9940         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
9941         int8_t batch_amount_conv = batch_amount;
9942         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);
9943         LDKCVec_NodeAnnouncementZ ret_constr;
9944         ret_constr.datalen = ret->arr_len;
9945         if (ret_constr.datalen > 0)
9946                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9947         else
9948                 ret_constr.data = NULL;
9949         uint32_t* ret_vals = ret->elems;
9950         for (size_t s = 0; s < ret_constr.datalen; s++) {
9951                 uint32_t ret_conv_18 = ret_vals[s];
9952                 LDKNodeAnnouncement ret_conv_18_conv;
9953                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9954                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9955                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
9956                 ret_constr.data[s] = ret_conv_18_conv;
9957         }
9958         FREE(ret);
9959         return ret_constr;
9960 }
9961 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9962         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9963         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9964         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9965         LDKInit init_var = *init;
9966         uint32_t init_ref = 0;
9967         init_var = Init_clone(&init_var);
9968         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9969         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9970         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
9971         init_ref = (uintptr_t)init_var.inner;
9972         if (init_var.is_owned) {
9973                 init_ref |= 1;
9974         }
9975         js_invoke_function_u_uu(j_calls->instance_ptr, 78, (uint32_t)their_node_id_arr, (uint32_t)init_ref);
9976 }
9977 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9978         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9979         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9980         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9981         LDKReplyChannelRange msg_var = msg;
9982         uint32_t msg_ref = 0;
9983         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9984         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9985         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9986         msg_ref = (uintptr_t)msg_var.inner;
9987         if (msg_var.is_owned) {
9988                 msg_ref |= 1;
9989         }
9990         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 79, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9991         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9992         CHECK_ACCESS(ret_ptr);
9993         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9994         FREE((void*)ret);
9995         return ret_conv;
9996 }
9997 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9998         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9999         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10000         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10001         LDKReplyShortChannelIdsEnd msg_var = msg;
10002         uint32_t msg_ref = 0;
10003         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10004         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10005         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10006         msg_ref = (uintptr_t)msg_var.inner;
10007         if (msg_var.is_owned) {
10008                 msg_ref |= 1;
10009         }
10010         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 80, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
10011         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10012         CHECK_ACCESS(ret_ptr);
10013         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10014         FREE((void*)ret);
10015         return ret_conv;
10016 }
10017 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
10018         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10019         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10020         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10021         LDKQueryChannelRange msg_var = msg;
10022         uint32_t msg_ref = 0;
10023         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10024         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10025         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10026         msg_ref = (uintptr_t)msg_var.inner;
10027         if (msg_var.is_owned) {
10028                 msg_ref |= 1;
10029         }
10030         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 81, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
10031         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10032         CHECK_ACCESS(ret_ptr);
10033         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10034         FREE((void*)ret);
10035         return ret_conv;
10036 }
10037 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
10038         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10039         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10040         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10041         LDKQueryShortChannelIds msg_var = msg;
10042         uint32_t msg_ref = 0;
10043         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10044         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10045         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10046         msg_ref = (uintptr_t)msg_var.inner;
10047         if (msg_var.is_owned) {
10048                 msg_ref |= 1;
10049         }
10050         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 82, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
10051         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10052         CHECK_ACCESS(ret_ptr);
10053         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10054         FREE((void*)ret);
10055         return ret_conv;
10056 }
10057 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
10058         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
10059         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10060         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
10061 }
10062 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
10063         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
10064         atomic_init(&calls->refcnt, 1);
10065         calls->instance_ptr = o;
10066
10067         LDKRoutingMessageHandler ret = {
10068                 .this_arg = (void*) calls,
10069                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
10070                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
10071                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
10072                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
10073                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
10074                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
10075                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
10076                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
10077                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
10078                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
10079                 .free = LDKRoutingMessageHandler_JCalls_free,
10080                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
10081         };
10082         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
10083         return ret;
10084 }
10085 long  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
10086         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
10087         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
10088         return (long)res_ptr;
10089 }
10090 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
10091         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10092         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10093         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10094         LDKNodeAnnouncement msg_conv;
10095         msg_conv.inner = (void*)(msg & (~1));
10096         msg_conv.is_owned = false;
10097         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10098         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10099         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
10100         return (uint32_t)ret_conv;
10101 }
10102
10103 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
10104         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10105         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10106         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10107         LDKChannelAnnouncement msg_conv;
10108         msg_conv.inner = (void*)(msg & (~1));
10109         msg_conv.is_owned = false;
10110         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10111         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10112         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
10113         return (uint32_t)ret_conv;
10114 }
10115
10116 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
10117         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10118         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10119         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10120         LDKChannelUpdate msg_conv;
10121         msg_conv.inner = (void*)(msg & (~1));
10122         msg_conv.is_owned = false;
10123         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10124         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10125         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
10126         return (uint32_t)ret_conv;
10127 }
10128
10129 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) {
10130         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10131         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10132         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10133         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
10134         uint32_tArray ret_arr = NULL;
10135         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10136         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10137         for (size_t h = 0; h < ret_var.datalen; h++) {
10138                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
10139                 *ret_conv_59_conv = ret_var.data[h];
10140                 ret_arr_ptr[h] = ((uint32_t)ret_conv_59_conv);
10141         }
10142         
10143         FREE(ret_var.data);
10144         return ret_arr;
10145 }
10146
10147 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) {
10148         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10149         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10150         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10151         LDKPublicKey starting_point_ref;
10152         CHECK(starting_point->arr_len == 33);
10153         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33); FREE(starting_point);
10154         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
10155         uint32_tArray ret_arr = NULL;
10156         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10157         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10158         for (size_t s = 0; s < ret_var.datalen; s++) {
10159                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
10160                 uint32_t ret_conv_18_ref = 0;
10161                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10162                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10163                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
10164                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
10165                 if (ret_conv_18_var.is_owned) {
10166                         ret_conv_18_ref |= 1;
10167                 }
10168                 ret_arr_ptr[s] = ret_conv_18_ref;
10169         }
10170         
10171         FREE(ret_var.data);
10172         return ret_arr;
10173 }
10174
10175 void  __attribute__((export_name("TS_RoutingMessageHandler_peer_connected"))) TS_RoutingMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
10176         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10177         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10178         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10179         LDKPublicKey their_node_id_ref;
10180         CHECK(their_node_id->arr_len == 33);
10181         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10182         LDKInit init_conv;
10183         init_conv.inner = (void*)(init & (~1));
10184         init_conv.is_owned = false;
10185         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
10186         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
10187 }
10188
10189 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) {
10190         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10191         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10192         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10193         LDKPublicKey their_node_id_ref;
10194         CHECK(their_node_id->arr_len == 33);
10195         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10196         LDKReplyChannelRange msg_conv;
10197         msg_conv.inner = (void*)(msg & (~1));
10198         msg_conv.is_owned = (msg & 1) || (msg == 0);
10199         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10200         msg_conv = ReplyChannelRange_clone(&msg_conv);
10201         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10202         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10203         return (uint32_t)ret_conv;
10204 }
10205
10206 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) {
10207         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10208         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10209         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10210         LDKPublicKey their_node_id_ref;
10211         CHECK(their_node_id->arr_len == 33);
10212         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10213         LDKReplyShortChannelIdsEnd msg_conv;
10214         msg_conv.inner = (void*)(msg & (~1));
10215         msg_conv.is_owned = (msg & 1) || (msg == 0);
10216         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10217         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
10218         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10219         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10220         return (uint32_t)ret_conv;
10221 }
10222
10223 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) {
10224         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10225         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10226         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10227         LDKPublicKey their_node_id_ref;
10228         CHECK(their_node_id->arr_len == 33);
10229         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10230         LDKQueryChannelRange msg_conv;
10231         msg_conv.inner = (void*)(msg & (~1));
10232         msg_conv.is_owned = (msg & 1) || (msg == 0);
10233         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10234         msg_conv = QueryChannelRange_clone(&msg_conv);
10235         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10236         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10237         return (uint32_t)ret_conv;
10238 }
10239
10240 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) {
10241         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10242         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10243         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10244         LDKPublicKey their_node_id_ref;
10245         CHECK(their_node_id->arr_len == 33);
10246         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10247         LDKQueryShortChannelIds msg_conv;
10248         msg_conv.inner = (void*)(msg & (~1));
10249         msg_conv.is_owned = (msg & 1) || (msg == 0);
10250         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10251         msg_conv = QueryShortChannelIds_clone(&msg_conv);
10252         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10253         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10254         return (uint32_t)ret_conv;
10255 }
10256
10257 typedef struct LDKCustomMessageReader_JCalls {
10258         atomic_size_t refcnt;
10259         uint32_t instance_ptr;
10260 } LDKCustomMessageReader_JCalls;
10261 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
10262         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10263         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10264                 FREE(j_calls);
10265         }
10266 }
10267 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
10268         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10269         int16_t message_type_conv = message_type;
10270         LDKu8slice buffer_var = buffer;
10271         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
10272         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
10273         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 83, (uint32_t)message_type_conv, (uint32_t)buffer_arr);
10274         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10275         CHECK_ACCESS(ret_ptr);
10276         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
10277         FREE((void*)ret);
10278         return ret_conv;
10279 }
10280 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
10281         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
10282         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10283 }
10284 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
10285         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
10286         atomic_init(&calls->refcnt, 1);
10287         calls->instance_ptr = o;
10288
10289         LDKCustomMessageReader ret = {
10290                 .this_arg = (void*) calls,
10291                 .read = read_LDKCustomMessageReader_jcall,
10292                 .free = LDKCustomMessageReader_JCalls_free,
10293         };
10294         return ret;
10295 }
10296 long  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
10297         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
10298         *res_ptr = LDKCustomMessageReader_init(o);
10299         return (long)res_ptr;
10300 }
10301 uint32_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
10302         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10303         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10304         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
10305         LDKu8slice buffer_ref;
10306         buffer_ref.datalen = buffer->arr_len;
10307         buffer_ref.data = buffer->elems;
10308         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10309         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
10310         FREE(buffer);
10311         return (uint32_t)ret_conv;
10312 }
10313
10314 typedef struct LDKCustomMessageHandler_JCalls {
10315         atomic_size_t refcnt;
10316         uint32_t instance_ptr;
10317         LDKCustomMessageReader_JCalls* CustomMessageReader;
10318 } LDKCustomMessageHandler_JCalls;
10319 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
10320         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10321         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10322                 FREE(j_calls);
10323         }
10324 }
10325 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
10326         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10327         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
10328         *msg_ret = msg;
10329         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
10330         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
10331         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);
10332         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10333         CHECK_ACCESS(ret_ptr);
10334         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10335         FREE((void*)ret);
10336         return ret_conv;
10337 }
10338 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
10339         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10340         uint32_tArray ret = (uint32_tArray)js_invoke_function_u_(j_calls->instance_ptr, 85);
10341         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
10342         ret_constr.datalen = ret->arr_len;
10343         if (ret_constr.datalen > 0)
10344                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
10345         else
10346                 ret_constr.data = NULL;
10347         uint32_t* ret_vals = ret->elems;
10348         for (size_t z = 0; z < ret_constr.datalen; z++) {
10349                 uint32_t ret_conv_25 = ret_vals[z];
10350                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
10351                 CHECK_ACCESS(ret_conv_25_ptr);
10352                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
10353                 FREE((void*)ret_conv_25);
10354                 ret_constr.data[z] = ret_conv_25_conv;
10355         }
10356         FREE(ret);
10357         return ret_constr;
10358 }
10359 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
10360         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
10361         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10362         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
10363 }
10364 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
10365         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
10366         atomic_init(&calls->refcnt, 1);
10367         calls->instance_ptr = o;
10368
10369         LDKCustomMessageHandler ret = {
10370                 .this_arg = (void*) calls,
10371                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
10372                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
10373                 .free = LDKCustomMessageHandler_JCalls_free,
10374                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
10375         };
10376         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
10377         return ret;
10378 }
10379 long  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
10380         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
10381         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
10382         return (long)res_ptr;
10383 }
10384 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) {
10385         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10386         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10387         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10388         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
10389         CHECK_ACCESS(msg_ptr);
10390         LDKType msg_conv = *(LDKType*)(msg_ptr);
10391         if (msg_conv.free == LDKType_JCalls_free) {
10392                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10393                 LDKType_JCalls_cloned(&msg_conv);
10394         }
10395         LDKPublicKey sender_node_id_ref;
10396         CHECK(sender_node_id->arr_len == 33);
10397         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
10398         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10399         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
10400         return (uint32_t)ret_conv;
10401 }
10402
10403 uint32_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
10404         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10405         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10406         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10407         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
10408         uint32_tArray ret_arr = NULL;
10409         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10410         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10411         for (size_t z = 0; z < ret_var.datalen; z++) {
10412                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10413                 *ret_conv_25_conv = ret_var.data[z];
10414                 ret_arr_ptr[z] = ((uint32_t)ret_conv_25_conv);
10415         }
10416         
10417         FREE(ret_var.data);
10418         return ret_arr;
10419 }
10420
10421 typedef struct LDKSocketDescriptor_JCalls {
10422         atomic_size_t refcnt;
10423         uint32_t instance_ptr;
10424 } LDKSocketDescriptor_JCalls;
10425 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
10426         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10427         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10428                 FREE(j_calls);
10429         }
10430 }
10431 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
10432         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10433         LDKu8slice data_var = data;
10434         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
10435         memcpy(data_arr->elems, data_var.data, data_var.datalen);
10436         jboolean resume_read_conv = resume_read;
10437         return js_invoke_function_u_uu(j_calls->instance_ptr, 86, (uint32_t)data_arr, (uint32_t)resume_read_conv);
10438 }
10439 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
10440         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10441         js_invoke_function_u_(j_calls->instance_ptr, 87);
10442 }
10443 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
10444         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10445         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10446         *other_arg_clone = SocketDescriptor_clone(other_arg);
10447         return js_invoke_function_u_u(j_calls->instance_ptr, 88, (uint32_t)(uint32_t)other_arg_clone);
10448 }
10449 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
10450         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10451         return js_invoke_function_b_(j_calls->instance_ptr, 89);
10452 }
10453 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
10454         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
10455         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10456 }
10457 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
10458         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
10459         atomic_init(&calls->refcnt, 1);
10460         calls->instance_ptr = o;
10461
10462         LDKSocketDescriptor ret = {
10463                 .this_arg = (void*) calls,
10464                 .send_data = send_data_LDKSocketDescriptor_jcall,
10465                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
10466                 .eq = eq_LDKSocketDescriptor_jcall,
10467                 .hash = hash_LDKSocketDescriptor_jcall,
10468                 .cloned = LDKSocketDescriptor_JCalls_cloned,
10469                 .free = LDKSocketDescriptor_JCalls_free,
10470         };
10471         return ret;
10472 }
10473 long  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
10474         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10475         *res_ptr = LDKSocketDescriptor_init(o);
10476         return (long)res_ptr;
10477 }
10478 uint32_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
10479         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10480         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10481         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10482         LDKu8slice data_ref;
10483         data_ref.datalen = data->arr_len;
10484         data_ref.data = data->elems;
10485         uint32_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
10486         FREE(data);
10487         return ret_conv;
10488 }
10489
10490 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
10491         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10492         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10493         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10494         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
10495 }
10496
10497 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
10498         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10499         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10500         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10501         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
10502         return ret_conv;
10503 }
10504
10505 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_ty_from_ptr"))) TS_LDKEffectiveCapacity_ty_from_ptr(uint32_t ptr) {
10506         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10507         switch(obj->tag) {
10508                 case LDKEffectiveCapacity_ExactLiquidity: return 0;
10509                 case LDKEffectiveCapacity_MaximumHTLC: return 1;
10510                 case LDKEffectiveCapacity_Total: return 2;
10511                 case LDKEffectiveCapacity_Infinite: return 3;
10512                 case LDKEffectiveCapacity_Unknown: return 4;
10513                 default: abort();
10514         }
10515 }
10516 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat"))) TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(uint32_t ptr) {
10517         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10518         assert(obj->tag == LDKEffectiveCapacity_ExactLiquidity);
10519                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
10520         return liquidity_msat_conv;
10521 }
10522 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat"))) TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat(uint32_t ptr) {
10523         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10524         assert(obj->tag == LDKEffectiveCapacity_MaximumHTLC);
10525                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
10526         return amount_msat_conv;
10527 }
10528 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_capacity_msat"))) TS_LDKEffectiveCapacity_Total_get_capacity_msat(uint32_t ptr) {
10529         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10530         assert(obj->tag == LDKEffectiveCapacity_Total);
10531                         int64_t capacity_msat_conv = obj->total.capacity_msat;
10532         return capacity_msat_conv;
10533 }
10534 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_htlc_maximum_msat"))) TS_LDKEffectiveCapacity_Total_get_htlc_maximum_msat(uint32_t ptr) {
10535         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10536         assert(obj->tag == LDKEffectiveCapacity_Total);
10537                         uint32_t htlc_maximum_msat_ref = ((uintptr_t)&obj->total.htlc_maximum_msat) | 1;
10538         return htlc_maximum_msat_ref;
10539 }
10540 typedef struct LDKLockableScore_JCalls {
10541         atomic_size_t refcnt;
10542         uint32_t instance_ptr;
10543 } LDKLockableScore_JCalls;
10544 static void LDKLockableScore_JCalls_free(void* this_arg) {
10545         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10546         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10547                 FREE(j_calls);
10548         }
10549 }
10550 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
10551         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10552         uint32_t ret = js_invoke_function_u_(j_calls->instance_ptr, 90);
10553         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10554         CHECK_ACCESS(ret_ptr);
10555         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
10556         if (ret_conv.free == LDKScore_JCalls_free) {
10557                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10558                 LDKScore_JCalls_cloned(&ret_conv);
10559         }// WARNING: we may need a move here but no clone is available for LDKScore
10560         
10561         return ret_conv;
10562 }
10563 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
10564         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
10565         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10566 }
10567 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
10568         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
10569         atomic_init(&calls->refcnt, 1);
10570         calls->instance_ptr = o;
10571
10572         LDKLockableScore ret = {
10573                 .this_arg = (void*) calls,
10574                 .lock = lock_LDKLockableScore_jcall,
10575                 .free = LDKLockableScore_JCalls_free,
10576         };
10577         return ret;
10578 }
10579 long  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
10580         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
10581         *res_ptr = LDKLockableScore_init(o);
10582         return (long)res_ptr;
10583 }
10584 uint32_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint32_t this_arg) {
10585         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10586         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10587         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
10588         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
10589         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
10590         return (uint32_t)ret_ret;
10591 }
10592
10593 uint32_t __attribute__((export_name("TS_LDKFallback_ty_from_ptr"))) TS_LDKFallback_ty_from_ptr(uint32_t ptr) {
10594         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10595         switch(obj->tag) {
10596                 case LDKFallback_SegWitProgram: return 0;
10597                 case LDKFallback_PubKeyHash: return 1;
10598                 case LDKFallback_ScriptHash: return 2;
10599                 default: abort();
10600         }
10601 }
10602 int8_t __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_version"))) TS_LDKFallback_SegWitProgram_get_version(uint32_t ptr) {
10603         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10604         assert(obj->tag == LDKFallback_SegWitProgram);
10605                         uint8_t version_val = obj->seg_wit_program.version._0;
10606         return version_val;
10607 }
10608 int8_tArray __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_program"))) TS_LDKFallback_SegWitProgram_get_program(uint32_t ptr) {
10609         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10610         assert(obj->tag == LDKFallback_SegWitProgram);
10611                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10612                         int8_tArray program_arr = init_int8_tArray(program_var.datalen, __LINE__);
10613                         memcpy(program_arr->elems, program_var.data, program_var.datalen);
10614         return program_arr;
10615 }
10616 int8_tArray __attribute__((export_name("TS_LDKFallback_PubKeyHash_get_pub_key_hash"))) TS_LDKFallback_PubKeyHash_get_pub_key_hash(uint32_t ptr) {
10617         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10618         assert(obj->tag == LDKFallback_PubKeyHash);
10619                         int8_tArray pub_key_hash_arr = init_int8_tArray(20, __LINE__);
10620                         memcpy(pub_key_hash_arr->elems, obj->pub_key_hash.data, 20);
10621         return pub_key_hash_arr;
10622 }
10623 int8_tArray __attribute__((export_name("TS_LDKFallback_ScriptHash_get_script_hash"))) TS_LDKFallback_ScriptHash_get_script_hash(uint32_t ptr) {
10624         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10625         assert(obj->tag == LDKFallback_ScriptHash);
10626                         int8_tArray script_hash_arr = init_int8_tArray(20, __LINE__);
10627                         memcpy(script_hash_arr->elems, obj->script_hash.data, 20);
10628         return script_hash_arr;
10629 }
10630 typedef struct LDKPayer_JCalls {
10631         atomic_size_t refcnt;
10632         uint32_t instance_ptr;
10633 } LDKPayer_JCalls;
10634 static void LDKPayer_JCalls_free(void* this_arg) {
10635         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10636         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10637                 FREE(j_calls);
10638         }
10639 }
10640 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
10641         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10642         int8_tArray ret = (int8_tArray)js_invoke_function_u_(j_calls->instance_ptr, 91);
10643         LDKPublicKey ret_ref;
10644         CHECK(ret->arr_len == 33);
10645         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
10646         return ret_ref;
10647 }
10648 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
10649         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10650         uint32_tArray ret = (uint32_tArray)js_invoke_function_u_(j_calls->instance_ptr, 92);
10651         LDKCVec_ChannelDetailsZ ret_constr;
10652         ret_constr.datalen = ret->arr_len;
10653         if (ret_constr.datalen > 0)
10654                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10655         else
10656                 ret_constr.data = NULL;
10657         uint32_t* ret_vals = ret->elems;
10658         for (size_t q = 0; q < ret_constr.datalen; q++) {
10659                 uint32_t ret_conv_16 = ret_vals[q];
10660                 LDKChannelDetails ret_conv_16_conv;
10661                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
10662                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
10663                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
10664                 ret_constr.data[q] = ret_conv_16_conv;
10665         }
10666         FREE(ret);
10667         return ret_constr;
10668 }
10669 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
10670         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10671         LDKRoute route_var = *route;
10672         uint32_t route_ref = 0;
10673         route_var = Route_clone(&route_var);
10674         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10675         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10676         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10677         route_ref = (uintptr_t)route_var.inner;
10678         if (route_var.is_owned) {
10679                 route_ref |= 1;
10680         }
10681         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10682         memcpy(payment_hash_arr->elems, payment_hash.data, 32);
10683         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
10684         memcpy(payment_secret_arr->elems, payment_secret.data, 32);
10685         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);
10686         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10687         CHECK_ACCESS(ret_ptr);
10688         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10689         FREE((void*)ret);
10690         return ret_conv;
10691 }
10692 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
10693         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10694         LDKRoute route_var = *route;
10695         uint32_t route_ref = 0;
10696         route_var = Route_clone(&route_var);
10697         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10698         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10699         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10700         route_ref = (uintptr_t)route_var.inner;
10701         if (route_var.is_owned) {
10702                 route_ref |= 1;
10703         }
10704         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
10705         memcpy(payment_preimage_arr->elems, payment_preimage.data, 32);
10706         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 94, (uint32_t)route_ref, (uint32_t)payment_preimage_arr);
10707         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10708         CHECK_ACCESS(ret_ptr);
10709         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10710         FREE((void*)ret);
10711         return ret_conv;
10712 }
10713 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
10714         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10715         LDKRoute route_var = *route;
10716         uint32_t route_ref = 0;
10717         route_var = Route_clone(&route_var);
10718         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10719         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10720         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10721         route_ref = (uintptr_t)route_var.inner;
10722         if (route_var.is_owned) {
10723                 route_ref |= 1;
10724         }
10725         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10726         memcpy(payment_id_arr->elems, payment_id.data, 32);
10727         uint32_t ret = js_invoke_function_u_uu(j_calls->instance_ptr, 95, (uint32_t)route_ref, (uint32_t)payment_id_arr);
10728         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10729         CHECK_ACCESS(ret_ptr);
10730         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
10731         FREE((void*)ret);
10732         return ret_conv;
10733 }
10734 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
10735         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10736         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10737         memcpy(payment_id_arr->elems, payment_id.data, 32);
10738         js_invoke_function_u_u(j_calls->instance_ptr, 96, (uint32_t)payment_id_arr);
10739 }
10740 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
10741         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
10742         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10743 }
10744 static inline LDKPayer LDKPayer_init (JSValue o) {
10745         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
10746         atomic_init(&calls->refcnt, 1);
10747         calls->instance_ptr = o;
10748
10749         LDKPayer ret = {
10750                 .this_arg = (void*) calls,
10751                 .node_id = node_id_LDKPayer_jcall,
10752                 .first_hops = first_hops_LDKPayer_jcall,
10753                 .send_payment = send_payment_LDKPayer_jcall,
10754                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
10755                 .retry_payment = retry_payment_LDKPayer_jcall,
10756                 .abandon_payment = abandon_payment_LDKPayer_jcall,
10757                 .free = LDKPayer_JCalls_free,
10758         };
10759         return ret;
10760 }
10761 long  __attribute__((export_name("TS_LDKPayer_new"))) TS_LDKPayer_new(JSValue o) {
10762         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
10763         *res_ptr = LDKPayer_init(o);
10764         return (long)res_ptr;
10765 }
10766 int8_tArray  __attribute__((export_name("TS_Payer_node_id"))) TS_Payer_node_id(uint32_t this_arg) {
10767         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10768         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10769         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10770         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
10771         memcpy(ret_arr->elems, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
10772         return ret_arr;
10773 }
10774
10775 uint32_tArray  __attribute__((export_name("TS_Payer_first_hops"))) TS_Payer_first_hops(uint32_t this_arg) {
10776         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10777         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10778         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10779         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
10780         uint32_tArray ret_arr = NULL;
10781         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10782         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10783         for (size_t q = 0; q < ret_var.datalen; q++) {
10784                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10785                 uint32_t ret_conv_16_ref = 0;
10786                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10787                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10788                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
10789                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
10790                 if (ret_conv_16_var.is_owned) {
10791                         ret_conv_16_ref |= 1;
10792                 }
10793                 ret_arr_ptr[q] = ret_conv_16_ref;
10794         }
10795         
10796         FREE(ret_var.data);
10797         return ret_arr;
10798 }
10799
10800 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) {
10801         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10802         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10803         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10804         LDKRoute route_conv;
10805         route_conv.inner = (void*)(route & (~1));
10806         route_conv.is_owned = false;
10807         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10808         LDKThirtyTwoBytes payment_hash_ref;
10809         CHECK(payment_hash->arr_len == 32);
10810         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
10811         LDKThirtyTwoBytes payment_secret_ref;
10812         CHECK(payment_secret->arr_len == 32);
10813         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
10814         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10815         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
10816         return (uint32_t)ret_conv;
10817 }
10818
10819 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) {
10820         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10821         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10822         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10823         LDKRoute route_conv;
10824         route_conv.inner = (void*)(route & (~1));
10825         route_conv.is_owned = false;
10826         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10827         LDKThirtyTwoBytes payment_preimage_ref;
10828         CHECK(payment_preimage->arr_len == 32);
10829         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
10830         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10831         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
10832         return (uint32_t)ret_conv;
10833 }
10834
10835 uint32_t  __attribute__((export_name("TS_Payer_retry_payment"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
10836         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10837         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10838         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10839         LDKRoute route_conv;
10840         route_conv.inner = (void*)(route & (~1));
10841         route_conv.is_owned = false;
10842         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10843         LDKThirtyTwoBytes payment_id_ref;
10844         CHECK(payment_id->arr_len == 32);
10845         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10846         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10847         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
10848         return (uint32_t)ret_conv;
10849 }
10850
10851 void  __attribute__((export_name("TS_Payer_abandon_payment"))) TS_Payer_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
10852         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10853         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10854         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10855         LDKThirtyTwoBytes payment_id_ref;
10856         CHECK(payment_id->arr_len == 32);
10857         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10858         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
10859 }
10860
10861 typedef struct LDKRouter_JCalls {
10862         atomic_size_t refcnt;
10863         uint32_t instance_ptr;
10864 } LDKRouter_JCalls;
10865 static void LDKRouter_JCalls_free(void* this_arg) {
10866         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10867         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10868                 FREE(j_calls);
10869         }
10870 }
10871 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) {
10872         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10873         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
10874         memcpy(payer_arr->elems, payer.compressed_form, 33);
10875         LDKRouteParameters route_params_var = *route_params;
10876         uint32_t route_params_ref = 0;
10877         route_params_var = RouteParameters_clone(&route_params_var);
10878         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10879         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10880         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
10881         route_params_ref = (uintptr_t)route_params_var.inner;
10882         if (route_params_var.is_owned) {
10883                 route_params_ref |= 1;
10884         }
10885         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10886         memcpy(payment_hash_arr->elems, *payment_hash, 32);
10887         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
10888         uint32_tArray first_hops_arr = NULL;
10889         if (first_hops != NULL) {
10890                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
10891                 first_hops_arr = init_uint32_tArray(first_hops_var.datalen, __LINE__);
10892                 uint32_t *first_hops_arr_ptr = (uint32_t*)(((uint8_t*)first_hops_arr) + 4);
10893                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
10894                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
10895                         uint32_t first_hops_conv_16_ref = 0;
10896                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10897                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10898                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
10899                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
10900                         if (first_hops_conv_16_var.is_owned) {
10901                                 first_hops_conv_16_ref |= 1;
10902                         }
10903                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
10904                 }
10905         
10906         }
10907         // WARNING: This object doesn't live past this scope, needs clone!
10908         uint32_t ret_scorer = ((uintptr_t)scorer) | 1;
10909         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);
10910         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10911         CHECK_ACCESS(ret_ptr);
10912         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
10913         FREE((void*)ret);
10914         return ret_conv;
10915 }
10916 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
10917         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
10918         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10919 }
10920 static inline LDKRouter LDKRouter_init (JSValue o) {
10921         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
10922         atomic_init(&calls->refcnt, 1);
10923         calls->instance_ptr = o;
10924
10925         LDKRouter ret = {
10926                 .this_arg = (void*) calls,
10927                 .find_route = find_route_LDKRouter_jcall,
10928                 .free = LDKRouter_JCalls_free,
10929         };
10930         return ret;
10931 }
10932 long  __attribute__((export_name("TS_LDKRouter_new"))) TS_LDKRouter_new(JSValue o) {
10933         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
10934         *res_ptr = LDKRouter_init(o);
10935         return (long)res_ptr;
10936 }
10937 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) {
10938         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10939         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10940         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
10941         LDKPublicKey payer_ref;
10942         CHECK(payer->arr_len == 33);
10943         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
10944         LDKRouteParameters route_params_conv;
10945         route_params_conv.inner = (void*)(route_params & (~1));
10946         route_params_conv.is_owned = false;
10947         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
10948         unsigned char payment_hash_arr[32];
10949         CHECK(payment_hash->arr_len == 32);
10950         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
10951         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
10952         LDKCVec_ChannelDetailsZ first_hops_constr;
10953         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
10954         if (first_hops != 0) {
10955                 first_hops_constr.datalen = first_hops->arr_len;
10956                 if (first_hops_constr.datalen > 0)
10957                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10958                 else
10959                         first_hops_constr.data = NULL;
10960                 uint32_t* first_hops_vals = first_hops->elems;
10961                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
10962                         uint32_t first_hops_conv_16 = first_hops_vals[q];
10963                         LDKChannelDetails first_hops_conv_16_conv;
10964                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
10965                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
10966                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
10967                         first_hops_constr.data[q] = first_hops_conv_16_conv;
10968                 }
10969                 FREE(first_hops);
10970                 first_hops_ptr = &first_hops_constr;
10971         }
10972         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
10973         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
10974         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
10975         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
10976         *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);
10977         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
10978         return (uint32_t)ret_conv;
10979 }
10980
10981 uint32_t __attribute__((export_name("TS_LDKRetry_ty_from_ptr"))) TS_LDKRetry_ty_from_ptr(uint32_t ptr) {
10982         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
10983         switch(obj->tag) {
10984                 case LDKRetry_Attempts: return 0;
10985                 default: abort();
10986         }
10987 }
10988 uint32_t __attribute__((export_name("TS_LDKRetry_Attempts_get_attempts"))) TS_LDKRetry_Attempts_get_attempts(uint32_t ptr) {
10989         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
10990         assert(obj->tag == LDKRetry_Attempts);
10991                         uint32_t attempts_conv = obj->attempts;
10992         return attempts_conv;
10993 }
10994 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
10995         LDKStr ret_str = _ldk_get_compiled_version();
10996         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10997         Str_free(ret_str);
10998         return ret_conv;
10999 }
11000
11001 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
11002         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
11003         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
11004         Str_free(ret_str);
11005         return ret_conv;
11006 }
11007
11008 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
11009         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
11010         *ret_copy = Bech32Error_clone(arg);
11011 uint32_t ret_ref = (uintptr_t)ret_copy;
11012         return ret_ref;
11013 }
11014 uint32_t  __attribute__((export_name("TS_Bech32Error_clone_ptr"))) TS_Bech32Error_clone_ptr(uint32_t arg) {
11015         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
11016         uint32_t ret_conv = Bech32Error_clone_ptr(arg_conv);
11017         return ret_conv;
11018 }
11019
11020 uint32_t  __attribute__((export_name("TS_Bech32Error_clone"))) TS_Bech32Error_clone(uint32_t orig) {
11021         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
11022         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
11023         *ret_copy = Bech32Error_clone(orig_conv);
11024         uint32_t ret_ref = (uintptr_t)ret_copy;
11025         return ret_ref;
11026 }
11027
11028 void  __attribute__((export_name("TS_Bech32Error_free"))) TS_Bech32Error_free(uint32_t o) {
11029         if ((o & 1) != 0) return;
11030         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
11031         CHECK_ACCESS(o_ptr);
11032         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
11033         FREE((void*)o);
11034         Bech32Error_free(o_conv);
11035 }
11036
11037 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
11038         LDKTransaction _res_ref;
11039         _res_ref.datalen = _res->arr_len;
11040         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
11041         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
11042         _res_ref.data_is_owned = true;
11043         Transaction_free(_res_ref);
11044 }
11045
11046 uint32_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
11047         LDKCVec_u8Z script_pubkey_ref;
11048         script_pubkey_ref.datalen = script_pubkey->arr_len;
11049         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
11050         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
11051         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11052         *ret_ref = TxOut_new(script_pubkey_ref, value);
11053         return (uint32_t)ret_ref;
11054 }
11055
11056 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint32_t _res) {
11057         if ((_res & 1) != 0) return;
11058         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11059         CHECK_ACCESS(_res_ptr);
11060         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
11061         FREE((void*)_res);
11062         TxOut_free(_res_conv);
11063 }
11064
11065 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
11066         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11067         *ret_ref = TxOut_clone(arg);
11068         return (uint32_t)ret_ref;
11069 }
11070 uint32_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint32_t arg) {
11071         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
11072         uint32_t ret_conv = TxOut_clone_ptr(arg_conv);
11073         return ret_conv;
11074 }
11075
11076 uint32_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint32_t orig) {
11077         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
11078         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11079         *ret_ref = TxOut_clone(orig_conv);
11080         return (uint32_t)ret_ref;
11081 }
11082
11083 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
11084         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
11085         Str_free(dummy);
11086 }
11087
11088 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
11089         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11090         *ret_conv = CResult_NoneNoneZ_ok();
11091         return (uint32_t)ret_conv;
11092 }
11093
11094 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
11095         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11096         *ret_conv = CResult_NoneNoneZ_err();
11097         return (uint32_t)ret_conv;
11098 }
11099
11100 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
11101         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
11102         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
11103         return ret_conv;
11104 }
11105
11106 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
11107         if ((_res & 1) != 0) return;
11108         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11109         CHECK_ACCESS(_res_ptr);
11110         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
11111         FREE((void*)_res);
11112         CResult_NoneNoneZ_free(_res_conv);
11113 }
11114
11115 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
11116         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11117         *ret_conv = CResult_NoneNoneZ_clone(arg);
11118         return (uint32_t)ret_conv;
11119 }
11120 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
11121         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
11122         uint32_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
11123         return ret_conv;
11124 }
11125
11126 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
11127         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
11128         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11129         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
11130         return (uint32_t)ret_conv;
11131 }
11132
11133 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(uint32_t o) {
11134         LDKCounterpartyCommitmentSecrets o_conv;
11135         o_conv.inner = (void*)(o & (~1));
11136         o_conv.is_owned = (o & 1) || (o == 0);
11137         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11138         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
11139         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11140         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
11141         return (uint32_t)ret_conv;
11142 }
11143
11144 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(uint32_t e) {
11145         LDKDecodeError e_conv;
11146         e_conv.inner = (void*)(e & (~1));
11147         e_conv.is_owned = (e & 1) || (e == 0);
11148         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11149         e_conv = DecodeError_clone(&e_conv);
11150         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11151         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
11152         return (uint32_t)ret_conv;
11153 }
11154
11155 jboolean  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(uint32_t o) {
11156         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
11157         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
11158         return ret_conv;
11159 }
11160
11161 void  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(uint32_t _res) {
11162         if ((_res & 1) != 0) return;
11163         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11164         CHECK_ACCESS(_res_ptr);
11165         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
11166         FREE((void*)_res);
11167         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
11168 }
11169
11170 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
11171         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11172         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
11173         return (uint32_t)ret_conv;
11174 }
11175 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(uint32_t arg) {
11176         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
11177         uint32_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
11178         return ret_conv;
11179 }
11180
11181 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(uint32_t orig) {
11182         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
11183         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11184         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
11185         return (uint32_t)ret_conv;
11186 }
11187
11188 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
11189         LDKSecretKey o_ref;
11190         CHECK(o->arr_len == 32);
11191         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
11192         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11193         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
11194         return (uint32_t)ret_conv;
11195 }
11196
11197 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
11198         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11199         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11200         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
11201         return (uint32_t)ret_conv;
11202 }
11203
11204 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
11205         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
11206         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
11207         return ret_conv;
11208 }
11209
11210 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
11211         if ((_res & 1) != 0) return;
11212         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11213         CHECK_ACCESS(_res_ptr);
11214         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
11215         FREE((void*)_res);
11216         CResult_SecretKeyErrorZ_free(_res_conv);
11217 }
11218
11219 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
11220         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11221         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
11222         return (uint32_t)ret_conv;
11223 }
11224 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone_ptr"))) TS_CResult_SecretKeyErrorZ_clone_ptr(uint32_t arg) {
11225         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
11226         uint32_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
11227         return ret_conv;
11228 }
11229
11230 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone"))) TS_CResult_SecretKeyErrorZ_clone(uint32_t orig) {
11231         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
11232         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11233         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
11234         return (uint32_t)ret_conv;
11235 }
11236
11237 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
11238         LDKPublicKey o_ref;
11239         CHECK(o->arr_len == 33);
11240         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
11241         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11242         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
11243         return (uint32_t)ret_conv;
11244 }
11245
11246 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
11247         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11248         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11249         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
11250         return (uint32_t)ret_conv;
11251 }
11252
11253 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
11254         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
11255         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
11256         return ret_conv;
11257 }
11258
11259 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
11260         if ((_res & 1) != 0) return;
11261         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11262         CHECK_ACCESS(_res_ptr);
11263         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
11264         FREE((void*)_res);
11265         CResult_PublicKeyErrorZ_free(_res_conv);
11266 }
11267
11268 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
11269         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11270         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
11271         return (uint32_t)ret_conv;
11272 }
11273 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
11274         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
11275         uint32_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
11276         return ret_conv;
11277 }
11278
11279 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
11280         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
11281         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11282         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
11283         return (uint32_t)ret_conv;
11284 }
11285
11286 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
11287         LDKTxCreationKeys o_conv;
11288         o_conv.inner = (void*)(o & (~1));
11289         o_conv.is_owned = (o & 1) || (o == 0);
11290         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11291         o_conv = TxCreationKeys_clone(&o_conv);
11292         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11293         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
11294         return (uint32_t)ret_conv;
11295 }
11296
11297 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
11298         LDKDecodeError e_conv;
11299         e_conv.inner = (void*)(e & (~1));
11300         e_conv.is_owned = (e & 1) || (e == 0);
11301         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11302         e_conv = DecodeError_clone(&e_conv);
11303         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11304         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
11305         return (uint32_t)ret_conv;
11306 }
11307
11308 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
11309         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
11310         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
11311         return ret_conv;
11312 }
11313
11314 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
11315         if ((_res & 1) != 0) return;
11316         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11317         CHECK_ACCESS(_res_ptr);
11318         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
11319         FREE((void*)_res);
11320         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
11321 }
11322
11323 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
11324         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11325         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
11326         return (uint32_t)ret_conv;
11327 }
11328 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
11329         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
11330         uint32_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
11331         return ret_conv;
11332 }
11333
11334 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
11335         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
11336         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11337         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
11338         return (uint32_t)ret_conv;
11339 }
11340
11341 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
11342         LDKChannelPublicKeys o_conv;
11343         o_conv.inner = (void*)(o & (~1));
11344         o_conv.is_owned = (o & 1) || (o == 0);
11345         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11346         o_conv = ChannelPublicKeys_clone(&o_conv);
11347         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11348         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
11349         return (uint32_t)ret_conv;
11350 }
11351
11352 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
11353         LDKDecodeError e_conv;
11354         e_conv.inner = (void*)(e & (~1));
11355         e_conv.is_owned = (e & 1) || (e == 0);
11356         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11357         e_conv = DecodeError_clone(&e_conv);
11358         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11359         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
11360         return (uint32_t)ret_conv;
11361 }
11362
11363 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
11364         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
11365         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
11366         return ret_conv;
11367 }
11368
11369 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
11370         if ((_res & 1) != 0) return;
11371         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11372         CHECK_ACCESS(_res_ptr);
11373         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
11374         FREE((void*)_res);
11375         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
11376 }
11377
11378 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
11379         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11380         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
11381         return (uint32_t)ret_conv;
11382 }
11383 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
11384         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
11385         uint32_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
11386         return ret_conv;
11387 }
11388
11389 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
11390         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
11391         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11392         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
11393         return (uint32_t)ret_conv;
11394 }
11395
11396 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
11397         LDKTxCreationKeys o_conv;
11398         o_conv.inner = (void*)(o & (~1));
11399         o_conv.is_owned = (o & 1) || (o == 0);
11400         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11401         o_conv = TxCreationKeys_clone(&o_conv);
11402         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11403         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
11404         return (uint32_t)ret_conv;
11405 }
11406
11407 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
11408         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11409         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11410         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
11411         return (uint32_t)ret_conv;
11412 }
11413
11414 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
11415         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
11416         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
11417         return ret_conv;
11418 }
11419
11420 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
11421         if ((_res & 1) != 0) return;
11422         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11423         CHECK_ACCESS(_res_ptr);
11424         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
11425         FREE((void*)_res);
11426         CResult_TxCreationKeysErrorZ_free(_res_conv);
11427 }
11428
11429 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
11430         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11431         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
11432         return (uint32_t)ret_conv;
11433 }
11434 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
11435         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
11436         uint32_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
11437         return ret_conv;
11438 }
11439
11440 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
11441         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
11442         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11443         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
11444         return (uint32_t)ret_conv;
11445 }
11446
11447 uint32_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
11448         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11449         *ret_copy = COption_u32Z_some(o);
11450         uint32_t ret_ref = (uintptr_t)ret_copy;
11451         return ret_ref;
11452 }
11453
11454 uint32_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
11455         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11456         *ret_copy = COption_u32Z_none();
11457         uint32_t ret_ref = (uintptr_t)ret_copy;
11458         return ret_ref;
11459 }
11460
11461 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint32_t _res) {
11462         if ((_res & 1) != 0) return;
11463         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11464         CHECK_ACCESS(_res_ptr);
11465         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
11466         FREE((void*)_res);
11467         COption_u32Z_free(_res_conv);
11468 }
11469
11470 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
11471         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11472         *ret_copy = COption_u32Z_clone(arg);
11473 uint32_t ret_ref = (uintptr_t)ret_copy;
11474         return ret_ref;
11475 }
11476 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
11477         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
11478         uint32_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
11479         return ret_conv;
11480 }
11481
11482 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint32_t orig) {
11483         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
11484         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11485         *ret_copy = COption_u32Z_clone(orig_conv);
11486         uint32_t ret_ref = (uintptr_t)ret_copy;
11487         return ret_ref;
11488 }
11489
11490 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
11491         LDKHTLCOutputInCommitment o_conv;
11492         o_conv.inner = (void*)(o & (~1));
11493         o_conv.is_owned = (o & 1) || (o == 0);
11494         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11495         o_conv = HTLCOutputInCommitment_clone(&o_conv);
11496         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11497         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
11498         return (uint32_t)ret_conv;
11499 }
11500
11501 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
11502         LDKDecodeError e_conv;
11503         e_conv.inner = (void*)(e & (~1));
11504         e_conv.is_owned = (e & 1) || (e == 0);
11505         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11506         e_conv = DecodeError_clone(&e_conv);
11507         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11508         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
11509         return (uint32_t)ret_conv;
11510 }
11511
11512 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
11513         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
11514         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
11515         return ret_conv;
11516 }
11517
11518 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
11519         if ((_res & 1) != 0) return;
11520         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11521         CHECK_ACCESS(_res_ptr);
11522         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
11523         FREE((void*)_res);
11524         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
11525 }
11526
11527 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
11528         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11529         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
11530         return (uint32_t)ret_conv;
11531 }
11532 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
11533         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
11534         uint32_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
11535         return ret_conv;
11536 }
11537
11538 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
11539         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
11540         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11541         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
11542         return (uint32_t)ret_conv;
11543 }
11544
11545 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
11546         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
11547         return ret_conv;
11548 }
11549
11550 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
11551         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
11552         return ret_conv;
11553 }
11554
11555 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
11556         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
11557         COption_NoneZ_free(_res_conv);
11558 }
11559
11560 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11561         LDKCounterpartyChannelTransactionParameters o_conv;
11562         o_conv.inner = (void*)(o & (~1));
11563         o_conv.is_owned = (o & 1) || (o == 0);
11564         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11565         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
11566         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11567         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11568         return (uint32_t)ret_conv;
11569 }
11570
11571 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11572         LDKDecodeError e_conv;
11573         e_conv.inner = (void*)(e & (~1));
11574         e_conv.is_owned = (e & 1) || (e == 0);
11575         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11576         e_conv = DecodeError_clone(&e_conv);
11577         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11578         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
11579         return (uint32_t)ret_conv;
11580 }
11581
11582 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11583         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11584         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11585         return ret_conv;
11586 }
11587
11588 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11589         if ((_res & 1) != 0) return;
11590         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11591         CHECK_ACCESS(_res_ptr);
11592         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11593         FREE((void*)_res);
11594         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11595 }
11596
11597 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11598         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11599         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
11600         return (uint32_t)ret_conv;
11601 }
11602 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11603         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11604         uint32_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11605         return ret_conv;
11606 }
11607
11608 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11609         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11610         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11611         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11612         return (uint32_t)ret_conv;
11613 }
11614
11615 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11616         LDKChannelTransactionParameters o_conv;
11617         o_conv.inner = (void*)(o & (~1));
11618         o_conv.is_owned = (o & 1) || (o == 0);
11619         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11620         o_conv = ChannelTransactionParameters_clone(&o_conv);
11621         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11622         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11623         return (uint32_t)ret_conv;
11624 }
11625
11626 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11627         LDKDecodeError e_conv;
11628         e_conv.inner = (void*)(e & (~1));
11629         e_conv.is_owned = (e & 1) || (e == 0);
11630         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11631         e_conv = DecodeError_clone(&e_conv);
11632         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11633         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
11634         return (uint32_t)ret_conv;
11635 }
11636
11637 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11638         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11639         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11640         return ret_conv;
11641 }
11642
11643 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11644         if ((_res & 1) != 0) return;
11645         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11646         CHECK_ACCESS(_res_ptr);
11647         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11648         FREE((void*)_res);
11649         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11650 }
11651
11652 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11653         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11654         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
11655         return (uint32_t)ret_conv;
11656 }
11657 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11658         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11659         uint32_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11660         return ret_conv;
11661 }
11662
11663 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11664         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11665         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11666         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11667         return (uint32_t)ret_conv;
11668 }
11669
11670 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
11671         LDKCVec_SignatureZ _res_constr;
11672         _res_constr.datalen = _res->arr_len;
11673         if (_res_constr.datalen > 0)
11674                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11675         else
11676                 _res_constr.data = NULL;
11677         int8_tArray* _res_vals = (void*) _res->elems;
11678         for (size_t m = 0; m < _res_constr.datalen; m++) {
11679                 int8_tArray _res_conv_12 = _res_vals[m];
11680                 LDKSignature _res_conv_12_ref;
11681                 CHECK(_res_conv_12->arr_len == 64);
11682                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64); FREE(_res_conv_12);
11683                 _res_constr.data[m] = _res_conv_12_ref;
11684         }
11685         FREE(_res);
11686         CVec_SignatureZ_free(_res_constr);
11687 }
11688
11689 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11690         LDKHolderCommitmentTransaction o_conv;
11691         o_conv.inner = (void*)(o & (~1));
11692         o_conv.is_owned = (o & 1) || (o == 0);
11693         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11694         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11695         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11696         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11697         return (uint32_t)ret_conv;
11698 }
11699
11700 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11701         LDKDecodeError e_conv;
11702         e_conv.inner = (void*)(e & (~1));
11703         e_conv.is_owned = (e & 1) || (e == 0);
11704         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11705         e_conv = DecodeError_clone(&e_conv);
11706         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11707         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11708         return (uint32_t)ret_conv;
11709 }
11710
11711 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11712         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
11713         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11714         return ret_conv;
11715 }
11716
11717 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11718         if ((_res & 1) != 0) return;
11719         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11720         CHECK_ACCESS(_res_ptr);
11721         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11722         FREE((void*)_res);
11723         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
11724 }
11725
11726 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11727         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11728         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
11729         return (uint32_t)ret_conv;
11730 }
11731 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11732         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11733         uint32_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11734         return ret_conv;
11735 }
11736
11737 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11738         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11739         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11740         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11741         return (uint32_t)ret_conv;
11742 }
11743
11744 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11745         LDKBuiltCommitmentTransaction o_conv;
11746         o_conv.inner = (void*)(o & (~1));
11747         o_conv.is_owned = (o & 1) || (o == 0);
11748         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11749         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
11750         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11751         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
11752         return (uint32_t)ret_conv;
11753 }
11754
11755 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11756         LDKDecodeError e_conv;
11757         e_conv.inner = (void*)(e & (~1));
11758         e_conv.is_owned = (e & 1) || (e == 0);
11759         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11760         e_conv = DecodeError_clone(&e_conv);
11761         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11762         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
11763         return (uint32_t)ret_conv;
11764 }
11765
11766 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11767         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
11768         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11769         return ret_conv;
11770 }
11771
11772 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11773         if ((_res & 1) != 0) return;
11774         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11775         CHECK_ACCESS(_res_ptr);
11776         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11777         FREE((void*)_res);
11778         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
11779 }
11780
11781 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11782         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11783         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
11784         return (uint32_t)ret_conv;
11785 }
11786 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11787         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11788         uint32_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11789         return ret_conv;
11790 }
11791
11792 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11793         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11794         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11795         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11796         return (uint32_t)ret_conv;
11797 }
11798
11799 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
11800         LDKTrustedClosingTransaction o_conv;
11801         o_conv.inner = (void*)(o & (~1));
11802         o_conv.is_owned = (o & 1) || (o == 0);
11803         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11804         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
11805         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11806         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
11807         return (uint32_t)ret_conv;
11808 }
11809
11810 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
11811         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11812         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
11813         return (uint32_t)ret_conv;
11814 }
11815
11816 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
11817         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
11818         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
11819         return ret_conv;
11820 }
11821
11822 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
11823         if ((_res & 1) != 0) return;
11824         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11825         CHECK_ACCESS(_res_ptr);
11826         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
11827         FREE((void*)_res);
11828         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
11829 }
11830
11831 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11832         LDKCommitmentTransaction o_conv;
11833         o_conv.inner = (void*)(o & (~1));
11834         o_conv.is_owned = (o & 1) || (o == 0);
11835         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11836         o_conv = CommitmentTransaction_clone(&o_conv);
11837         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11838         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
11839         return (uint32_t)ret_conv;
11840 }
11841
11842 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11843         LDKDecodeError e_conv;
11844         e_conv.inner = (void*)(e & (~1));
11845         e_conv.is_owned = (e & 1) || (e == 0);
11846         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11847         e_conv = DecodeError_clone(&e_conv);
11848         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11849         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
11850         return (uint32_t)ret_conv;
11851 }
11852
11853 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11854         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
11855         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11856         return ret_conv;
11857 }
11858
11859 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11860         if ((_res & 1) != 0) return;
11861         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11862         CHECK_ACCESS(_res_ptr);
11863         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
11864         FREE((void*)_res);
11865         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
11866 }
11867
11868 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11869         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11870         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
11871         return (uint32_t)ret_conv;
11872 }
11873 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11874         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
11875         uint32_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11876         return ret_conv;
11877 }
11878
11879 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11880         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
11881         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11882         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
11883         return (uint32_t)ret_conv;
11884 }
11885
11886 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
11887         LDKTrustedCommitmentTransaction o_conv;
11888         o_conv.inner = (void*)(o & (~1));
11889         o_conv.is_owned = (o & 1) || (o == 0);
11890         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11891         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
11892         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11893         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
11894         return (uint32_t)ret_conv;
11895 }
11896
11897 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
11898         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11899         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
11900         return (uint32_t)ret_conv;
11901 }
11902
11903 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
11904         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
11905         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
11906         return ret_conv;
11907 }
11908
11909 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
11910         if ((_res & 1) != 0) return;
11911         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11912         CHECK_ACCESS(_res_ptr);
11913         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
11914         FREE((void*)_res);
11915         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
11916 }
11917
11918 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
11919         LDKCVec_SignatureZ o_constr;
11920         o_constr.datalen = o->arr_len;
11921         if (o_constr.datalen > 0)
11922                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11923         else
11924                 o_constr.data = NULL;
11925         int8_tArray* o_vals = (void*) o->elems;
11926         for (size_t m = 0; m < o_constr.datalen; m++) {
11927                 int8_tArray o_conv_12 = o_vals[m];
11928                 LDKSignature o_conv_12_ref;
11929                 CHECK(o_conv_12->arr_len == 64);
11930                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64); FREE(o_conv_12);
11931                 o_constr.data[m] = o_conv_12_ref;
11932         }
11933         FREE(o);
11934         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11935         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
11936         return (uint32_t)ret_conv;
11937 }
11938
11939 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
11940         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11941         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
11942         return (uint32_t)ret_conv;
11943 }
11944
11945 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
11946         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
11947         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
11948         return ret_conv;
11949 }
11950
11951 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
11952         if ((_res & 1) != 0) return;
11953         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11954         CHECK_ACCESS(_res_ptr);
11955         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
11956         FREE((void*)_res);
11957         CResult_CVec_SignatureZNoneZ_free(_res_conv);
11958 }
11959
11960 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
11961         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11962         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
11963         return (uint32_t)ret_conv;
11964 }
11965 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
11966         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
11967         uint32_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
11968         return ret_conv;
11969 }
11970
11971 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
11972         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
11973         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11974         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
11975         return (uint32_t)ret_conv;
11976 }
11977
11978 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
11979         LDKShutdownScript o_conv;
11980         o_conv.inner = (void*)(o & (~1));
11981         o_conv.is_owned = (o & 1) || (o == 0);
11982         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11983         o_conv = ShutdownScript_clone(&o_conv);
11984         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11985         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
11986         return (uint32_t)ret_conv;
11987 }
11988
11989 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
11990         LDKDecodeError e_conv;
11991         e_conv.inner = (void*)(e & (~1));
11992         e_conv.is_owned = (e & 1) || (e == 0);
11993         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11994         e_conv = DecodeError_clone(&e_conv);
11995         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11996         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
11997         return (uint32_t)ret_conv;
11998 }
11999
12000 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
12001         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
12002         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
12003         return ret_conv;
12004 }
12005
12006 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
12007         if ((_res & 1) != 0) return;
12008         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12009         CHECK_ACCESS(_res_ptr);
12010         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
12011         FREE((void*)_res);
12012         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
12013 }
12014
12015 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
12016         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12017         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
12018         return (uint32_t)ret_conv;
12019 }
12020 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
12021         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
12022         uint32_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
12023         return ret_conv;
12024 }
12025
12026 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
12027         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
12028         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12029         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
12030         return (uint32_t)ret_conv;
12031 }
12032
12033 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
12034         LDKShutdownScript o_conv;
12035         o_conv.inner = (void*)(o & (~1));
12036         o_conv.is_owned = (o & 1) || (o == 0);
12037         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12038         o_conv = ShutdownScript_clone(&o_conv);
12039         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12040         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
12041         return (uint32_t)ret_conv;
12042 }
12043
12044 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
12045         LDKInvalidShutdownScript e_conv;
12046         e_conv.inner = (void*)(e & (~1));
12047         e_conv.is_owned = (e & 1) || (e == 0);
12048         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12049         e_conv = InvalidShutdownScript_clone(&e_conv);
12050         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12051         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
12052         return (uint32_t)ret_conv;
12053 }
12054
12055 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
12056         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
12057         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
12058         return ret_conv;
12059 }
12060
12061 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
12062         if ((_res & 1) != 0) return;
12063         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12064         CHECK_ACCESS(_res_ptr);
12065         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
12066         FREE((void*)_res);
12067         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
12068 }
12069
12070 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
12071         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12072         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
12073         return (uint32_t)ret_conv;
12074 }
12075 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
12076         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
12077         uint32_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
12078         return ret_conv;
12079 }
12080
12081 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
12082         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
12083         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12084         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
12085         return (uint32_t)ret_conv;
12086 }
12087
12088 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
12089         LDKRouteHop o_conv;
12090         o_conv.inner = (void*)(o & (~1));
12091         o_conv.is_owned = (o & 1) || (o == 0);
12092         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12093         o_conv = RouteHop_clone(&o_conv);
12094         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12095         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
12096         return (uint32_t)ret_conv;
12097 }
12098
12099 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
12100         LDKDecodeError e_conv;
12101         e_conv.inner = (void*)(e & (~1));
12102         e_conv.is_owned = (e & 1) || (e == 0);
12103         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12104         e_conv = DecodeError_clone(&e_conv);
12105         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12106         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
12107         return (uint32_t)ret_conv;
12108 }
12109
12110 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
12111         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
12112         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
12113         return ret_conv;
12114 }
12115
12116 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
12117         if ((_res & 1) != 0) return;
12118         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12119         CHECK_ACCESS(_res_ptr);
12120         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
12121         FREE((void*)_res);
12122         CResult_RouteHopDecodeErrorZ_free(_res_conv);
12123 }
12124
12125 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
12126         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12127         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
12128         return (uint32_t)ret_conv;
12129 }
12130 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
12131         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
12132         uint32_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
12133         return ret_conv;
12134 }
12135
12136 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
12137         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
12138         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12139         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
12140         return (uint32_t)ret_conv;
12141 }
12142
12143 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
12144         LDKCVec_RouteHopZ _res_constr;
12145         _res_constr.datalen = _res->arr_len;
12146         if (_res_constr.datalen > 0)
12147                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12148         else
12149                 _res_constr.data = NULL;
12150         uint32_t* _res_vals = _res->elems;
12151         for (size_t k = 0; k < _res_constr.datalen; k++) {
12152                 uint32_t _res_conv_10 = _res_vals[k];
12153                 LDKRouteHop _res_conv_10_conv;
12154                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
12155                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
12156                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
12157                 _res_constr.data[k] = _res_conv_10_conv;
12158         }
12159         FREE(_res);
12160         CVec_RouteHopZ_free(_res_constr);
12161 }
12162
12163 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
12164         LDKCVec_CVec_RouteHopZZ _res_constr;
12165         _res_constr.datalen = _res->arr_len;
12166         if (_res_constr.datalen > 0)
12167                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12168         else
12169                 _res_constr.data = NULL;
12170         uint32_tArray* _res_vals = (void*) _res->elems;
12171         for (size_t m = 0; m < _res_constr.datalen; m++) {
12172                 uint32_tArray _res_conv_12 = _res_vals[m];
12173                 LDKCVec_RouteHopZ _res_conv_12_constr;
12174                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
12175                 if (_res_conv_12_constr.datalen > 0)
12176                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12177                 else
12178                         _res_conv_12_constr.data = NULL;
12179                 uint32_t* _res_conv_12_vals = _res_conv_12->elems;
12180                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
12181                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
12182                         LDKRouteHop _res_conv_12_conv_10_conv;
12183                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
12184                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
12185                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
12186                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
12187                 }
12188                 FREE(_res_conv_12);
12189                 _res_constr.data[m] = _res_conv_12_constr;
12190         }
12191         FREE(_res);
12192         CVec_CVec_RouteHopZZ_free(_res_constr);
12193 }
12194
12195 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
12196         LDKRoute o_conv;
12197         o_conv.inner = (void*)(o & (~1));
12198         o_conv.is_owned = (o & 1) || (o == 0);
12199         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12200         o_conv = Route_clone(&o_conv);
12201         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12202         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
12203         return (uint32_t)ret_conv;
12204 }
12205
12206 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
12207         LDKDecodeError e_conv;
12208         e_conv.inner = (void*)(e & (~1));
12209         e_conv.is_owned = (e & 1) || (e == 0);
12210         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12211         e_conv = DecodeError_clone(&e_conv);
12212         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12213         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
12214         return (uint32_t)ret_conv;
12215 }
12216
12217 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
12218         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
12219         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
12220         return ret_conv;
12221 }
12222
12223 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
12224         if ((_res & 1) != 0) return;
12225         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12226         CHECK_ACCESS(_res_ptr);
12227         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
12228         FREE((void*)_res);
12229         CResult_RouteDecodeErrorZ_free(_res_conv);
12230 }
12231
12232 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
12233         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12234         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
12235         return (uint32_t)ret_conv;
12236 }
12237 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
12238         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
12239         uint32_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
12240         return ret_conv;
12241 }
12242
12243 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
12244         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
12245         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12246         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
12247         return (uint32_t)ret_conv;
12248 }
12249
12250 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
12251         LDKRouteParameters o_conv;
12252         o_conv.inner = (void*)(o & (~1));
12253         o_conv.is_owned = (o & 1) || (o == 0);
12254         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12255         o_conv = RouteParameters_clone(&o_conv);
12256         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12257         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
12258         return (uint32_t)ret_conv;
12259 }
12260
12261 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
12262         LDKDecodeError e_conv;
12263         e_conv.inner = (void*)(e & (~1));
12264         e_conv.is_owned = (e & 1) || (e == 0);
12265         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12266         e_conv = DecodeError_clone(&e_conv);
12267         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12268         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
12269         return (uint32_t)ret_conv;
12270 }
12271
12272 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
12273         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
12274         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
12275         return ret_conv;
12276 }
12277
12278 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
12279         if ((_res & 1) != 0) return;
12280         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12281         CHECK_ACCESS(_res_ptr);
12282         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
12283         FREE((void*)_res);
12284         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
12285 }
12286
12287 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
12288         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12289         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
12290         return (uint32_t)ret_conv;
12291 }
12292 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12293         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
12294         uint32_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
12295         return ret_conv;
12296 }
12297
12298 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
12299         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
12300         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12301         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
12302         return (uint32_t)ret_conv;
12303 }
12304
12305 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
12306         LDKCVec_RouteHintZ _res_constr;
12307         _res_constr.datalen = _res->arr_len;
12308         if (_res_constr.datalen > 0)
12309                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
12310         else
12311                 _res_constr.data = NULL;
12312         uint32_t* _res_vals = _res->elems;
12313         for (size_t l = 0; l < _res_constr.datalen; l++) {
12314                 uint32_t _res_conv_11 = _res_vals[l];
12315                 LDKRouteHint _res_conv_11_conv;
12316                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
12317                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
12318                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
12319                 _res_constr.data[l] = _res_conv_11_conv;
12320         }
12321         FREE(_res);
12322         CVec_RouteHintZ_free(_res_constr);
12323 }
12324
12325 uint32_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
12326         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12327         *ret_copy = COption_u64Z_some(o);
12328         uint32_t ret_ref = (uintptr_t)ret_copy;
12329         return ret_ref;
12330 }
12331
12332 uint32_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
12333         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12334         *ret_copy = COption_u64Z_none();
12335         uint32_t ret_ref = (uintptr_t)ret_copy;
12336         return ret_ref;
12337 }
12338
12339 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint32_t _res) {
12340         if ((_res & 1) != 0) return;
12341         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12342         CHECK_ACCESS(_res_ptr);
12343         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
12344         FREE((void*)_res);
12345         COption_u64Z_free(_res_conv);
12346 }
12347
12348 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
12349         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12350         *ret_copy = COption_u64Z_clone(arg);
12351 uint32_t ret_ref = (uintptr_t)ret_copy;
12352         return ret_ref;
12353 }
12354 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
12355         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
12356         uint32_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
12357         return ret_conv;
12358 }
12359
12360 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint32_t orig) {
12361         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
12362         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12363         *ret_copy = COption_u64Z_clone(orig_conv);
12364         uint32_t ret_ref = (uintptr_t)ret_copy;
12365         return ret_ref;
12366 }
12367
12368 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_ok(uint32_t o) {
12369         LDKPaymentParameters o_conv;
12370         o_conv.inner = (void*)(o & (~1));
12371         o_conv.is_owned = (o & 1) || (o == 0);
12372         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12373         o_conv = PaymentParameters_clone(&o_conv);
12374         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12375         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
12376         return (uint32_t)ret_conv;
12377 }
12378
12379 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_err"))) TS_CResult_PaymentParametersDecodeErrorZ_err(uint32_t e) {
12380         LDKDecodeError e_conv;
12381         e_conv.inner = (void*)(e & (~1));
12382         e_conv.is_owned = (e & 1) || (e == 0);
12383         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12384         e_conv = DecodeError_clone(&e_conv);
12385         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12386         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
12387         return (uint32_t)ret_conv;
12388 }
12389
12390 jboolean  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_is_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_is_ok(uint32_t o) {
12391         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
12392         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
12393         return ret_conv;
12394 }
12395
12396 void  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_free"))) TS_CResult_PaymentParametersDecodeErrorZ_free(uint32_t _res) {
12397         if ((_res & 1) != 0) return;
12398         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12399         CHECK_ACCESS(_res_ptr);
12400         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
12401         FREE((void*)_res);
12402         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
12403 }
12404
12405 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
12406         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12407         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
12408         return (uint32_t)ret_conv;
12409 }
12410 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12411         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
12412         uint32_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
12413         return ret_conv;
12414 }
12415
12416 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone"))) TS_CResult_PaymentParametersDecodeErrorZ_clone(uint32_t orig) {
12417         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
12418         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12419         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
12420         return (uint32_t)ret_conv;
12421 }
12422
12423 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
12424         LDKCVec_RouteHintHopZ _res_constr;
12425         _res_constr.datalen = _res->arr_len;
12426         if (_res_constr.datalen > 0)
12427                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
12428         else
12429                 _res_constr.data = NULL;
12430         uint32_t* _res_vals = _res->elems;
12431         for (size_t o = 0; o < _res_constr.datalen; o++) {
12432                 uint32_t _res_conv_14 = _res_vals[o];
12433                 LDKRouteHintHop _res_conv_14_conv;
12434                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
12435                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
12436                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
12437                 _res_constr.data[o] = _res_conv_14_conv;
12438         }
12439         FREE(_res);
12440         CVec_RouteHintHopZ_free(_res_constr);
12441 }
12442
12443 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
12444         LDKRouteHint o_conv;
12445         o_conv.inner = (void*)(o & (~1));
12446         o_conv.is_owned = (o & 1) || (o == 0);
12447         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12448         o_conv = RouteHint_clone(&o_conv);
12449         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12450         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
12451         return (uint32_t)ret_conv;
12452 }
12453
12454 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
12455         LDKDecodeError e_conv;
12456         e_conv.inner = (void*)(e & (~1));
12457         e_conv.is_owned = (e & 1) || (e == 0);
12458         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12459         e_conv = DecodeError_clone(&e_conv);
12460         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12461         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
12462         return (uint32_t)ret_conv;
12463 }
12464
12465 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
12466         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
12467         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
12468         return ret_conv;
12469 }
12470
12471 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
12472         if ((_res & 1) != 0) return;
12473         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12474         CHECK_ACCESS(_res_ptr);
12475         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
12476         FREE((void*)_res);
12477         CResult_RouteHintDecodeErrorZ_free(_res_conv);
12478 }
12479
12480 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
12481         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12482         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
12483         return (uint32_t)ret_conv;
12484 }
12485 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
12486         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
12487         uint32_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
12488         return ret_conv;
12489 }
12490
12491 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
12492         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
12493         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12494         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
12495         return (uint32_t)ret_conv;
12496 }
12497
12498 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
12499         LDKRouteHintHop o_conv;
12500         o_conv.inner = (void*)(o & (~1));
12501         o_conv.is_owned = (o & 1) || (o == 0);
12502         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12503         o_conv = RouteHintHop_clone(&o_conv);
12504         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12505         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
12506         return (uint32_t)ret_conv;
12507 }
12508
12509 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
12510         LDKDecodeError e_conv;
12511         e_conv.inner = (void*)(e & (~1));
12512         e_conv.is_owned = (e & 1) || (e == 0);
12513         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12514         e_conv = DecodeError_clone(&e_conv);
12515         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12516         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
12517         return (uint32_t)ret_conv;
12518 }
12519
12520 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
12521         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
12522         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
12523         return ret_conv;
12524 }
12525
12526 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
12527         if ((_res & 1) != 0) return;
12528         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12529         CHECK_ACCESS(_res_ptr);
12530         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
12531         FREE((void*)_res);
12532         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
12533 }
12534
12535 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
12536         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12537         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
12538         return (uint32_t)ret_conv;
12539 }
12540 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
12541         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
12542         uint32_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
12543         return ret_conv;
12544 }
12545
12546 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
12547         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
12548         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12549         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
12550         return (uint32_t)ret_conv;
12551 }
12552
12553 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
12554         LDKCVec_ChannelDetailsZ _res_constr;
12555         _res_constr.datalen = _res->arr_len;
12556         if (_res_constr.datalen > 0)
12557                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12558         else
12559                 _res_constr.data = NULL;
12560         uint32_t* _res_vals = _res->elems;
12561         for (size_t q = 0; q < _res_constr.datalen; q++) {
12562                 uint32_t _res_conv_16 = _res_vals[q];
12563                 LDKChannelDetails _res_conv_16_conv;
12564                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12565                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12566                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
12567                 _res_constr.data[q] = _res_conv_16_conv;
12568         }
12569         FREE(_res);
12570         CVec_ChannelDetailsZ_free(_res_constr);
12571 }
12572
12573 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
12574         LDKRoute o_conv;
12575         o_conv.inner = (void*)(o & (~1));
12576         o_conv.is_owned = (o & 1) || (o == 0);
12577         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12578         o_conv = Route_clone(&o_conv);
12579         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12580         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
12581         return (uint32_t)ret_conv;
12582 }
12583
12584 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
12585         LDKLightningError e_conv;
12586         e_conv.inner = (void*)(e & (~1));
12587         e_conv.is_owned = (e & 1) || (e == 0);
12588         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12589         e_conv = LightningError_clone(&e_conv);
12590         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12591         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
12592         return (uint32_t)ret_conv;
12593 }
12594
12595 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
12596         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
12597         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
12598         return ret_conv;
12599 }
12600
12601 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
12602         if ((_res & 1) != 0) return;
12603         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12604         CHECK_ACCESS(_res_ptr);
12605         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
12606         FREE((void*)_res);
12607         CResult_RouteLightningErrorZ_free(_res_conv);
12608 }
12609
12610 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
12611         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12612         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
12613         return (uint32_t)ret_conv;
12614 }
12615 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
12616         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
12617         uint32_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
12618         return ret_conv;
12619 }
12620
12621 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
12622         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
12623         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12624         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
12625         return (uint32_t)ret_conv;
12626 }
12627
12628 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
12629         LDKCVec_PublicKeyZ _res_constr;
12630         _res_constr.datalen = _res->arr_len;
12631         if (_res_constr.datalen > 0)
12632                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
12633         else
12634                 _res_constr.data = NULL;
12635         int8_tArray* _res_vals = (void*) _res->elems;
12636         for (size_t m = 0; m < _res_constr.datalen; m++) {
12637                 int8_tArray _res_conv_12 = _res_vals[m];
12638                 LDKPublicKey _res_conv_12_ref;
12639                 CHECK(_res_conv_12->arr_len == 33);
12640                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33); FREE(_res_conv_12);
12641                 _res_constr.data[m] = _res_conv_12_ref;
12642         }
12643         FREE(_res);
12644         CVec_PublicKeyZ_free(_res_constr);
12645 }
12646
12647 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_ok(uint32_t o) {
12648         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12649         CHECK_ACCESS(o_ptr);
12650         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
12651         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)o) & ~1));
12652         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12653         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
12654         return (uint32_t)ret_conv;
12655 }
12656
12657 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_err"))) TS_CResult_PaymentPurposeDecodeErrorZ_err(uint32_t e) {
12658         LDKDecodeError e_conv;
12659         e_conv.inner = (void*)(e & (~1));
12660         e_conv.is_owned = (e & 1) || (e == 0);
12661         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12662         e_conv = DecodeError_clone(&e_conv);
12663         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12664         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
12665         return (uint32_t)ret_conv;
12666 }
12667
12668 jboolean  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_is_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_is_ok(uint32_t o) {
12669         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(o & ~1);
12670         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
12671         return ret_conv;
12672 }
12673
12674 void  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_free"))) TS_CResult_PaymentPurposeDecodeErrorZ_free(uint32_t _res) {
12675         if ((_res & 1) != 0) return;
12676         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12677         CHECK_ACCESS(_res_ptr);
12678         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
12679         FREE((void*)_res);
12680         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
12681 }
12682
12683 static inline uintptr_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
12684         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12685         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
12686         return (uint32_t)ret_conv;
12687 }
12688 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentPurposeDecodeErrorZ_clone_ptr(uint32_t arg) {
12689         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(arg & ~1);
12690         uint32_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
12691         return ret_conv;
12692 }
12693
12694 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_clone"))) TS_CResult_PaymentPurposeDecodeErrorZ_clone(uint32_t orig) {
12695         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(orig & ~1);
12696         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12697         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
12698         return (uint32_t)ret_conv;
12699 }
12700
12701 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
12702         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12703         CHECK_ACCESS(o_ptr);
12704         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
12705         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
12706         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12707         *ret_copy = COption_ClosureReasonZ_some(o_conv);
12708         uint32_t ret_ref = (uintptr_t)ret_copy;
12709         return ret_ref;
12710 }
12711
12712 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
12713         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12714         *ret_copy = COption_ClosureReasonZ_none();
12715         uint32_t ret_ref = (uintptr_t)ret_copy;
12716         return ret_ref;
12717 }
12718
12719 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
12720         if ((_res & 1) != 0) return;
12721         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12722         CHECK_ACCESS(_res_ptr);
12723         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
12724         FREE((void*)_res);
12725         COption_ClosureReasonZ_free(_res_conv);
12726 }
12727
12728 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
12729         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12730         *ret_copy = COption_ClosureReasonZ_clone(arg);
12731 uint32_t ret_ref = (uintptr_t)ret_copy;
12732         return ret_ref;
12733 }
12734 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
12735         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
12736         uint32_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
12737         return ret_conv;
12738 }
12739
12740 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
12741         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
12742         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12743         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
12744         uint32_t ret_ref = (uintptr_t)ret_copy;
12745         return ret_ref;
12746 }
12747
12748 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
12749         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12750         CHECK_ACCESS(o_ptr);
12751         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
12752         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
12753         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12754         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
12755         return (uint32_t)ret_conv;
12756 }
12757
12758 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
12759         LDKDecodeError e_conv;
12760         e_conv.inner = (void*)(e & (~1));
12761         e_conv.is_owned = (e & 1) || (e == 0);
12762         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12763         e_conv = DecodeError_clone(&e_conv);
12764         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12765         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
12766         return (uint32_t)ret_conv;
12767 }
12768
12769 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
12770         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
12771         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
12772         return ret_conv;
12773 }
12774
12775 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
12776         if ((_res & 1) != 0) return;
12777         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12778         CHECK_ACCESS(_res_ptr);
12779         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
12780         FREE((void*)_res);
12781         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
12782 }
12783
12784 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
12785         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12786         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
12787         return (uint32_t)ret_conv;
12788 }
12789 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
12790         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
12791         uint32_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
12792         return ret_conv;
12793 }
12794
12795 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
12796         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
12797         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12798         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
12799         return (uint32_t)ret_conv;
12800 }
12801
12802 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
12803         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12804         CHECK_ACCESS(o_ptr);
12805         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
12806         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
12807         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12808         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
12809         uint32_t ret_ref = (uintptr_t)ret_copy;
12810         return ret_ref;
12811 }
12812
12813 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
12814         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12815         *ret_copy = COption_NetworkUpdateZ_none();
12816         uint32_t ret_ref = (uintptr_t)ret_copy;
12817         return ret_ref;
12818 }
12819
12820 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
12821         if ((_res & 1) != 0) return;
12822         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12823         CHECK_ACCESS(_res_ptr);
12824         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
12825         FREE((void*)_res);
12826         COption_NetworkUpdateZ_free(_res_conv);
12827 }
12828
12829 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
12830         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12831         *ret_copy = COption_NetworkUpdateZ_clone(arg);
12832 uint32_t ret_ref = (uintptr_t)ret_copy;
12833         return ret_ref;
12834 }
12835 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
12836         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
12837         uint32_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
12838         return ret_conv;
12839 }
12840
12841 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
12842         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
12843         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12844         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
12845         uint32_t ret_ref = (uintptr_t)ret_copy;
12846         return ret_ref;
12847 }
12848
12849 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
12850         LDKCVec_SpendableOutputDescriptorZ _res_constr;
12851         _res_constr.datalen = _res->arr_len;
12852         if (_res_constr.datalen > 0)
12853                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12854         else
12855                 _res_constr.data = NULL;
12856         uint32_t* _res_vals = _res->elems;
12857         for (size_t b = 0; b < _res_constr.datalen; b++) {
12858                 uint32_t _res_conv_27 = _res_vals[b];
12859                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
12860                 CHECK_ACCESS(_res_conv_27_ptr);
12861                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
12862                 FREE((void*)_res_conv_27);
12863                 _res_constr.data[b] = _res_conv_27_conv;
12864         }
12865         FREE(_res);
12866         CVec_SpendableOutputDescriptorZ_free(_res_constr);
12867 }
12868
12869 uint32_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint32_t o) {
12870         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12871         CHECK_ACCESS(o_ptr);
12872         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
12873         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
12874         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12875         *ret_copy = COption_EventZ_some(o_conv);
12876         uint32_t ret_ref = (uintptr_t)ret_copy;
12877         return ret_ref;
12878 }
12879
12880 uint32_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
12881         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12882         *ret_copy = COption_EventZ_none();
12883         uint32_t ret_ref = (uintptr_t)ret_copy;
12884         return ret_ref;
12885 }
12886
12887 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint32_t _res) {
12888         if ((_res & 1) != 0) return;
12889         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12890         CHECK_ACCESS(_res_ptr);
12891         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
12892         FREE((void*)_res);
12893         COption_EventZ_free(_res_conv);
12894 }
12895
12896 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
12897         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12898         *ret_copy = COption_EventZ_clone(arg);
12899 uint32_t ret_ref = (uintptr_t)ret_copy;
12900         return ret_ref;
12901 }
12902 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
12903         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
12904         uint32_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
12905         return ret_conv;
12906 }
12907
12908 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint32_t orig) {
12909         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
12910         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12911         *ret_copy = COption_EventZ_clone(orig_conv);
12912         uint32_t ret_ref = (uintptr_t)ret_copy;
12913         return ret_ref;
12914 }
12915
12916 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
12917         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12918         CHECK_ACCESS(o_ptr);
12919         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
12920         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
12921         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12922         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
12923         return (uint32_t)ret_conv;
12924 }
12925
12926 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
12927         LDKDecodeError e_conv;
12928         e_conv.inner = (void*)(e & (~1));
12929         e_conv.is_owned = (e & 1) || (e == 0);
12930         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12931         e_conv = DecodeError_clone(&e_conv);
12932         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12933         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
12934         return (uint32_t)ret_conv;
12935 }
12936
12937 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
12938         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
12939         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
12940         return ret_conv;
12941 }
12942
12943 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
12944         if ((_res & 1) != 0) return;
12945         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12946         CHECK_ACCESS(_res_ptr);
12947         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
12948         FREE((void*)_res);
12949         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
12950 }
12951
12952 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
12953         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12954         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
12955         return (uint32_t)ret_conv;
12956 }
12957 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
12958         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
12959         uint32_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
12960         return ret_conv;
12961 }
12962
12963 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
12964         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
12965         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12966         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
12967         return (uint32_t)ret_conv;
12968 }
12969
12970 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
12971         LDKCVec_MessageSendEventZ _res_constr;
12972         _res_constr.datalen = _res->arr_len;
12973         if (_res_constr.datalen > 0)
12974                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
12975         else
12976                 _res_constr.data = NULL;
12977         uint32_t* _res_vals = _res->elems;
12978         for (size_t s = 0; s < _res_constr.datalen; s++) {
12979                 uint32_t _res_conv_18 = _res_vals[s];
12980                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
12981                 CHECK_ACCESS(_res_conv_18_ptr);
12982                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
12983                 FREE((void*)_res_conv_18);
12984                 _res_constr.data[s] = _res_conv_18_conv;
12985         }
12986         FREE(_res);
12987         CVec_MessageSendEventZ_free(_res_constr);
12988 }
12989
12990 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
12991         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12992         CHECK_ACCESS(o_ptr);
12993         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
12994         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
12995         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12996         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
12997         return (uint32_t)ret_conv;
12998 }
12999
13000 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
13001         LDKAccessError e_conv = LDKAccessError_from_js(e);
13002         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13003         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
13004         return (uint32_t)ret_conv;
13005 }
13006
13007 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
13008         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
13009         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
13010         return ret_conv;
13011 }
13012
13013 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
13014         if ((_res & 1) != 0) return;
13015         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13016         CHECK_ACCESS(_res_ptr);
13017         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
13018         FREE((void*)_res);
13019         CResult_TxOutAccessErrorZ_free(_res_conv);
13020 }
13021
13022 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
13023         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13024         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
13025         return (uint32_t)ret_conv;
13026 }
13027 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
13028         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
13029         uint32_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
13030         return ret_conv;
13031 }
13032
13033 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
13034         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
13035         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13036         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
13037         return (uint32_t)ret_conv;
13038 }
13039
13040 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
13041         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13042         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
13043         return ((uint32_t)ret_conv);
13044 }
13045 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
13046         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
13047         uint32_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
13048         return ret_conv;
13049 }
13050
13051 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
13052         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
13053         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13054         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
13055         return ((uint32_t)ret_conv);
13056 }
13057
13058 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(uint32_t a, int8_tArray b) {
13059         LDKTransaction b_ref;
13060         b_ref.datalen = b->arr_len;
13061         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
13062         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
13063         b_ref.data_is_owned = true;
13064         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13065         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
13066         return ((uint32_t)ret_conv);
13067 }
13068
13069 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
13070         if ((_res & 1) != 0) return;
13071         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13072         CHECK_ACCESS(_res_ptr);
13073         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
13074         FREE((void*)_res);
13075         C2Tuple_usizeTransactionZ_free(_res_conv);
13076 }
13077
13078 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
13079         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
13080         _res_constr.datalen = _res->arr_len;
13081         if (_res_constr.datalen > 0)
13082                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
13083         else
13084                 _res_constr.data = NULL;
13085         uint32_t* _res_vals = _res->elems;
13086         for (size_t c = 0; c < _res_constr.datalen; c++) {
13087                 uint32_t _res_conv_28 = _res_vals[c];
13088                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
13089                 CHECK_ACCESS(_res_conv_28_ptr);
13090                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
13091                 FREE((void*)_res_conv_28);
13092                 _res_constr.data[c] = _res_conv_28_conv;
13093         }
13094         FREE(_res);
13095         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
13096 }
13097
13098 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
13099         LDKCVec_TxidZ _res_constr;
13100         _res_constr.datalen = _res->arr_len;
13101         if (_res_constr.datalen > 0)
13102                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
13103         else
13104                 _res_constr.data = NULL;
13105         int8_tArray* _res_vals = (void*) _res->elems;
13106         for (size_t m = 0; m < _res_constr.datalen; m++) {
13107                 int8_tArray _res_conv_12 = _res_vals[m];
13108                 LDKThirtyTwoBytes _res_conv_12_ref;
13109                 CHECK(_res_conv_12->arr_len == 32);
13110                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
13111                 _res_constr.data[m] = _res_conv_12_ref;
13112         }
13113         FREE(_res);
13114         CVec_TxidZ_free(_res_constr);
13115 }
13116
13117 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
13118         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13119         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
13120         return (uint32_t)ret_conv;
13121 }
13122
13123 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
13124         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
13125         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13126         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
13127         return (uint32_t)ret_conv;
13128 }
13129
13130 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
13131         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
13132         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
13133         return ret_conv;
13134 }
13135
13136 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
13137         if ((_res & 1) != 0) return;
13138         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13139         CHECK_ACCESS(_res_ptr);
13140         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
13141         FREE((void*)_res);
13142         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
13143 }
13144
13145 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
13146         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13147         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
13148         return (uint32_t)ret_conv;
13149 }
13150 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
13151         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
13152         uint32_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
13153         return ret_conv;
13154 }
13155
13156 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
13157         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
13158         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13159         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
13160         return (uint32_t)ret_conv;
13161 }
13162
13163 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
13164         LDKCVec_MonitorEventZ _res_constr;
13165         _res_constr.datalen = _res->arr_len;
13166         if (_res_constr.datalen > 0)
13167                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
13168         else
13169                 _res_constr.data = NULL;
13170         uint32_t* _res_vals = _res->elems;
13171         for (size_t o = 0; o < _res_constr.datalen; o++) {
13172                 uint32_t _res_conv_14 = _res_vals[o];
13173                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
13174                 CHECK_ACCESS(_res_conv_14_ptr);
13175                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
13176                 FREE((void*)_res_conv_14);
13177                 _res_constr.data[o] = _res_conv_14_conv;
13178         }
13179         FREE(_res);
13180         CVec_MonitorEventZ_free(_res_constr);
13181 }
13182
13183 static inline uintptr_t C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR arg) {
13184         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
13185         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone(arg);
13186         return ((uint32_t)ret_conv);
13187 }
13188 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr(uint32_t arg) {
13189         LDKC2Tuple_OutPointCVec_MonitorEventZZ* arg_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(arg & ~1);
13190         uint32_t ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr(arg_conv);
13191         return ret_conv;
13192 }
13193
13194 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_clone"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_clone(uint32_t orig) {
13195         LDKC2Tuple_OutPointCVec_MonitorEventZZ* orig_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(orig & ~1);
13196         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
13197         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone(orig_conv);
13198         return ((uint32_t)ret_conv);
13199 }
13200
13201 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_new"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_new(uint32_t a, uint32_tArray b) {
13202         LDKOutPoint a_conv;
13203         a_conv.inner = (void*)(a & (~1));
13204         a_conv.is_owned = (a & 1) || (a == 0);
13205         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
13206         a_conv = OutPoint_clone(&a_conv);
13207         LDKCVec_MonitorEventZ b_constr;
13208         b_constr.datalen = b->arr_len;
13209         if (b_constr.datalen > 0)
13210                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
13211         else
13212                 b_constr.data = NULL;
13213         uint32_t* b_vals = b->elems;
13214         for (size_t o = 0; o < b_constr.datalen; o++) {
13215                 uint32_t b_conv_14 = b_vals[o];
13216                 void* b_conv_14_ptr = (void*)(((uintptr_t)b_conv_14) & ~1);
13217                 CHECK_ACCESS(b_conv_14_ptr);
13218                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
13219                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)b_conv_14) & ~1));
13220                 b_constr.data[o] = b_conv_14_conv;
13221         }
13222         FREE(b);
13223         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
13224         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_new(a_conv, b_constr);
13225         return ((uint32_t)ret_conv);
13226 }
13227
13228 void  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_free"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_free(uint32_t _res) {
13229         if ((_res & 1) != 0) return;
13230         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13231         CHECK_ACCESS(_res_ptr);
13232         LDKC2Tuple_OutPointCVec_MonitorEventZZ _res_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(_res_ptr);
13233         FREE((void*)_res);
13234         C2Tuple_OutPointCVec_MonitorEventZZ_free(_res_conv);
13235 }
13236
13237 void  __attribute__((export_name("TS_CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_free"))) TS_CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_free(uint32_tArray _res) {
13238         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ _res_constr;
13239         _res_constr.datalen = _res->arr_len;
13240         if (_res_constr.datalen > 0)
13241                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ Elements");
13242         else
13243                 _res_constr.data = NULL;
13244         uint32_t* _res_vals = _res->elems;
13245         for (size_t m = 0; m < _res_constr.datalen; m++) {
13246                 uint32_t _res_conv_38 = _res_vals[m];
13247                 void* _res_conv_38_ptr = (void*)(((uintptr_t)_res_conv_38) & ~1);
13248                 CHECK_ACCESS(_res_conv_38_ptr);
13249                 LDKC2Tuple_OutPointCVec_MonitorEventZZ _res_conv_38_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(_res_conv_38_ptr);
13250                 FREE((void*)_res_conv_38);
13251                 _res_constr.data[m] = _res_conv_38_conv;
13252         }
13253         FREE(_res);
13254         CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_free(_res_constr);
13255 }
13256
13257 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_some"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
13258         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13259         CHECK_ACCESS(o_ptr);
13260         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
13261         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
13262         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13263         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
13264         uint32_t ret_ref = (uintptr_t)ret_copy;
13265         return ret_ref;
13266 }
13267
13268 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_none"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
13269         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13270         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
13271         uint32_t ret_ref = (uintptr_t)ret_copy;
13272         return ret_ref;
13273 }
13274
13275 void  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_free"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
13276         if ((_res & 1) != 0) return;
13277         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13278         CHECK_ACCESS(_res_ptr);
13279         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
13280         FREE((void*)_res);
13281         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
13282 }
13283
13284 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
13285         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13286         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
13287 uint32_t ret_ref = (uintptr_t)ret_copy;
13288         return ret_ref;
13289 }
13290 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
13291         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
13292         uint32_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
13293         return ret_conv;
13294 }
13295
13296 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
13297         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
13298         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13299         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
13300         uint32_t ret_ref = (uintptr_t)ret_copy;
13301         return ret_ref;
13302 }
13303
13304 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok(uint32_t o) {
13305         LDKFixedPenaltyScorer o_conv;
13306         o_conv.inner = (void*)(o & (~1));
13307         o_conv.is_owned = (o & 1) || (o == 0);
13308         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13309         o_conv = FixedPenaltyScorer_clone(&o_conv);
13310         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13311         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
13312         return (uint32_t)ret_conv;
13313 }
13314
13315 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_err(uint32_t e) {
13316         LDKDecodeError e_conv;
13317         e_conv.inner = (void*)(e & (~1));
13318         e_conv.is_owned = (e & 1) || (e == 0);
13319         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13320         e_conv = DecodeError_clone(&e_conv);
13321         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13322         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
13323         return (uint32_t)ret_conv;
13324 }
13325
13326 jboolean  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(uint32_t o) {
13327         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
13328         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
13329         return ret_conv;
13330 }
13331
13332 void  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_free"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_free(uint32_t _res) {
13333         if ((_res & 1) != 0) return;
13334         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13335         CHECK_ACCESS(_res_ptr);
13336         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
13337         FREE((void*)_res);
13338         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
13339 }
13340
13341 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
13342         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13343         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
13344         return (uint32_t)ret_conv;
13345 }
13346 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(uint32_t arg) {
13347         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
13348         uint32_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
13349         return ret_conv;
13350 }
13351
13352 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone(uint32_t orig) {
13353         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
13354         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13355         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
13356         return (uint32_t)ret_conv;
13357 }
13358
13359 static inline uintptr_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
13360         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13361         *ret_conv = C2Tuple_u64u64Z_clone(arg);
13362         return ((uint32_t)ret_conv);
13363 }
13364 uint32_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_clone_ptr"))) TS_C2Tuple_u64u64Z_clone_ptr(uint32_t arg) {
13365         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)(arg & ~1);
13366         uint32_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
13367         return ret_conv;
13368 }
13369
13370 uint32_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_clone"))) TS_C2Tuple_u64u64Z_clone(uint32_t orig) {
13371         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)(orig & ~1);
13372         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13373         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
13374         return ((uint32_t)ret_conv);
13375 }
13376
13377 uint32_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_new"))) TS_C2Tuple_u64u64Z_new(int64_t a, int64_t b) {
13378         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13379         *ret_conv = C2Tuple_u64u64Z_new(a, b);
13380         return ((uint32_t)ret_conv);
13381 }
13382
13383 void  __attribute__((export_name("TS_C2Tuple_u64u64Z_free"))) TS_C2Tuple_u64u64Z_free(uint32_t _res) {
13384         if ((_res & 1) != 0) return;
13385         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13386         CHECK_ACCESS(_res_ptr);
13387         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
13388         FREE((void*)_res);
13389         C2Tuple_u64u64Z_free(_res_conv);
13390 }
13391
13392 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_some"))) TS_COption_C2Tuple_u64u64ZZ_some(uint32_t o) {
13393         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13394         CHECK_ACCESS(o_ptr);
13395         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
13396         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)(((uintptr_t)o) & ~1));
13397         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13398         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
13399         uint32_t ret_ref = (uintptr_t)ret_copy;
13400         return ret_ref;
13401 }
13402
13403 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_none"))) TS_COption_C2Tuple_u64u64ZZ_none() {
13404         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13405         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
13406         uint32_t ret_ref = (uintptr_t)ret_copy;
13407         return ret_ref;
13408 }
13409
13410 void  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_free"))) TS_COption_C2Tuple_u64u64ZZ_free(uint32_t _res) {
13411         if ((_res & 1) != 0) return;
13412         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13413         CHECK_ACCESS(_res_ptr);
13414         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
13415         FREE((void*)_res);
13416         COption_C2Tuple_u64u64ZZ_free(_res_conv);
13417 }
13418
13419 static inline uintptr_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
13420         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13421         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
13422 uint32_t ret_ref = (uintptr_t)ret_copy;
13423         return ret_ref;
13424 }
13425 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_clone_ptr"))) TS_COption_C2Tuple_u64u64ZZ_clone_ptr(uint32_t arg) {
13426         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)arg;
13427         uint32_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
13428         return ret_conv;
13429 }
13430
13431 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_clone"))) TS_COption_C2Tuple_u64u64ZZ_clone(uint32_t orig) {
13432         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)orig;
13433         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13434         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
13435         uint32_t ret_ref = (uintptr_t)ret_copy;
13436         return ret_ref;
13437 }
13438
13439 void  __attribute__((export_name("TS_CVec_NodeIdZ_free"))) TS_CVec_NodeIdZ_free(uint32_tArray _res) {
13440         LDKCVec_NodeIdZ _res_constr;
13441         _res_constr.datalen = _res->arr_len;
13442         if (_res_constr.datalen > 0)
13443                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
13444         else
13445                 _res_constr.data = NULL;
13446         uint32_t* _res_vals = _res->elems;
13447         for (size_t i = 0; i < _res_constr.datalen; i++) {
13448                 uint32_t _res_conv_8 = _res_vals[i];
13449                 LDKNodeId _res_conv_8_conv;
13450                 _res_conv_8_conv.inner = (void*)(_res_conv_8 & (~1));
13451                 _res_conv_8_conv.is_owned = (_res_conv_8 & 1) || (_res_conv_8 == 0);
13452                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
13453                 _res_constr.data[i] = _res_conv_8_conv;
13454         }
13455         FREE(_res);
13456         CVec_NodeIdZ_free(_res_constr);
13457 }
13458
13459 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_ok(uint32_t o) {
13460         LDKProbabilisticScorer o_conv;
13461         o_conv.inner = (void*)(o & (~1));
13462         o_conv.is_owned = (o & 1) || (o == 0);
13463         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13464         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
13465         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
13466         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
13467         return (uint32_t)ret_conv;
13468 }
13469
13470 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_err(uint32_t e) {
13471         LDKDecodeError e_conv;
13472         e_conv.inner = (void*)(e & (~1));
13473         e_conv.is_owned = (e & 1) || (e == 0);
13474         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13475         e_conv = DecodeError_clone(&e_conv);
13476         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
13477         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
13478         return (uint32_t)ret_conv;
13479 }
13480
13481 jboolean  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok(uint32_t o) {
13482         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
13483         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
13484         return ret_conv;
13485 }
13486
13487 void  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_free"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_free(uint32_t _res) {
13488         if ((_res & 1) != 0) return;
13489         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13490         CHECK_ACCESS(_res_ptr);
13491         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
13492         FREE((void*)_res);
13493         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
13494 }
13495
13496 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
13497         LDKInitFeatures o_conv;
13498         o_conv.inner = (void*)(o & (~1));
13499         o_conv.is_owned = (o & 1) || (o == 0);
13500         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13501         o_conv = InitFeatures_clone(&o_conv);
13502         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13503         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
13504         return (uint32_t)ret_conv;
13505 }
13506
13507 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
13508         LDKDecodeError e_conv;
13509         e_conv.inner = (void*)(e & (~1));
13510         e_conv.is_owned = (e & 1) || (e == 0);
13511         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13512         e_conv = DecodeError_clone(&e_conv);
13513         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13514         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
13515         return (uint32_t)ret_conv;
13516 }
13517
13518 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13519         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
13520         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
13521         return ret_conv;
13522 }
13523
13524 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
13525         if ((_res & 1) != 0) return;
13526         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13527         CHECK_ACCESS(_res_ptr);
13528         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
13529         FREE((void*)_res);
13530         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
13531 }
13532
13533 static inline uintptr_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13534         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13535         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
13536         return (uint32_t)ret_conv;
13537 }
13538 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_InitFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13539         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
13540         uint32_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13541         return ret_conv;
13542 }
13543
13544 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_clone"))) TS_CResult_InitFeaturesDecodeErrorZ_clone(uint32_t orig) {
13545         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(orig & ~1);
13546         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13547         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
13548         return (uint32_t)ret_conv;
13549 }
13550
13551 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
13552         LDKChannelFeatures o_conv;
13553         o_conv.inner = (void*)(o & (~1));
13554         o_conv.is_owned = (o & 1) || (o == 0);
13555         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13556         o_conv = ChannelFeatures_clone(&o_conv);
13557         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13558         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
13559         return (uint32_t)ret_conv;
13560 }
13561
13562 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
13563         LDKDecodeError e_conv;
13564         e_conv.inner = (void*)(e & (~1));
13565         e_conv.is_owned = (e & 1) || (e == 0);
13566         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13567         e_conv = DecodeError_clone(&e_conv);
13568         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13569         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
13570         return (uint32_t)ret_conv;
13571 }
13572
13573 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13574         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
13575         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
13576         return ret_conv;
13577 }
13578
13579 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
13580         if ((_res & 1) != 0) return;
13581         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13582         CHECK_ACCESS(_res_ptr);
13583         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
13584         FREE((void*)_res);
13585         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
13586 }
13587
13588 static inline uintptr_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13589         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13590         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
13591         return (uint32_t)ret_conv;
13592 }
13593 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13594         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
13595         uint32_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13596         return ret_conv;
13597 }
13598
13599 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_clone"))) TS_CResult_ChannelFeaturesDecodeErrorZ_clone(uint32_t orig) {
13600         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(orig & ~1);
13601         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13602         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
13603         return (uint32_t)ret_conv;
13604 }
13605
13606 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
13607         LDKNodeFeatures o_conv;
13608         o_conv.inner = (void*)(o & (~1));
13609         o_conv.is_owned = (o & 1) || (o == 0);
13610         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13611         o_conv = NodeFeatures_clone(&o_conv);
13612         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13613         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
13614         return (uint32_t)ret_conv;
13615 }
13616
13617 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
13618         LDKDecodeError e_conv;
13619         e_conv.inner = (void*)(e & (~1));
13620         e_conv.is_owned = (e & 1) || (e == 0);
13621         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13622         e_conv = DecodeError_clone(&e_conv);
13623         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13624         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
13625         return (uint32_t)ret_conv;
13626 }
13627
13628 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13629         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
13630         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
13631         return ret_conv;
13632 }
13633
13634 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
13635         if ((_res & 1) != 0) return;
13636         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13637         CHECK_ACCESS(_res_ptr);
13638         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
13639         FREE((void*)_res);
13640         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
13641 }
13642
13643 static inline uintptr_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13644         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13645         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
13646         return (uint32_t)ret_conv;
13647 }
13648 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_NodeFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13649         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
13650         uint32_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13651         return ret_conv;
13652 }
13653
13654 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_clone"))) TS_CResult_NodeFeaturesDecodeErrorZ_clone(uint32_t orig) {
13655         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(orig & ~1);
13656         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13657         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
13658         return (uint32_t)ret_conv;
13659 }
13660
13661 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
13662         LDKInvoiceFeatures o_conv;
13663         o_conv.inner = (void*)(o & (~1));
13664         o_conv.is_owned = (o & 1) || (o == 0);
13665         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13666         o_conv = InvoiceFeatures_clone(&o_conv);
13667         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13668         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
13669         return (uint32_t)ret_conv;
13670 }
13671
13672 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
13673         LDKDecodeError e_conv;
13674         e_conv.inner = (void*)(e & (~1));
13675         e_conv.is_owned = (e & 1) || (e == 0);
13676         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13677         e_conv = DecodeError_clone(&e_conv);
13678         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13679         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
13680         return (uint32_t)ret_conv;
13681 }
13682
13683 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13684         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
13685         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
13686         return ret_conv;
13687 }
13688
13689 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
13690         if ((_res & 1) != 0) return;
13691         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13692         CHECK_ACCESS(_res_ptr);
13693         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
13694         FREE((void*)_res);
13695         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
13696 }
13697
13698 static inline uintptr_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13699         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13700         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
13701         return (uint32_t)ret_conv;
13702 }
13703 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13704         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
13705         uint32_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13706         return ret_conv;
13707 }
13708
13709 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_clone"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_clone(uint32_t orig) {
13710         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(orig & ~1);
13711         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13712         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
13713         return (uint32_t)ret_conv;
13714 }
13715
13716 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
13717         LDKChannelTypeFeatures o_conv;
13718         o_conv.inner = (void*)(o & (~1));
13719         o_conv.is_owned = (o & 1) || (o == 0);
13720         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13721         o_conv = ChannelTypeFeatures_clone(&o_conv);
13722         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13723         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
13724         return (uint32_t)ret_conv;
13725 }
13726
13727 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
13728         LDKDecodeError e_conv;
13729         e_conv.inner = (void*)(e & (~1));
13730         e_conv.is_owned = (e & 1) || (e == 0);
13731         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13732         e_conv = DecodeError_clone(&e_conv);
13733         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13734         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
13735         return (uint32_t)ret_conv;
13736 }
13737
13738 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13739         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
13740         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
13741         return ret_conv;
13742 }
13743
13744 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint32_t _res) {
13745         if ((_res & 1) != 0) return;
13746         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13747         CHECK_ACCESS(_res_ptr);
13748         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
13749         FREE((void*)_res);
13750         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
13751 }
13752
13753 static inline uintptr_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13754         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13755         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
13756         return (uint32_t)ret_conv;
13757 }
13758 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13759         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(arg & ~1);
13760         uint32_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13761         return ret_conv;
13762 }
13763
13764 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone(uint32_t orig) {
13765         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(orig & ~1);
13766         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13767         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
13768         return (uint32_t)ret_conv;
13769 }
13770
13771 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
13772         LDKNodeId o_conv;
13773         o_conv.inner = (void*)(o & (~1));
13774         o_conv.is_owned = (o & 1) || (o == 0);
13775         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13776         o_conv = NodeId_clone(&o_conv);
13777         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13778         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
13779         return (uint32_t)ret_conv;
13780 }
13781
13782 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
13783         LDKDecodeError e_conv;
13784         e_conv.inner = (void*)(e & (~1));
13785         e_conv.is_owned = (e & 1) || (e == 0);
13786         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13787         e_conv = DecodeError_clone(&e_conv);
13788         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13789         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
13790         return (uint32_t)ret_conv;
13791 }
13792
13793 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
13794         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
13795         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
13796         return ret_conv;
13797 }
13798
13799 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
13800         if ((_res & 1) != 0) return;
13801         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13802         CHECK_ACCESS(_res_ptr);
13803         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
13804         FREE((void*)_res);
13805         CResult_NodeIdDecodeErrorZ_free(_res_conv);
13806 }
13807
13808 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
13809         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13810         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
13811         return (uint32_t)ret_conv;
13812 }
13813 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
13814         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
13815         uint32_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
13816         return ret_conv;
13817 }
13818
13819 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
13820         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
13821         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13822         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
13823         return (uint32_t)ret_conv;
13824 }
13825
13826 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
13827         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13828         CHECK_ACCESS(o_ptr);
13829         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
13830         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
13831         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13832         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
13833         return (uint32_t)ret_conv;
13834 }
13835
13836 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
13837         LDKDecodeError e_conv;
13838         e_conv.inner = (void*)(e & (~1));
13839         e_conv.is_owned = (e & 1) || (e == 0);
13840         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13841         e_conv = DecodeError_clone(&e_conv);
13842         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13843         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
13844         return (uint32_t)ret_conv;
13845 }
13846
13847 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
13848         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
13849         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
13850         return ret_conv;
13851 }
13852
13853 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
13854         if ((_res & 1) != 0) return;
13855         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13856         CHECK_ACCESS(_res_ptr);
13857         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
13858         FREE((void*)_res);
13859         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
13860 }
13861
13862 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
13863         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13864         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
13865         return (uint32_t)ret_conv;
13866 }
13867 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
13868         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
13869         uint32_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
13870         return ret_conv;
13871 }
13872
13873 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
13874         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
13875         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13876         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
13877         return (uint32_t)ret_conv;
13878 }
13879
13880 uint32_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint32_t o) {
13881         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13882         CHECK_ACCESS(o_ptr);
13883         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
13884         if (o_conv.free == LDKAccess_JCalls_free) {
13885                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13886                 LDKAccess_JCalls_cloned(&o_conv);
13887         }
13888         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
13889         *ret_copy = COption_AccessZ_some(o_conv);
13890         uint32_t ret_ref = (uintptr_t)ret_copy;
13891         return ret_ref;
13892 }
13893
13894 uint32_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
13895         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
13896         *ret_copy = COption_AccessZ_none();
13897         uint32_t ret_ref = (uintptr_t)ret_copy;
13898         return ret_ref;
13899 }
13900
13901 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint32_t _res) {
13902         if ((_res & 1) != 0) return;
13903         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13904         CHECK_ACCESS(_res_ptr);
13905         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
13906         FREE((void*)_res);
13907         COption_AccessZ_free(_res_conv);
13908 }
13909
13910 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
13911         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13912         *ret_conv = CResult_boolLightningErrorZ_ok(o);
13913         return (uint32_t)ret_conv;
13914 }
13915
13916 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
13917         LDKLightningError e_conv;
13918         e_conv.inner = (void*)(e & (~1));
13919         e_conv.is_owned = (e & 1) || (e == 0);
13920         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13921         e_conv = LightningError_clone(&e_conv);
13922         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13923         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
13924         return (uint32_t)ret_conv;
13925 }
13926
13927 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
13928         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
13929         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
13930         return ret_conv;
13931 }
13932
13933 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
13934         if ((_res & 1) != 0) return;
13935         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13936         CHECK_ACCESS(_res_ptr);
13937         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
13938         FREE((void*)_res);
13939         CResult_boolLightningErrorZ_free(_res_conv);
13940 }
13941
13942 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
13943         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13944         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
13945         return (uint32_t)ret_conv;
13946 }
13947 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
13948         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
13949         uint32_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
13950         return ret_conv;
13951 }
13952
13953 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
13954         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
13955         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13956         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
13957         return (uint32_t)ret_conv;
13958 }
13959
13960 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
13961         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13962         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
13963         return ((uint32_t)ret_conv);
13964 }
13965 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
13966         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
13967         uint32_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
13968         return ret_conv;
13969 }
13970
13971 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
13972         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
13973         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13974         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
13975         return ((uint32_t)ret_conv);
13976 }
13977
13978 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
13979         LDKChannelAnnouncement a_conv;
13980         a_conv.inner = (void*)(a & (~1));
13981         a_conv.is_owned = (a & 1) || (a == 0);
13982         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
13983         a_conv = ChannelAnnouncement_clone(&a_conv);
13984         LDKChannelUpdate b_conv;
13985         b_conv.inner = (void*)(b & (~1));
13986         b_conv.is_owned = (b & 1) || (b == 0);
13987         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
13988         b_conv = ChannelUpdate_clone(&b_conv);
13989         LDKChannelUpdate c_conv;
13990         c_conv.inner = (void*)(c & (~1));
13991         c_conv.is_owned = (c & 1) || (c == 0);
13992         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
13993         c_conv = ChannelUpdate_clone(&c_conv);
13994         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13995         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
13996         return ((uint32_t)ret_conv);
13997 }
13998
13999 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
14000         if ((_res & 1) != 0) return;
14001         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14002         CHECK_ACCESS(_res_ptr);
14003         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
14004         FREE((void*)_res);
14005         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
14006 }
14007
14008 void  __attribute__((export_name("TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
14009         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
14010         _res_constr.datalen = _res->arr_len;
14011         if (_res_constr.datalen > 0)
14012                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
14013         else
14014                 _res_constr.data = NULL;
14015         uint32_t* _res_vals = _res->elems;
14016         for (size_t h = 0; h < _res_constr.datalen; h++) {
14017                 uint32_t _res_conv_59 = _res_vals[h];
14018                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
14019                 CHECK_ACCESS(_res_conv_59_ptr);
14020                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
14021                 FREE((void*)_res_conv_59);
14022                 _res_constr.data[h] = _res_conv_59_conv;
14023         }
14024         FREE(_res);
14025         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
14026 }
14027
14028 void  __attribute__((export_name("TS_CVec_NodeAnnouncementZ_free"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
14029         LDKCVec_NodeAnnouncementZ _res_constr;
14030         _res_constr.datalen = _res->arr_len;
14031         if (_res_constr.datalen > 0)
14032                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
14033         else
14034                 _res_constr.data = NULL;
14035         uint32_t* _res_vals = _res->elems;
14036         for (size_t s = 0; s < _res_constr.datalen; s++) {
14037                 uint32_t _res_conv_18 = _res_vals[s];
14038                 LDKNodeAnnouncement _res_conv_18_conv;
14039                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
14040                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
14041                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
14042                 _res_constr.data[s] = _res_conv_18_conv;
14043         }
14044         FREE(_res);
14045         CVec_NodeAnnouncementZ_free(_res_constr);
14046 }
14047
14048 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
14049         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14050         *ret_conv = CResult_NoneLightningErrorZ_ok();
14051         return (uint32_t)ret_conv;
14052 }
14053
14054 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
14055         LDKLightningError e_conv;
14056         e_conv.inner = (void*)(e & (~1));
14057         e_conv.is_owned = (e & 1) || (e == 0);
14058         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14059         e_conv = LightningError_clone(&e_conv);
14060         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14061         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
14062         return (uint32_t)ret_conv;
14063 }
14064
14065 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
14066         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
14067         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
14068         return ret_conv;
14069 }
14070
14071 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
14072         if ((_res & 1) != 0) return;
14073         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14074         CHECK_ACCESS(_res_ptr);
14075         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
14076         FREE((void*)_res);
14077         CResult_NoneLightningErrorZ_free(_res_conv);
14078 }
14079
14080 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
14081         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14082         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
14083         return (uint32_t)ret_conv;
14084 }
14085 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
14086         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
14087         uint32_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
14088         return ret_conv;
14089 }
14090
14091 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
14092         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
14093         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14094         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
14095         return (uint32_t)ret_conv;
14096 }
14097
14098 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok(uint32_t o) {
14099         LDKChannelUpdateInfo o_conv;
14100         o_conv.inner = (void*)(o & (~1));
14101         o_conv.is_owned = (o & 1) || (o == 0);
14102         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14103         o_conv = ChannelUpdateInfo_clone(&o_conv);
14104         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14105         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
14106         return (uint32_t)ret_conv;
14107 }
14108
14109 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_err(uint32_t e) {
14110         LDKDecodeError e_conv;
14111         e_conv.inner = (void*)(e & (~1));
14112         e_conv.is_owned = (e & 1) || (e == 0);
14113         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14114         e_conv = DecodeError_clone(&e_conv);
14115         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14116         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
14117         return (uint32_t)ret_conv;
14118 }
14119
14120 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(uint32_t o) {
14121         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
14122         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
14123         return ret_conv;
14124 }
14125
14126 void  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_free"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_free(uint32_t _res) {
14127         if ((_res & 1) != 0) return;
14128         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14129         CHECK_ACCESS(_res_ptr);
14130         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
14131         FREE((void*)_res);
14132         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
14133 }
14134
14135 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
14136         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14137         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
14138         return (uint32_t)ret_conv;
14139 }
14140 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14141         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
14142         uint32_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
14143         return ret_conv;
14144 }
14145
14146 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone(uint32_t orig) {
14147         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
14148         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14149         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
14150         return (uint32_t)ret_conv;
14151 }
14152
14153 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
14154         LDKChannelInfo o_conv;
14155         o_conv.inner = (void*)(o & (~1));
14156         o_conv.is_owned = (o & 1) || (o == 0);
14157         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14158         o_conv = ChannelInfo_clone(&o_conv);
14159         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14160         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
14161         return (uint32_t)ret_conv;
14162 }
14163
14164 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
14165         LDKDecodeError e_conv;
14166         e_conv.inner = (void*)(e & (~1));
14167         e_conv.is_owned = (e & 1) || (e == 0);
14168         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14169         e_conv = DecodeError_clone(&e_conv);
14170         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14171         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
14172         return (uint32_t)ret_conv;
14173 }
14174
14175 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
14176         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
14177         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
14178         return ret_conv;
14179 }
14180
14181 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
14182         if ((_res & 1) != 0) return;
14183         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14184         CHECK_ACCESS(_res_ptr);
14185         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
14186         FREE((void*)_res);
14187         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
14188 }
14189
14190 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
14191         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14192         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
14193         return (uint32_t)ret_conv;
14194 }
14195 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14196         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
14197         uint32_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
14198         return ret_conv;
14199 }
14200
14201 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
14202         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
14203         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14204         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
14205         return (uint32_t)ret_conv;
14206 }
14207
14208 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
14209         LDKRoutingFees o_conv;
14210         o_conv.inner = (void*)(o & (~1));
14211         o_conv.is_owned = (o & 1) || (o == 0);
14212         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14213         o_conv = RoutingFees_clone(&o_conv);
14214         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14215         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
14216         return (uint32_t)ret_conv;
14217 }
14218
14219 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
14220         LDKDecodeError e_conv;
14221         e_conv.inner = (void*)(e & (~1));
14222         e_conv.is_owned = (e & 1) || (e == 0);
14223         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14224         e_conv = DecodeError_clone(&e_conv);
14225         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14226         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
14227         return (uint32_t)ret_conv;
14228 }
14229
14230 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
14231         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
14232         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
14233         return ret_conv;
14234 }
14235
14236 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
14237         if ((_res & 1) != 0) return;
14238         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14239         CHECK_ACCESS(_res_ptr);
14240         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
14241         FREE((void*)_res);
14242         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
14243 }
14244
14245 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
14246         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14247         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
14248         return (uint32_t)ret_conv;
14249 }
14250 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
14251         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
14252         uint32_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
14253         return ret_conv;
14254 }
14255
14256 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
14257         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
14258         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14259         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
14260         return (uint32_t)ret_conv;
14261 }
14262
14263 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
14264         LDKCVec_NetAddressZ _res_constr;
14265         _res_constr.datalen = _res->arr_len;
14266         if (_res_constr.datalen > 0)
14267                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14268         else
14269                 _res_constr.data = NULL;
14270         uint32_t* _res_vals = _res->elems;
14271         for (size_t m = 0; m < _res_constr.datalen; m++) {
14272                 uint32_t _res_conv_12 = _res_vals[m];
14273                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
14274                 CHECK_ACCESS(_res_conv_12_ptr);
14275                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
14276                 FREE((void*)_res_conv_12);
14277                 _res_constr.data[m] = _res_conv_12_conv;
14278         }
14279         FREE(_res);
14280         CVec_NetAddressZ_free(_res_constr);
14281 }
14282
14283 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
14284         LDKNodeAnnouncementInfo o_conv;
14285         o_conv.inner = (void*)(o & (~1));
14286         o_conv.is_owned = (o & 1) || (o == 0);
14287         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14288         o_conv = NodeAnnouncementInfo_clone(&o_conv);
14289         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14290         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
14291         return (uint32_t)ret_conv;
14292 }
14293
14294 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
14295         LDKDecodeError e_conv;
14296         e_conv.inner = (void*)(e & (~1));
14297         e_conv.is_owned = (e & 1) || (e == 0);
14298         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14299         e_conv = DecodeError_clone(&e_conv);
14300         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14301         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
14302         return (uint32_t)ret_conv;
14303 }
14304
14305 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
14306         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
14307         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
14308         return ret_conv;
14309 }
14310
14311 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
14312         if ((_res & 1) != 0) return;
14313         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14314         CHECK_ACCESS(_res_ptr);
14315         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
14316         FREE((void*)_res);
14317         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
14318 }
14319
14320 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
14321         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14322         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
14323         return (uint32_t)ret_conv;
14324 }
14325 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14326         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
14327         uint32_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
14328         return ret_conv;
14329 }
14330
14331 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
14332         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
14333         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14334         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
14335         return (uint32_t)ret_conv;
14336 }
14337
14338 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_ok"))) TS_CResult_NodeAliasDecodeErrorZ_ok(uint32_t o) {
14339         LDKNodeAlias o_conv;
14340         o_conv.inner = (void*)(o & (~1));
14341         o_conv.is_owned = (o & 1) || (o == 0);
14342         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14343         o_conv = NodeAlias_clone(&o_conv);
14344         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14345         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
14346         return (uint32_t)ret_conv;
14347 }
14348
14349 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_err"))) TS_CResult_NodeAliasDecodeErrorZ_err(uint32_t e) {
14350         LDKDecodeError e_conv;
14351         e_conv.inner = (void*)(e & (~1));
14352         e_conv.is_owned = (e & 1) || (e == 0);
14353         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14354         e_conv = DecodeError_clone(&e_conv);
14355         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14356         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
14357         return (uint32_t)ret_conv;
14358 }
14359
14360 jboolean  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_is_ok"))) TS_CResult_NodeAliasDecodeErrorZ_is_ok(uint32_t o) {
14361         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(o & ~1);
14362         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
14363         return ret_conv;
14364 }
14365
14366 void  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_free"))) TS_CResult_NodeAliasDecodeErrorZ_free(uint32_t _res) {
14367         if ((_res & 1) != 0) return;
14368         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14369         CHECK_ACCESS(_res_ptr);
14370         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
14371         FREE((void*)_res);
14372         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
14373 }
14374
14375 static inline uintptr_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
14376         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14377         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
14378         return (uint32_t)ret_conv;
14379 }
14380 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAliasDecodeErrorZ_clone_ptr(uint32_t arg) {
14381         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(arg & ~1);
14382         uint32_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
14383         return ret_conv;
14384 }
14385
14386 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_clone"))) TS_CResult_NodeAliasDecodeErrorZ_clone(uint32_t orig) {
14387         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(orig & ~1);
14388         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14389         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
14390         return (uint32_t)ret_conv;
14391 }
14392
14393 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
14394         LDKCVec_u64Z _res_constr;
14395         _res_constr.datalen = _res->arr_len;
14396         if (_res_constr.datalen > 0)
14397                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14398         else
14399                 _res_constr.data = NULL;
14400         int64_t* _res_vals = _res->elems;
14401         for (size_t i = 0; i < _res_constr.datalen; i++) {
14402                 int64_t _res_conv_8 = _res_vals[i];
14403                 _res_constr.data[i] = _res_conv_8;
14404         }
14405         FREE(_res);
14406         CVec_u64Z_free(_res_constr);
14407 }
14408
14409 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
14410         LDKNodeInfo o_conv;
14411         o_conv.inner = (void*)(o & (~1));
14412         o_conv.is_owned = (o & 1) || (o == 0);
14413         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14414         o_conv = NodeInfo_clone(&o_conv);
14415         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14416         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
14417         return (uint32_t)ret_conv;
14418 }
14419
14420 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
14421         LDKDecodeError e_conv;
14422         e_conv.inner = (void*)(e & (~1));
14423         e_conv.is_owned = (e & 1) || (e == 0);
14424         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14425         e_conv = DecodeError_clone(&e_conv);
14426         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14427         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
14428         return (uint32_t)ret_conv;
14429 }
14430
14431 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
14432         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
14433         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
14434         return ret_conv;
14435 }
14436
14437 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
14438         if ((_res & 1) != 0) return;
14439         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14440         CHECK_ACCESS(_res_ptr);
14441         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
14442         FREE((void*)_res);
14443         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
14444 }
14445
14446 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
14447         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14448         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
14449         return (uint32_t)ret_conv;
14450 }
14451 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14452         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
14453         uint32_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
14454         return ret_conv;
14455 }
14456
14457 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
14458         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
14459         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14460         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
14461         return (uint32_t)ret_conv;
14462 }
14463
14464 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
14465         LDKNetworkGraph o_conv;
14466         o_conv.inner = (void*)(o & (~1));
14467         o_conv.is_owned = (o & 1) || (o == 0);
14468         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14469         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
14470         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14471         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
14472         return (uint32_t)ret_conv;
14473 }
14474
14475 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
14476         LDKDecodeError e_conv;
14477         e_conv.inner = (void*)(e & (~1));
14478         e_conv.is_owned = (e & 1) || (e == 0);
14479         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14480         e_conv = DecodeError_clone(&e_conv);
14481         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14482         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
14483         return (uint32_t)ret_conv;
14484 }
14485
14486 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
14487         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
14488         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
14489         return ret_conv;
14490 }
14491
14492 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
14493         if ((_res & 1) != 0) return;
14494         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14495         CHECK_ACCESS(_res_ptr);
14496         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
14497         FREE((void*)_res);
14498         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
14499 }
14500
14501 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
14502         LDKCVec_NetAddressZ o_constr;
14503         o_constr.datalen = o->arr_len;
14504         if (o_constr.datalen > 0)
14505                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14506         else
14507                 o_constr.data = NULL;
14508         uint32_t* o_vals = o->elems;
14509         for (size_t m = 0; m < o_constr.datalen; m++) {
14510                 uint32_t o_conv_12 = o_vals[m];
14511                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
14512                 CHECK_ACCESS(o_conv_12_ptr);
14513                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
14514                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
14515                 o_constr.data[m] = o_conv_12_conv;
14516         }
14517         FREE(o);
14518         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14519         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
14520         uint32_t ret_ref = (uintptr_t)ret_copy;
14521         return ret_ref;
14522 }
14523
14524 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
14525         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14526         *ret_copy = COption_CVec_NetAddressZZ_none();
14527         uint32_t ret_ref = (uintptr_t)ret_copy;
14528         return ret_ref;
14529 }
14530
14531 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
14532         if ((_res & 1) != 0) return;
14533         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14534         CHECK_ACCESS(_res_ptr);
14535         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
14536         FREE((void*)_res);
14537         COption_CVec_NetAddressZZ_free(_res_conv);
14538 }
14539
14540 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
14541         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14542         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
14543 uint32_t ret_ref = (uintptr_t)ret_copy;
14544         return ret_ref;
14545 }
14546 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
14547         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
14548         uint32_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
14549         return ret_conv;
14550 }
14551
14552 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
14553         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
14554         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14555         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
14556         uint32_t ret_ref = (uintptr_t)ret_copy;
14557         return ret_ref;
14558 }
14559
14560 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14561         LDKDelayedPaymentOutputDescriptor o_conv;
14562         o_conv.inner = (void*)(o & (~1));
14563         o_conv.is_owned = (o & 1) || (o == 0);
14564         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14565         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
14566         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14567         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14568         return (uint32_t)ret_conv;
14569 }
14570
14571 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14572         LDKDecodeError e_conv;
14573         e_conv.inner = (void*)(e & (~1));
14574         e_conv.is_owned = (e & 1) || (e == 0);
14575         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14576         e_conv = DecodeError_clone(&e_conv);
14577         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14578         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14579         return (uint32_t)ret_conv;
14580 }
14581
14582 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14583         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
14584         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14585         return ret_conv;
14586 }
14587
14588 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14589         if ((_res & 1) != 0) return;
14590         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14591         CHECK_ACCESS(_res_ptr);
14592         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
14593         FREE((void*)_res);
14594         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
14595 }
14596
14597 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14598         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14599         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
14600         return (uint32_t)ret_conv;
14601 }
14602 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
14603         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
14604         uint32_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14605         return ret_conv;
14606 }
14607
14608 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
14609         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
14610         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14611         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
14612         return (uint32_t)ret_conv;
14613 }
14614
14615 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14616         LDKStaticPaymentOutputDescriptor o_conv;
14617         o_conv.inner = (void*)(o & (~1));
14618         o_conv.is_owned = (o & 1) || (o == 0);
14619         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14620         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
14621         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14622         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14623         return (uint32_t)ret_conv;
14624 }
14625
14626 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14627         LDKDecodeError e_conv;
14628         e_conv.inner = (void*)(e & (~1));
14629         e_conv.is_owned = (e & 1) || (e == 0);
14630         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14631         e_conv = DecodeError_clone(&e_conv);
14632         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14633         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14634         return (uint32_t)ret_conv;
14635 }
14636
14637 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14638         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
14639         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14640         return ret_conv;
14641 }
14642
14643 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14644         if ((_res & 1) != 0) return;
14645         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14646         CHECK_ACCESS(_res_ptr);
14647         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
14648         FREE((void*)_res);
14649         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
14650 }
14651
14652 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14653         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14654         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
14655         return (uint32_t)ret_conv;
14656 }
14657 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
14658         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
14659         uint32_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14660         return ret_conv;
14661 }
14662
14663 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
14664         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
14665         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14666         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
14667         return (uint32_t)ret_conv;
14668 }
14669
14670 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14671         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14672         CHECK_ACCESS(o_ptr);
14673         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
14674         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
14675         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14676         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
14677         return (uint32_t)ret_conv;
14678 }
14679
14680 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14681         LDKDecodeError e_conv;
14682         e_conv.inner = (void*)(e & (~1));
14683         e_conv.is_owned = (e & 1) || (e == 0);
14684         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14685         e_conv = DecodeError_clone(&e_conv);
14686         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14687         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
14688         return (uint32_t)ret_conv;
14689 }
14690
14691 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14692         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
14693         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14694         return ret_conv;
14695 }
14696
14697 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14698         if ((_res & 1) != 0) return;
14699         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14700         CHECK_ACCESS(_res_ptr);
14701         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
14702         FREE((void*)_res);
14703         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
14704 }
14705
14706 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14707         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14708         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
14709         return (uint32_t)ret_conv;
14710 }
14711 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
14712         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
14713         uint32_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14714         return ret_conv;
14715 }
14716
14717 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
14718         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
14719         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14720         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
14721         return (uint32_t)ret_conv;
14722 }
14723
14724 void  __attribute__((export_name("TS_CVec_PaymentPreimageZ_free"))) TS_CVec_PaymentPreimageZ_free(ptrArray _res) {
14725         LDKCVec_PaymentPreimageZ _res_constr;
14726         _res_constr.datalen = _res->arr_len;
14727         if (_res_constr.datalen > 0)
14728                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
14729         else
14730                 _res_constr.data = NULL;
14731         int8_tArray* _res_vals = (void*) _res->elems;
14732         for (size_t m = 0; m < _res_constr.datalen; m++) {
14733                 int8_tArray _res_conv_12 = _res_vals[m];
14734                 LDKThirtyTwoBytes _res_conv_12_ref;
14735                 CHECK(_res_conv_12->arr_len == 32);
14736                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
14737                 _res_constr.data[m] = _res_conv_12_ref;
14738         }
14739         FREE(_res);
14740         CVec_PaymentPreimageZ_free(_res_constr);
14741 }
14742
14743 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
14744         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
14745         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
14746         return ((uint32_t)ret_conv);
14747 }
14748 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
14749         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
14750         uint32_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
14751         return ret_conv;
14752 }
14753
14754 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
14755         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
14756         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
14757         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
14758         return ((uint32_t)ret_conv);
14759 }
14760
14761 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
14762         LDKSignature a_ref;
14763         CHECK(a->arr_len == 64);
14764         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
14765         LDKCVec_SignatureZ b_constr;
14766         b_constr.datalen = b->arr_len;
14767         if (b_constr.datalen > 0)
14768                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14769         else
14770                 b_constr.data = NULL;
14771         int8_tArray* b_vals = (void*) b->elems;
14772         for (size_t m = 0; m < b_constr.datalen; m++) {
14773                 int8_tArray b_conv_12 = b_vals[m];
14774                 LDKSignature b_conv_12_ref;
14775                 CHECK(b_conv_12->arr_len == 64);
14776                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64); FREE(b_conv_12);
14777                 b_constr.data[m] = b_conv_12_ref;
14778         }
14779         FREE(b);
14780         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
14781         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
14782         return ((uint32_t)ret_conv);
14783 }
14784
14785 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
14786         if ((_res & 1) != 0) return;
14787         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14788         CHECK_ACCESS(_res_ptr);
14789         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
14790         FREE((void*)_res);
14791         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
14792 }
14793
14794 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
14795         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14796         CHECK_ACCESS(o_ptr);
14797         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
14798         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
14799         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
14800         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
14801         return (uint32_t)ret_conv;
14802 }
14803
14804 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
14805         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
14806         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
14807         return (uint32_t)ret_conv;
14808 }
14809
14810 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
14811         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
14812         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
14813         return ret_conv;
14814 }
14815
14816 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
14817         if ((_res & 1) != 0) return;
14818         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14819         CHECK_ACCESS(_res_ptr);
14820         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
14821         FREE((void*)_res);
14822         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
14823 }
14824
14825 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
14826         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
14827         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
14828         return (uint32_t)ret_conv;
14829 }
14830 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
14831         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
14832         uint32_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
14833         return ret_conv;
14834 }
14835
14836 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
14837         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
14838         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
14839         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
14840         return (uint32_t)ret_conv;
14841 }
14842
14843 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
14844         LDKSignature o_ref;
14845         CHECK(o->arr_len == 64);
14846         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
14847         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
14848         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
14849         return (uint32_t)ret_conv;
14850 }
14851
14852 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
14853         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
14854         *ret_conv = CResult_SignatureNoneZ_err();
14855         return (uint32_t)ret_conv;
14856 }
14857
14858 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
14859         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
14860         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
14861         return ret_conv;
14862 }
14863
14864 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
14865         if ((_res & 1) != 0) return;
14866         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14867         CHECK_ACCESS(_res_ptr);
14868         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
14869         FREE((void*)_res);
14870         CResult_SignatureNoneZ_free(_res_conv);
14871 }
14872
14873 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
14874         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
14875         *ret_conv = CResult_SignatureNoneZ_clone(arg);
14876         return (uint32_t)ret_conv;
14877 }
14878 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
14879         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
14880         uint32_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
14881         return ret_conv;
14882 }
14883
14884 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
14885         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
14886         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
14887         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
14888         return (uint32_t)ret_conv;
14889 }
14890
14891 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
14892         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
14893         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
14894         return ((uint32_t)ret_conv);
14895 }
14896 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone_ptr"))) TS_C2Tuple_SignatureSignatureZ_clone_ptr(uint32_t arg) {
14897         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
14898         uint32_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
14899         return ret_conv;
14900 }
14901
14902 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone"))) TS_C2Tuple_SignatureSignatureZ_clone(uint32_t orig) {
14903         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
14904         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
14905         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
14906         return ((uint32_t)ret_conv);
14907 }
14908
14909 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_new"))) TS_C2Tuple_SignatureSignatureZ_new(int8_tArray a, int8_tArray b) {
14910         LDKSignature a_ref;
14911         CHECK(a->arr_len == 64);
14912         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
14913         LDKSignature b_ref;
14914         CHECK(b->arr_len == 64);
14915         memcpy(b_ref.compact_form, b->elems, 64); FREE(b);
14916         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
14917         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
14918         return ((uint32_t)ret_conv);
14919 }
14920
14921 void  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_free"))) TS_C2Tuple_SignatureSignatureZ_free(uint32_t _res) {
14922         if ((_res & 1) != 0) return;
14923         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14924         CHECK_ACCESS(_res_ptr);
14925         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
14926         FREE((void*)_res);
14927         C2Tuple_SignatureSignatureZ_free(_res_conv);
14928 }
14929
14930 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok(uint32_t o) {
14931         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14932         CHECK_ACCESS(o_ptr);
14933         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
14934         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
14935         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
14936         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
14937         return (uint32_t)ret_conv;
14938 }
14939
14940 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err() {
14941         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
14942         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
14943         return (uint32_t)ret_conv;
14944 }
14945
14946 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(uint32_t o) {
14947         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
14948         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
14949         return ret_conv;
14950 }
14951
14952 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free(uint32_t _res) {
14953         if ((_res & 1) != 0) return;
14954         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14955         CHECK_ACCESS(_res_ptr);
14956         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
14957         FREE((void*)_res);
14958         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
14959 }
14960
14961 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
14962         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
14963         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
14964         return (uint32_t)ret_conv;
14965 }
14966 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(uint32_t arg) {
14967         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
14968         uint32_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
14969         return ret_conv;
14970 }
14971
14972 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone(uint32_t orig) {
14973         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
14974         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
14975         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
14976         return (uint32_t)ret_conv;
14977 }
14978
14979 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_ok"))) TS_CResult_SecretKeyNoneZ_ok(int8_tArray o) {
14980         LDKSecretKey o_ref;
14981         CHECK(o->arr_len == 32);
14982         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
14983         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
14984         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
14985         return (uint32_t)ret_conv;
14986 }
14987
14988 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_err"))) TS_CResult_SecretKeyNoneZ_err() {
14989         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
14990         *ret_conv = CResult_SecretKeyNoneZ_err();
14991         return (uint32_t)ret_conv;
14992 }
14993
14994 jboolean  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_is_ok"))) TS_CResult_SecretKeyNoneZ_is_ok(uint32_t o) {
14995         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
14996         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
14997         return ret_conv;
14998 }
14999
15000 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_free"))) TS_CResult_SecretKeyNoneZ_free(uint32_t _res) {
15001         if ((_res & 1) != 0) return;
15002         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15003         CHECK_ACCESS(_res_ptr);
15004         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
15005         FREE((void*)_res);
15006         CResult_SecretKeyNoneZ_free(_res_conv);
15007 }
15008
15009 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
15010         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15011         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
15012         return (uint32_t)ret_conv;
15013 }
15014 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone_ptr"))) TS_CResult_SecretKeyNoneZ_clone_ptr(uint32_t arg) {
15015         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
15016         uint32_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
15017         return ret_conv;
15018 }
15019
15020 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone"))) TS_CResult_SecretKeyNoneZ_clone(uint32_t orig) {
15021         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
15022         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15023         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
15024         return (uint32_t)ret_conv;
15025 }
15026
15027 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
15028         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15029         CHECK_ACCESS(o_ptr);
15030         LDKSign o_conv = *(LDKSign*)(o_ptr);
15031         if (o_conv.free == LDKSign_JCalls_free) {
15032                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15033                 LDKSign_JCalls_cloned(&o_conv);
15034         }
15035         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15036         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
15037         return (uint32_t)ret_conv;
15038 }
15039
15040 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
15041         LDKDecodeError e_conv;
15042         e_conv.inner = (void*)(e & (~1));
15043         e_conv.is_owned = (e & 1) || (e == 0);
15044         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15045         e_conv = DecodeError_clone(&e_conv);
15046         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15047         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
15048         return (uint32_t)ret_conv;
15049 }
15050
15051 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
15052         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
15053         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
15054         return ret_conv;
15055 }
15056
15057 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
15058         if ((_res & 1) != 0) return;
15059         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15060         CHECK_ACCESS(_res_ptr);
15061         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
15062         FREE((void*)_res);
15063         CResult_SignDecodeErrorZ_free(_res_conv);
15064 }
15065
15066 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
15067         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15068         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
15069         return (uint32_t)ret_conv;
15070 }
15071 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
15072         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
15073         uint32_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
15074         return ret_conv;
15075 }
15076
15077 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
15078         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
15079         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15080         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
15081         return (uint32_t)ret_conv;
15082 }
15083
15084 void  __attribute__((export_name("TS_CVec_u5Z_free"))) TS_CVec_u5Z_free(ptrArray _res) {
15085         LDKCVec_u5Z _res_constr;
15086         _res_constr.datalen = _res->arr_len;
15087         if (_res_constr.datalen > 0)
15088                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
15089         else
15090                 _res_constr.data = NULL;
15091         int8_t* _res_vals = (void*) _res->elems;
15092         for (size_t h = 0; h < _res_constr.datalen; h++) {
15093                 int8_t _res_conv_7 = _res_vals[h];
15094                 
15095                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
15096         }
15097         FREE(_res);
15098         CVec_u5Z_free(_res_constr);
15099 }
15100
15101 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
15102         LDKRecoverableSignature o_ref;
15103         CHECK(o->arr_len == 68);
15104         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
15105         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15106         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
15107         return (uint32_t)ret_conv;
15108 }
15109
15110 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
15111         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15112         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
15113         return (uint32_t)ret_conv;
15114 }
15115
15116 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
15117         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
15118         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
15119         return ret_conv;
15120 }
15121
15122 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
15123         if ((_res & 1) != 0) return;
15124         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15125         CHECK_ACCESS(_res_ptr);
15126         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
15127         FREE((void*)_res);
15128         CResult_RecoverableSignatureNoneZ_free(_res_conv);
15129 }
15130
15131 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
15132         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15133         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
15134         return (uint32_t)ret_conv;
15135 }
15136 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
15137         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
15138         uint32_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
15139         return ret_conv;
15140 }
15141
15142 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
15143         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
15144         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15145         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
15146         return (uint32_t)ret_conv;
15147 }
15148
15149 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
15150         LDKCVec_u8Z _res_ref;
15151         _res_ref.datalen = _res->arr_len;
15152         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
15153         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
15154         CVec_u8Z_free(_res_ref);
15155 }
15156
15157 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
15158         LDKCVec_CVec_u8ZZ _res_constr;
15159         _res_constr.datalen = _res->arr_len;
15160         if (_res_constr.datalen > 0)
15161                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15162         else
15163                 _res_constr.data = NULL;
15164         int8_tArray* _res_vals = (void*) _res->elems;
15165         for (size_t m = 0; m < _res_constr.datalen; m++) {
15166                 int8_tArray _res_conv_12 = _res_vals[m];
15167                 LDKCVec_u8Z _res_conv_12_ref;
15168                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
15169                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15170                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
15171                 _res_constr.data[m] = _res_conv_12_ref;
15172         }
15173         FREE(_res);
15174         CVec_CVec_u8ZZ_free(_res_constr);
15175 }
15176
15177 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
15178         LDKCVec_CVec_u8ZZ o_constr;
15179         o_constr.datalen = o->arr_len;
15180         if (o_constr.datalen > 0)
15181                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15182         else
15183                 o_constr.data = NULL;
15184         int8_tArray* o_vals = (void*) o->elems;
15185         for (size_t m = 0; m < o_constr.datalen; m++) {
15186                 int8_tArray o_conv_12 = o_vals[m];
15187                 LDKCVec_u8Z o_conv_12_ref;
15188                 o_conv_12_ref.datalen = o_conv_12->arr_len;
15189                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15190                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen); FREE(o_conv_12);
15191                 o_constr.data[m] = o_conv_12_ref;
15192         }
15193         FREE(o);
15194         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15195         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
15196         return (uint32_t)ret_conv;
15197 }
15198
15199 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
15200         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15201         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
15202         return (uint32_t)ret_conv;
15203 }
15204
15205 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
15206         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
15207         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
15208         return ret_conv;
15209 }
15210
15211 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
15212         if ((_res & 1) != 0) return;
15213         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15214         CHECK_ACCESS(_res_ptr);
15215         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
15216         FREE((void*)_res);
15217         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
15218 }
15219
15220 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
15221         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15222         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
15223         return (uint32_t)ret_conv;
15224 }
15225 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
15226         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
15227         uint32_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
15228         return ret_conv;
15229 }
15230
15231 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
15232         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
15233         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15234         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
15235         return (uint32_t)ret_conv;
15236 }
15237
15238 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
15239         LDKInMemorySigner o_conv;
15240         o_conv.inner = (void*)(o & (~1));
15241         o_conv.is_owned = (o & 1) || (o == 0);
15242         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15243         o_conv = InMemorySigner_clone(&o_conv);
15244         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15245         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
15246         return (uint32_t)ret_conv;
15247 }
15248
15249 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
15250         LDKDecodeError e_conv;
15251         e_conv.inner = (void*)(e & (~1));
15252         e_conv.is_owned = (e & 1) || (e == 0);
15253         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15254         e_conv = DecodeError_clone(&e_conv);
15255         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15256         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
15257         return (uint32_t)ret_conv;
15258 }
15259
15260 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
15261         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
15262         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
15263         return ret_conv;
15264 }
15265
15266 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
15267         if ((_res & 1) != 0) return;
15268         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15269         CHECK_ACCESS(_res_ptr);
15270         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
15271         FREE((void*)_res);
15272         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
15273 }
15274
15275 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
15276         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15277         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
15278         return (uint32_t)ret_conv;
15279 }
15280 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
15281         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
15282         uint32_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
15283         return ret_conv;
15284 }
15285
15286 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
15287         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
15288         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15289         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
15290         return (uint32_t)ret_conv;
15291 }
15292
15293 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
15294         LDKCVec_TxOutZ _res_constr;
15295         _res_constr.datalen = _res->arr_len;
15296         if (_res_constr.datalen > 0)
15297                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15298         else
15299                 _res_constr.data = NULL;
15300         uint32_t* _res_vals = _res->elems;
15301         for (size_t h = 0; h < _res_constr.datalen; h++) {
15302                 uint32_t _res_conv_7 = _res_vals[h];
15303                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
15304                 CHECK_ACCESS(_res_conv_7_ptr);
15305                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
15306                 FREE((void*)_res_conv_7);
15307                 _res_constr.data[h] = _res_conv_7_conv;
15308         }
15309         FREE(_res);
15310         CVec_TxOutZ_free(_res_constr);
15311 }
15312
15313 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
15314         LDKTransaction o_ref;
15315         o_ref.datalen = o->arr_len;
15316         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
15317         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
15318         o_ref.data_is_owned = true;
15319         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15320         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
15321         return (uint32_t)ret_conv;
15322 }
15323
15324 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
15325         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15326         *ret_conv = CResult_TransactionNoneZ_err();
15327         return (uint32_t)ret_conv;
15328 }
15329
15330 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
15331         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
15332         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
15333         return ret_conv;
15334 }
15335
15336 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
15337         if ((_res & 1) != 0) return;
15338         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15339         CHECK_ACCESS(_res_ptr);
15340         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
15341         FREE((void*)_res);
15342         CResult_TransactionNoneZ_free(_res_conv);
15343 }
15344
15345 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
15346         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15347         *ret_conv = CResult_TransactionNoneZ_clone(arg);
15348         return (uint32_t)ret_conv;
15349 }
15350 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
15351         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
15352         uint32_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
15353         return ret_conv;
15354 }
15355
15356 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
15357         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
15358         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15359         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
15360         return (uint32_t)ret_conv;
15361 }
15362
15363 uint32_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
15364         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15365         *ret_copy = COption_u16Z_some(o);
15366         uint32_t ret_ref = (uintptr_t)ret_copy;
15367         return ret_ref;
15368 }
15369
15370 uint32_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
15371         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15372         *ret_copy = COption_u16Z_none();
15373         uint32_t ret_ref = (uintptr_t)ret_copy;
15374         return ret_ref;
15375 }
15376
15377 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint32_t _res) {
15378         if ((_res & 1) != 0) return;
15379         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15380         CHECK_ACCESS(_res_ptr);
15381         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
15382         FREE((void*)_res);
15383         COption_u16Z_free(_res_conv);
15384 }
15385
15386 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
15387         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15388         *ret_copy = COption_u16Z_clone(arg);
15389 uint32_t ret_ref = (uintptr_t)ret_copy;
15390         return ret_ref;
15391 }
15392 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
15393         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
15394         uint32_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
15395         return ret_conv;
15396 }
15397
15398 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint32_t orig) {
15399         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
15400         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15401         *ret_copy = COption_u16Z_clone(orig_conv);
15402         uint32_t ret_ref = (uintptr_t)ret_copy;
15403         return ret_ref;
15404 }
15405
15406 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
15407         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15408         *ret_conv = CResult_NoneAPIErrorZ_ok();
15409         return (uint32_t)ret_conv;
15410 }
15411
15412 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
15413         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15414         CHECK_ACCESS(e_ptr);
15415         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15416         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15417         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15418         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
15419         return (uint32_t)ret_conv;
15420 }
15421
15422 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
15423         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
15424         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
15425         return ret_conv;
15426 }
15427
15428 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
15429         if ((_res & 1) != 0) return;
15430         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15431         CHECK_ACCESS(_res_ptr);
15432         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
15433         FREE((void*)_res);
15434         CResult_NoneAPIErrorZ_free(_res_conv);
15435 }
15436
15437 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
15438         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15439         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
15440         return (uint32_t)ret_conv;
15441 }
15442 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
15443         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
15444         uint32_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
15445         return ret_conv;
15446 }
15447
15448 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
15449         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
15450         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15451         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
15452         return (uint32_t)ret_conv;
15453 }
15454
15455 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
15456         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
15457         _res_constr.datalen = _res->arr_len;
15458         if (_res_constr.datalen > 0)
15459                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15460         else
15461                 _res_constr.data = NULL;
15462         uint32_t* _res_vals = _res->elems;
15463         for (size_t w = 0; w < _res_constr.datalen; w++) {
15464                 uint32_t _res_conv_22 = _res_vals[w];
15465                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
15466                 CHECK_ACCESS(_res_conv_22_ptr);
15467                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
15468                 FREE((void*)_res_conv_22);
15469                 _res_constr.data[w] = _res_conv_22_conv;
15470         }
15471         FREE(_res);
15472         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
15473 }
15474
15475 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
15476         LDKCVec_APIErrorZ _res_constr;
15477         _res_constr.datalen = _res->arr_len;
15478         if (_res_constr.datalen > 0)
15479                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
15480         else
15481                 _res_constr.data = NULL;
15482         uint32_t* _res_vals = _res->elems;
15483         for (size_t k = 0; k < _res_constr.datalen; k++) {
15484                 uint32_t _res_conv_10 = _res_vals[k];
15485                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
15486                 CHECK_ACCESS(_res_conv_10_ptr);
15487                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
15488                 FREE((void*)_res_conv_10);
15489                 _res_constr.data[k] = _res_conv_10_conv;
15490         }
15491         FREE(_res);
15492         CVec_APIErrorZ_free(_res_constr);
15493 }
15494
15495 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
15496         LDKThirtyTwoBytes o_ref;
15497         CHECK(o->arr_len == 32);
15498         memcpy(o_ref.data, o->elems, 32); FREE(o);
15499         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15500         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
15501         return (uint32_t)ret_conv;
15502 }
15503
15504 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
15505         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15506         CHECK_ACCESS(e_ptr);
15507         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15508         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15509         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15510         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
15511         return (uint32_t)ret_conv;
15512 }
15513
15514 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
15515         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
15516         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
15517         return ret_conv;
15518 }
15519
15520 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
15521         if ((_res & 1) != 0) return;
15522         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15523         CHECK_ACCESS(_res_ptr);
15524         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
15525         FREE((void*)_res);
15526         CResult__u832APIErrorZ_free(_res_conv);
15527 }
15528
15529 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
15530         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15531         *ret_conv = CResult__u832APIErrorZ_clone(arg);
15532         return (uint32_t)ret_conv;
15533 }
15534 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
15535         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
15536         uint32_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
15537         return ret_conv;
15538 }
15539
15540 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
15541         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
15542         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15543         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
15544         return (uint32_t)ret_conv;
15545 }
15546
15547 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
15548         LDKThirtyTwoBytes o_ref;
15549         CHECK(o->arr_len == 32);
15550         memcpy(o_ref.data, o->elems, 32); FREE(o);
15551         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15552         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
15553         return (uint32_t)ret_conv;
15554 }
15555
15556 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
15557         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15558         CHECK_ACCESS(e_ptr);
15559         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15560         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15561         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15562         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
15563         return (uint32_t)ret_conv;
15564 }
15565
15566 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
15567         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
15568         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
15569         return ret_conv;
15570 }
15571
15572 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
15573         if ((_res & 1) != 0) return;
15574         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15575         CHECK_ACCESS(_res_ptr);
15576         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
15577         FREE((void*)_res);
15578         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
15579 }
15580
15581 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
15582         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15583         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
15584         return (uint32_t)ret_conv;
15585 }
15586 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
15587         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
15588         uint32_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
15589         return ret_conv;
15590 }
15591
15592 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
15593         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
15594         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15595         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
15596         return (uint32_t)ret_conv;
15597 }
15598
15599 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
15600         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15601         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
15602         return (uint32_t)ret_conv;
15603 }
15604
15605 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
15606         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15607         CHECK_ACCESS(e_ptr);
15608         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15609         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15610         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15611         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
15612         return (uint32_t)ret_conv;
15613 }
15614
15615 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
15616         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
15617         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
15618         return ret_conv;
15619 }
15620
15621 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
15622         if ((_res & 1) != 0) return;
15623         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15624         CHECK_ACCESS(_res_ptr);
15625         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
15626         FREE((void*)_res);
15627         CResult_NonePaymentSendFailureZ_free(_res_conv);
15628 }
15629
15630 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
15631         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15632         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
15633         return (uint32_t)ret_conv;
15634 }
15635 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
15636         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
15637         uint32_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
15638         return ret_conv;
15639 }
15640
15641 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
15642         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
15643         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15644         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
15645         return (uint32_t)ret_conv;
15646 }
15647
15648 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
15649         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15650         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
15651         return ((uint32_t)ret_conv);
15652 }
15653 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
15654         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
15655         uint32_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
15656         return ret_conv;
15657 }
15658
15659 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
15660         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
15661         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15662         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
15663         return ((uint32_t)ret_conv);
15664 }
15665
15666 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
15667         LDKThirtyTwoBytes a_ref;
15668         CHECK(a->arr_len == 32);
15669         memcpy(a_ref.data, a->elems, 32); FREE(a);
15670         LDKThirtyTwoBytes b_ref;
15671         CHECK(b->arr_len == 32);
15672         memcpy(b_ref.data, b->elems, 32); FREE(b);
15673         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15674         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
15675         return ((uint32_t)ret_conv);
15676 }
15677
15678 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
15679         if ((_res & 1) != 0) return;
15680         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15681         CHECK_ACCESS(_res_ptr);
15682         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
15683         FREE((void*)_res);
15684         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
15685 }
15686
15687 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
15688         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15689         CHECK_ACCESS(o_ptr);
15690         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
15691         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
15692         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15693         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
15694         return (uint32_t)ret_conv;
15695 }
15696
15697 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
15698         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15699         CHECK_ACCESS(e_ptr);
15700         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15701         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15702         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15703         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
15704         return (uint32_t)ret_conv;
15705 }
15706
15707 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
15708         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
15709         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
15710         return ret_conv;
15711 }
15712
15713 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
15714         if ((_res & 1) != 0) return;
15715         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15716         CHECK_ACCESS(_res_ptr);
15717         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
15718         FREE((void*)_res);
15719         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
15720 }
15721
15722 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
15723         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15724         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
15725         return (uint32_t)ret_conv;
15726 }
15727 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
15728         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
15729         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
15730         return ret_conv;
15731 }
15732
15733 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
15734         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
15735         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15736         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
15737         return (uint32_t)ret_conv;
15738 }
15739
15740 void  __attribute__((export_name("TS_CVec_ThirtyTwoBytesZ_free"))) TS_CVec_ThirtyTwoBytesZ_free(ptrArray _res) {
15741         LDKCVec_ThirtyTwoBytesZ _res_constr;
15742         _res_constr.datalen = _res->arr_len;
15743         if (_res_constr.datalen > 0)
15744                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
15745         else
15746                 _res_constr.data = NULL;
15747         int8_tArray* _res_vals = (void*) _res->elems;
15748         for (size_t m = 0; m < _res_constr.datalen; m++) {
15749                 int8_tArray _res_conv_12 = _res_vals[m];
15750                 LDKThirtyTwoBytes _res_conv_12_ref;
15751                 CHECK(_res_conv_12->arr_len == 32);
15752                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
15753                 _res_constr.data[m] = _res_conv_12_ref;
15754         }
15755         FREE(_res);
15756         CVec_ThirtyTwoBytesZ_free(_res_constr);
15757 }
15758
15759 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
15760         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15761         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
15762         return ((uint32_t)ret_conv);
15763 }
15764 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
15765         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
15766         uint32_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
15767         return ret_conv;
15768 }
15769
15770 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
15771         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
15772         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15773         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
15774         return ((uint32_t)ret_conv);
15775 }
15776
15777 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
15778         LDKThirtyTwoBytes a_ref;
15779         CHECK(a->arr_len == 32);
15780         memcpy(a_ref.data, a->elems, 32); FREE(a);
15781         LDKThirtyTwoBytes b_ref;
15782         CHECK(b->arr_len == 32);
15783         memcpy(b_ref.data, b->elems, 32); FREE(b);
15784         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15785         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
15786         return ((uint32_t)ret_conv);
15787 }
15788
15789 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
15790         if ((_res & 1) != 0) return;
15791         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15792         CHECK_ACCESS(_res_ptr);
15793         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
15794         FREE((void*)_res);
15795         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
15796 }
15797
15798 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
15799         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15800         CHECK_ACCESS(o_ptr);
15801         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
15802         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
15803         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
15804         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
15805         return (uint32_t)ret_conv;
15806 }
15807
15808 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
15809         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
15810         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
15811         return (uint32_t)ret_conv;
15812 }
15813
15814 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
15815         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
15816         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
15817         return ret_conv;
15818 }
15819
15820 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
15821         if ((_res & 1) != 0) return;
15822         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15823         CHECK_ACCESS(_res_ptr);
15824         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
15825         FREE((void*)_res);
15826         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
15827 }
15828
15829 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
15830         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
15831         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
15832         return (uint32_t)ret_conv;
15833 }
15834 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
15835         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
15836         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
15837         return ret_conv;
15838 }
15839
15840 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
15841         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
15842         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
15843         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
15844         return (uint32_t)ret_conv;
15845 }
15846
15847 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
15848         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15849         CHECK_ACCESS(o_ptr);
15850         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
15851         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
15852         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
15853         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
15854         return (uint32_t)ret_conv;
15855 }
15856
15857 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
15858         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15859         CHECK_ACCESS(e_ptr);
15860         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15861         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15862         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
15863         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
15864         return (uint32_t)ret_conv;
15865 }
15866
15867 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
15868         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
15869         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
15870         return ret_conv;
15871 }
15872
15873 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
15874         if ((_res & 1) != 0) return;
15875         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15876         CHECK_ACCESS(_res_ptr);
15877         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
15878         FREE((void*)_res);
15879         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
15880 }
15881
15882 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
15883         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
15884         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
15885         return (uint32_t)ret_conv;
15886 }
15887 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
15888         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
15889         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
15890         return ret_conv;
15891 }
15892
15893 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
15894         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
15895         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
15896         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
15897         return (uint32_t)ret_conv;
15898 }
15899
15900 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
15901         LDKThirtyTwoBytes o_ref;
15902         CHECK(o->arr_len == 32);
15903         memcpy(o_ref.data, o->elems, 32); FREE(o);
15904         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
15905         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
15906         return (uint32_t)ret_conv;
15907 }
15908
15909 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
15910         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
15911         *ret_conv = CResult_PaymentSecretNoneZ_err();
15912         return (uint32_t)ret_conv;
15913 }
15914
15915 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
15916         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
15917         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
15918         return ret_conv;
15919 }
15920
15921 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
15922         if ((_res & 1) != 0) return;
15923         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15924         CHECK_ACCESS(_res_ptr);
15925         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
15926         FREE((void*)_res);
15927         CResult_PaymentSecretNoneZ_free(_res_conv);
15928 }
15929
15930 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
15931         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
15932         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
15933         return (uint32_t)ret_conv;
15934 }
15935 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
15936         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
15937         uint32_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
15938         return ret_conv;
15939 }
15940
15941 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
15942         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
15943         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
15944         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
15945         return (uint32_t)ret_conv;
15946 }
15947
15948 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
15949         LDKThirtyTwoBytes o_ref;
15950         CHECK(o->arr_len == 32);
15951         memcpy(o_ref.data, o->elems, 32); FREE(o);
15952         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15953         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
15954         return (uint32_t)ret_conv;
15955 }
15956
15957 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
15958         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15959         CHECK_ACCESS(e_ptr);
15960         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15961         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15962         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15963         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
15964         return (uint32_t)ret_conv;
15965 }
15966
15967 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
15968         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
15969         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
15970         return ret_conv;
15971 }
15972
15973 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
15974         if ((_res & 1) != 0) return;
15975         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15976         CHECK_ACCESS(_res_ptr);
15977         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
15978         FREE((void*)_res);
15979         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
15980 }
15981
15982 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
15983         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15984         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
15985         return (uint32_t)ret_conv;
15986 }
15987 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
15988         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
15989         uint32_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
15990         return ret_conv;
15991 }
15992
15993 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
15994         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
15995         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15996         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
15997         return (uint32_t)ret_conv;
15998 }
15999
16000 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
16001         LDKThirtyTwoBytes o_ref;
16002         CHECK(o->arr_len == 32);
16003         memcpy(o_ref.data, o->elems, 32); FREE(o);
16004         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16005         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
16006         return (uint32_t)ret_conv;
16007 }
16008
16009 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
16010         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16011         CHECK_ACCESS(e_ptr);
16012         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16013         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16014         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16015         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
16016         return (uint32_t)ret_conv;
16017 }
16018
16019 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
16020         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
16021         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
16022         return ret_conv;
16023 }
16024
16025 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
16026         if ((_res & 1) != 0) return;
16027         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16028         CHECK_ACCESS(_res_ptr);
16029         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
16030         FREE((void*)_res);
16031         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
16032 }
16033
16034 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
16035         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16036         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
16037         return (uint32_t)ret_conv;
16038 }
16039 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
16040         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
16041         uint32_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
16042         return ret_conv;
16043 }
16044
16045 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
16046         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
16047         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16048         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
16049         return (uint32_t)ret_conv;
16050 }
16051
16052 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(uint32_t o) {
16053         LDKCounterpartyForwardingInfo o_conv;
16054         o_conv.inner = (void*)(o & (~1));
16055         o_conv.is_owned = (o & 1) || (o == 0);
16056         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16057         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
16058         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16059         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
16060         return (uint32_t)ret_conv;
16061 }
16062
16063 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err(uint32_t e) {
16064         LDKDecodeError e_conv;
16065         e_conv.inner = (void*)(e & (~1));
16066         e_conv.is_owned = (e & 1) || (e == 0);
16067         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16068         e_conv = DecodeError_clone(&e_conv);
16069         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16070         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
16071         return (uint32_t)ret_conv;
16072 }
16073
16074 jboolean  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(uint32_t o) {
16075         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
16076         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
16077         return ret_conv;
16078 }
16079
16080 void  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free(uint32_t _res) {
16081         if ((_res & 1) != 0) return;
16082         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16083         CHECK_ACCESS(_res_ptr);
16084         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
16085         FREE((void*)_res);
16086         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
16087 }
16088
16089 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
16090         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16091         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
16092         return (uint32_t)ret_conv;
16093 }
16094 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16095         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
16096         uint32_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
16097         return ret_conv;
16098 }
16099
16100 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(uint32_t orig) {
16101         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
16102         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16103         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
16104         return (uint32_t)ret_conv;
16105 }
16106
16107 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_ok(uint32_t o) {
16108         LDKChannelCounterparty o_conv;
16109         o_conv.inner = (void*)(o & (~1));
16110         o_conv.is_owned = (o & 1) || (o == 0);
16111         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16112         o_conv = ChannelCounterparty_clone(&o_conv);
16113         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16114         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
16115         return (uint32_t)ret_conv;
16116 }
16117
16118 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_err(uint32_t e) {
16119         LDKDecodeError e_conv;
16120         e_conv.inner = (void*)(e & (~1));
16121         e_conv.is_owned = (e & 1) || (e == 0);
16122         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16123         e_conv = DecodeError_clone(&e_conv);
16124         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16125         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
16126         return (uint32_t)ret_conv;
16127 }
16128
16129 jboolean  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok(uint32_t o) {
16130         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
16131         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
16132         return ret_conv;
16133 }
16134
16135 void  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_free"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_free(uint32_t _res) {
16136         if ((_res & 1) != 0) return;
16137         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16138         CHECK_ACCESS(_res_ptr);
16139         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
16140         FREE((void*)_res);
16141         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
16142 }
16143
16144 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
16145         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16146         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
16147         return (uint32_t)ret_conv;
16148 }
16149 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(uint32_t arg) {
16150         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
16151         uint32_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
16152         return ret_conv;
16153 }
16154
16155 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone(uint32_t orig) {
16156         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
16157         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16158         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
16159         return (uint32_t)ret_conv;
16160 }
16161
16162 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_ok(uint32_t o) {
16163         LDKChannelDetails o_conv;
16164         o_conv.inner = (void*)(o & (~1));
16165         o_conv.is_owned = (o & 1) || (o == 0);
16166         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16167         o_conv = ChannelDetails_clone(&o_conv);
16168         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16169         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
16170         return (uint32_t)ret_conv;
16171 }
16172
16173 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_err(uint32_t e) {
16174         LDKDecodeError e_conv;
16175         e_conv.inner = (void*)(e & (~1));
16176         e_conv.is_owned = (e & 1) || (e == 0);
16177         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16178         e_conv = DecodeError_clone(&e_conv);
16179         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16180         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
16181         return (uint32_t)ret_conv;
16182 }
16183
16184 jboolean  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_is_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_is_ok(uint32_t o) {
16185         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
16186         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
16187         return ret_conv;
16188 }
16189
16190 void  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_free"))) TS_CResult_ChannelDetailsDecodeErrorZ_free(uint32_t _res) {
16191         if ((_res & 1) != 0) return;
16192         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16193         CHECK_ACCESS(_res_ptr);
16194         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
16195         FREE((void*)_res);
16196         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
16197 }
16198
16199 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
16200         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16201         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
16202         return (uint32_t)ret_conv;
16203 }
16204 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr(uint32_t arg) {
16205         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
16206         uint32_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
16207         return ret_conv;
16208 }
16209
16210 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone(uint32_t orig) {
16211         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
16212         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16213         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
16214         return (uint32_t)ret_conv;
16215 }
16216
16217 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_ok(uint32_t o) {
16218         LDKPhantomRouteHints o_conv;
16219         o_conv.inner = (void*)(o & (~1));
16220         o_conv.is_owned = (o & 1) || (o == 0);
16221         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16222         o_conv = PhantomRouteHints_clone(&o_conv);
16223         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16224         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
16225         return (uint32_t)ret_conv;
16226 }
16227
16228 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_err(uint32_t e) {
16229         LDKDecodeError e_conv;
16230         e_conv.inner = (void*)(e & (~1));
16231         e_conv.is_owned = (e & 1) || (e == 0);
16232         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16233         e_conv = DecodeError_clone(&e_conv);
16234         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16235         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
16236         return (uint32_t)ret_conv;
16237 }
16238
16239 jboolean  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok(uint32_t o) {
16240         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
16241         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
16242         return ret_conv;
16243 }
16244
16245 void  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_free"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_free(uint32_t _res) {
16246         if ((_res & 1) != 0) return;
16247         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16248         CHECK_ACCESS(_res_ptr);
16249         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
16250         FREE((void*)_res);
16251         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
16252 }
16253
16254 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
16255         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16256         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
16257         return (uint32_t)ret_conv;
16258 }
16259 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(uint32_t arg) {
16260         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
16261         uint32_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
16262         return ret_conv;
16263 }
16264
16265 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone(uint32_t orig) {
16266         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
16267         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16268         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
16269         return (uint32_t)ret_conv;
16270 }
16271
16272 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
16273         LDKCVec_ChannelMonitorZ _res_constr;
16274         _res_constr.datalen = _res->arr_len;
16275         if (_res_constr.datalen > 0)
16276                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16277         else
16278                 _res_constr.data = NULL;
16279         uint32_t* _res_vals = _res->elems;
16280         for (size_t q = 0; q < _res_constr.datalen; q++) {
16281                 uint32_t _res_conv_16 = _res_vals[q];
16282                 LDKChannelMonitor _res_conv_16_conv;
16283                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
16284                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
16285                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
16286                 _res_constr.data[q] = _res_conv_16_conv;
16287         }
16288         FREE(_res);
16289         CVec_ChannelMonitorZ_free(_res_constr);
16290 }
16291
16292 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
16293         LDKThirtyTwoBytes a_ref;
16294         CHECK(a->arr_len == 32);
16295         memcpy(a_ref.data, a->elems, 32); FREE(a);
16296         LDKChannelManager b_conv;
16297         b_conv.inner = (void*)(b & (~1));
16298         b_conv.is_owned = (b & 1) || (b == 0);
16299         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16300         // WARNING: we need a move here but no clone is available for LDKChannelManager
16301         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
16302         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
16303         return ((uint32_t)ret_conv);
16304 }
16305
16306 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
16307         if ((_res & 1) != 0) return;
16308         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16309         CHECK_ACCESS(_res_ptr);
16310         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
16311         FREE((void*)_res);
16312         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
16313 }
16314
16315 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
16316         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16317         CHECK_ACCESS(o_ptr);
16318         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
16319         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
16320         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16321         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
16322         return (uint32_t)ret_conv;
16323 }
16324
16325 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
16326         LDKDecodeError e_conv;
16327         e_conv.inner = (void*)(e & (~1));
16328         e_conv.is_owned = (e & 1) || (e == 0);
16329         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16330         e_conv = DecodeError_clone(&e_conv);
16331         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16332         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
16333         return (uint32_t)ret_conv;
16334 }
16335
16336 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
16337         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
16338         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
16339         return ret_conv;
16340 }
16341
16342 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
16343         if ((_res & 1) != 0) return;
16344         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16345         CHECK_ACCESS(_res_ptr);
16346         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
16347         FREE((void*)_res);
16348         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
16349 }
16350
16351 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
16352         LDKChannelConfig o_conv;
16353         o_conv.inner = (void*)(o & (~1));
16354         o_conv.is_owned = (o & 1) || (o == 0);
16355         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16356         o_conv = ChannelConfig_clone(&o_conv);
16357         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16358         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
16359         return (uint32_t)ret_conv;
16360 }
16361
16362 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
16363         LDKDecodeError e_conv;
16364         e_conv.inner = (void*)(e & (~1));
16365         e_conv.is_owned = (e & 1) || (e == 0);
16366         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16367         e_conv = DecodeError_clone(&e_conv);
16368         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16369         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
16370         return (uint32_t)ret_conv;
16371 }
16372
16373 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
16374         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
16375         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
16376         return ret_conv;
16377 }
16378
16379 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
16380         if ((_res & 1) != 0) return;
16381         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16382         CHECK_ACCESS(_res_ptr);
16383         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
16384         FREE((void*)_res);
16385         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
16386 }
16387
16388 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
16389         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16390         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
16391         return (uint32_t)ret_conv;
16392 }
16393 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
16394         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
16395         uint32_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
16396         return ret_conv;
16397 }
16398
16399 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
16400         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
16401         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16402         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
16403         return (uint32_t)ret_conv;
16404 }
16405
16406 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
16407         LDKOutPoint o_conv;
16408         o_conv.inner = (void*)(o & (~1));
16409         o_conv.is_owned = (o & 1) || (o == 0);
16410         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16411         o_conv = OutPoint_clone(&o_conv);
16412         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16413         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
16414         return (uint32_t)ret_conv;
16415 }
16416
16417 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
16418         LDKDecodeError e_conv;
16419         e_conv.inner = (void*)(e & (~1));
16420         e_conv.is_owned = (e & 1) || (e == 0);
16421         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16422         e_conv = DecodeError_clone(&e_conv);
16423         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16424         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
16425         return (uint32_t)ret_conv;
16426 }
16427
16428 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
16429         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
16430         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
16431         return ret_conv;
16432 }
16433
16434 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
16435         if ((_res & 1) != 0) return;
16436         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16437         CHECK_ACCESS(_res_ptr);
16438         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
16439         FREE((void*)_res);
16440         CResult_OutPointDecodeErrorZ_free(_res_conv);
16441 }
16442
16443 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
16444         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16445         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
16446         return (uint32_t)ret_conv;
16447 }
16448 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
16449         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
16450         uint32_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
16451         return ret_conv;
16452 }
16453
16454 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
16455         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
16456         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16457         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
16458         return (uint32_t)ret_conv;
16459 }
16460
16461 uint32_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint32_t o) {
16462         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16463         CHECK_ACCESS(o_ptr);
16464         LDKType o_conv = *(LDKType*)(o_ptr);
16465         if (o_conv.free == LDKType_JCalls_free) {
16466                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16467                 LDKType_JCalls_cloned(&o_conv);
16468         }
16469         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16470         *ret_copy = COption_TypeZ_some(o_conv);
16471         uint32_t ret_ref = (uintptr_t)ret_copy;
16472         return ret_ref;
16473 }
16474
16475 uint32_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
16476         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16477         *ret_copy = COption_TypeZ_none();
16478         uint32_t ret_ref = (uintptr_t)ret_copy;
16479         return ret_ref;
16480 }
16481
16482 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint32_t _res) {
16483         if ((_res & 1) != 0) return;
16484         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16485         CHECK_ACCESS(_res_ptr);
16486         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
16487         FREE((void*)_res);
16488         COption_TypeZ_free(_res_conv);
16489 }
16490
16491 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
16492         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16493         *ret_copy = COption_TypeZ_clone(arg);
16494 uint32_t ret_ref = (uintptr_t)ret_copy;
16495         return ret_ref;
16496 }
16497 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
16498         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
16499         uint32_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
16500         return ret_conv;
16501 }
16502
16503 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint32_t orig) {
16504         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
16505         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16506         *ret_copy = COption_TypeZ_clone(orig_conv);
16507         uint32_t ret_ref = (uintptr_t)ret_copy;
16508         return ret_ref;
16509 }
16510
16511 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
16512         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16513         CHECK_ACCESS(o_ptr);
16514         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
16515         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
16516         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16517         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
16518         return (uint32_t)ret_conv;
16519 }
16520
16521 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
16522         LDKDecodeError e_conv;
16523         e_conv.inner = (void*)(e & (~1));
16524         e_conv.is_owned = (e & 1) || (e == 0);
16525         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16526         e_conv = DecodeError_clone(&e_conv);
16527         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16528         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
16529         return (uint32_t)ret_conv;
16530 }
16531
16532 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
16533         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
16534         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
16535         return ret_conv;
16536 }
16537
16538 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
16539         if ((_res & 1) != 0) return;
16540         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16541         CHECK_ACCESS(_res_ptr);
16542         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
16543         FREE((void*)_res);
16544         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
16545 }
16546
16547 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
16548         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16549         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
16550         return (uint32_t)ret_conv;
16551 }
16552 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
16553         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
16554         uint32_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
16555         return ret_conv;
16556 }
16557
16558 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
16559         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
16560         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16561         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
16562         return (uint32_t)ret_conv;
16563 }
16564
16565 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_ok"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
16566         LDKThirtyTwoBytes o_ref;
16567         CHECK(o->arr_len == 32);
16568         memcpy(o_ref.data, o->elems, 32); FREE(o);
16569         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16570         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
16571         return (uint32_t)ret_conv;
16572 }
16573
16574 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_err"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
16575         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16576         CHECK_ACCESS(e_ptr);
16577         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
16578         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
16579         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16580         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
16581         return (uint32_t)ret_conv;
16582 }
16583
16584 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_is_ok"))) TS_CResult_PaymentIdPaymentErrorZ_is_ok(uint32_t o) {
16585         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
16586         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
16587         return ret_conv;
16588 }
16589
16590 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_free"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
16591         if ((_res & 1) != 0) return;
16592         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16593         CHECK_ACCESS(_res_ptr);
16594         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
16595         FREE((void*)_res);
16596         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
16597 }
16598
16599 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
16600         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16601         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
16602         return (uint32_t)ret_conv;
16603 }
16604 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone_ptr"))) TS_CResult_PaymentIdPaymentErrorZ_clone_ptr(uint32_t arg) {
16605         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
16606         uint32_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
16607         return ret_conv;
16608 }
16609
16610 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
16611         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
16612         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16613         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
16614         return (uint32_t)ret_conv;
16615 }
16616
16617 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_ok"))) TS_CResult_SiPrefixParseErrorZ_ok(uint32_t o) {
16618         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
16619         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
16620         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
16621         return (uint32_t)ret_conv;
16622 }
16623
16624 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_err"))) TS_CResult_SiPrefixParseErrorZ_err(uint32_t e) {
16625         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16626         CHECK_ACCESS(e_ptr);
16627         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
16628         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
16629         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
16630         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
16631         return (uint32_t)ret_conv;
16632 }
16633
16634 jboolean  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_is_ok"))) TS_CResult_SiPrefixParseErrorZ_is_ok(uint32_t o) {
16635         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
16636         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
16637         return ret_conv;
16638 }
16639
16640 void  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_free"))) TS_CResult_SiPrefixParseErrorZ_free(uint32_t _res) {
16641         if ((_res & 1) != 0) return;
16642         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16643         CHECK_ACCESS(_res_ptr);
16644         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
16645         FREE((void*)_res);
16646         CResult_SiPrefixParseErrorZ_free(_res_conv);
16647 }
16648
16649 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
16650         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
16651         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
16652         return (uint32_t)ret_conv;
16653 }
16654 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone_ptr"))) TS_CResult_SiPrefixParseErrorZ_clone_ptr(uint32_t arg) {
16655         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
16656         uint32_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
16657         return ret_conv;
16658 }
16659
16660 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone"))) TS_CResult_SiPrefixParseErrorZ_clone(uint32_t orig) {
16661         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
16662         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
16663         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
16664         return (uint32_t)ret_conv;
16665 }
16666
16667 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_ok(uint32_t o) {
16668         LDKInvoice o_conv;
16669         o_conv.inner = (void*)(o & (~1));
16670         o_conv.is_owned = (o & 1) || (o == 0);
16671         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16672         o_conv = Invoice_clone(&o_conv);
16673         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
16674         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
16675         return (uint32_t)ret_conv;
16676 }
16677
16678 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_err(uint32_t e) {
16679         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16680         CHECK_ACCESS(e_ptr);
16681         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
16682         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
16683         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
16684         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
16685         return (uint32_t)ret_conv;
16686 }
16687
16688 jboolean  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok(uint32_t o) {
16689         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
16690         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
16691         return ret_conv;
16692 }
16693
16694 void  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_free"))) TS_CResult_InvoiceParseOrSemanticErrorZ_free(uint32_t _res) {
16695         if ((_res & 1) != 0) return;
16696         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16697         CHECK_ACCESS(_res_ptr);
16698         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
16699         FREE((void*)_res);
16700         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
16701 }
16702
16703 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
16704         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
16705         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
16706         return (uint32_t)ret_conv;
16707 }
16708 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(uint32_t arg) {
16709         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
16710         uint32_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
16711         return ret_conv;
16712 }
16713
16714 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone(uint32_t orig) {
16715         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
16716         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
16717         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
16718         return (uint32_t)ret_conv;
16719 }
16720
16721 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_ok(uint32_t o) {
16722         LDKSignedRawInvoice o_conv;
16723         o_conv.inner = (void*)(o & (~1));
16724         o_conv.is_owned = (o & 1) || (o == 0);
16725         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16726         o_conv = SignedRawInvoice_clone(&o_conv);
16727         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
16728         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
16729         return (uint32_t)ret_conv;
16730 }
16731
16732 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_err(uint32_t e) {
16733         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16734         CHECK_ACCESS(e_ptr);
16735         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
16736         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
16737         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
16738         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
16739         return (uint32_t)ret_conv;
16740 }
16741
16742 jboolean  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_is_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_is_ok(uint32_t o) {
16743         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
16744         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
16745         return ret_conv;
16746 }
16747
16748 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_free"))) TS_CResult_SignedRawInvoiceParseErrorZ_free(uint32_t _res) {
16749         if ((_res & 1) != 0) return;
16750         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16751         CHECK_ACCESS(_res_ptr);
16752         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
16753         FREE((void*)_res);
16754         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
16755 }
16756
16757 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
16758         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
16759         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
16760         return (uint32_t)ret_conv;
16761 }
16762 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr(uint32_t arg) {
16763         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
16764         uint32_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
16765         return ret_conv;
16766 }
16767
16768 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone(uint32_t orig) {
16769         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
16770         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
16771         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
16772         return (uint32_t)ret_conv;
16773 }
16774
16775 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
16776         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
16777         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
16778         return ((uint32_t)ret_conv);
16779 }
16780 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(uint32_t arg) {
16781         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
16782         uint32_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
16783         return ret_conv;
16784 }
16785
16786 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
16787         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
16788         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
16789         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
16790         return ((uint32_t)ret_conv);
16791 }
16792
16793 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
16794         LDKRawInvoice a_conv;
16795         a_conv.inner = (void*)(a & (~1));
16796         a_conv.is_owned = (a & 1) || (a == 0);
16797         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16798         a_conv = RawInvoice_clone(&a_conv);
16799         LDKThirtyTwoBytes b_ref;
16800         CHECK(b->arr_len == 32);
16801         memcpy(b_ref.data, b->elems, 32); FREE(b);
16802         LDKInvoiceSignature c_conv;
16803         c_conv.inner = (void*)(c & (~1));
16804         c_conv.is_owned = (c & 1) || (c == 0);
16805         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
16806         c_conv = InvoiceSignature_clone(&c_conv);
16807         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
16808         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
16809         return ((uint32_t)ret_conv);
16810 }
16811
16812 void  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
16813         if ((_res & 1) != 0) return;
16814         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16815         CHECK_ACCESS(_res_ptr);
16816         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
16817         FREE((void*)_res);
16818         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
16819 }
16820
16821 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_ok"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
16822         LDKPayeePubKey o_conv;
16823         o_conv.inner = (void*)(o & (~1));
16824         o_conv.is_owned = (o & 1) || (o == 0);
16825         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16826         o_conv = PayeePubKey_clone(&o_conv);
16827         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
16828         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
16829         return (uint32_t)ret_conv;
16830 }
16831
16832 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_err"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
16833         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
16834         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
16835         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
16836         return (uint32_t)ret_conv;
16837 }
16838
16839 jboolean  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_is_ok"))) TS_CResult_PayeePubKeyErrorZ_is_ok(uint32_t o) {
16840         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
16841         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
16842         return ret_conv;
16843 }
16844
16845 void  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_free"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
16846         if ((_res & 1) != 0) return;
16847         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16848         CHECK_ACCESS(_res_ptr);
16849         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
16850         FREE((void*)_res);
16851         CResult_PayeePubKeyErrorZ_free(_res_conv);
16852 }
16853
16854 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
16855         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
16856         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
16857         return (uint32_t)ret_conv;
16858 }
16859 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone_ptr"))) TS_CResult_PayeePubKeyErrorZ_clone_ptr(uint32_t arg) {
16860         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
16861         uint32_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
16862         return ret_conv;
16863 }
16864
16865 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
16866         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
16867         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
16868         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
16869         return (uint32_t)ret_conv;
16870 }
16871
16872 void  __attribute__((export_name("TS_CVec_PrivateRouteZ_free"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
16873         LDKCVec_PrivateRouteZ _res_constr;
16874         _res_constr.datalen = _res->arr_len;
16875         if (_res_constr.datalen > 0)
16876                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
16877         else
16878                 _res_constr.data = NULL;
16879         uint32_t* _res_vals = _res->elems;
16880         for (size_t o = 0; o < _res_constr.datalen; o++) {
16881                 uint32_t _res_conv_14 = _res_vals[o];
16882                 LDKPrivateRoute _res_conv_14_conv;
16883                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
16884                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
16885                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
16886                 _res_constr.data[o] = _res_conv_14_conv;
16887         }
16888         FREE(_res);
16889         CVec_PrivateRouteZ_free(_res_constr);
16890 }
16891
16892 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
16893         LDKPositiveTimestamp o_conv;
16894         o_conv.inner = (void*)(o & (~1));
16895         o_conv.is_owned = (o & 1) || (o == 0);
16896         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16897         o_conv = PositiveTimestamp_clone(&o_conv);
16898         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
16899         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
16900         return (uint32_t)ret_conv;
16901 }
16902
16903 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_err"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
16904         LDKCreationError e_conv = LDKCreationError_from_js(e);
16905         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
16906         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
16907         return (uint32_t)ret_conv;
16908 }
16909
16910 jboolean  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_is_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_is_ok(uint32_t o) {
16911         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
16912         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
16913         return ret_conv;
16914 }
16915
16916 void  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_free"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
16917         if ((_res & 1) != 0) return;
16918         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16919         CHECK_ACCESS(_res_ptr);
16920         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
16921         FREE((void*)_res);
16922         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
16923 }
16924
16925 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
16926         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
16927         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
16928         return (uint32_t)ret_conv;
16929 }
16930 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr"))) TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr(uint32_t arg) {
16931         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
16932         uint32_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
16933         return ret_conv;
16934 }
16935
16936 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
16937         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
16938         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
16939         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
16940         return (uint32_t)ret_conv;
16941 }
16942
16943 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_ok"))) TS_CResult_NoneSemanticErrorZ_ok() {
16944         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
16945         *ret_conv = CResult_NoneSemanticErrorZ_ok();
16946         return (uint32_t)ret_conv;
16947 }
16948
16949 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_err"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
16950         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
16951         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
16952         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
16953         return (uint32_t)ret_conv;
16954 }
16955
16956 jboolean  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_is_ok"))) TS_CResult_NoneSemanticErrorZ_is_ok(uint32_t o) {
16957         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
16958         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
16959         return ret_conv;
16960 }
16961
16962 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_free"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
16963         if ((_res & 1) != 0) return;
16964         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16965         CHECK_ACCESS(_res_ptr);
16966         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
16967         FREE((void*)_res);
16968         CResult_NoneSemanticErrorZ_free(_res_conv);
16969 }
16970
16971 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
16972         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
16973         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
16974         return (uint32_t)ret_conv;
16975 }
16976 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone_ptr"))) TS_CResult_NoneSemanticErrorZ_clone_ptr(uint32_t arg) {
16977         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
16978         uint32_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
16979         return ret_conv;
16980 }
16981
16982 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
16983         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
16984         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
16985         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
16986         return (uint32_t)ret_conv;
16987 }
16988
16989 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_ok"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
16990         LDKInvoice o_conv;
16991         o_conv.inner = (void*)(o & (~1));
16992         o_conv.is_owned = (o & 1) || (o == 0);
16993         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16994         o_conv = Invoice_clone(&o_conv);
16995         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
16996         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
16997         return (uint32_t)ret_conv;
16998 }
16999
17000 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_err"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
17001         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
17002         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17003         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
17004         return (uint32_t)ret_conv;
17005 }
17006
17007 jboolean  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_is_ok"))) TS_CResult_InvoiceSemanticErrorZ_is_ok(uint32_t o) {
17008         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
17009         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
17010         return ret_conv;
17011 }
17012
17013 void  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_free"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
17014         if ((_res & 1) != 0) return;
17015         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17016         CHECK_ACCESS(_res_ptr);
17017         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
17018         FREE((void*)_res);
17019         CResult_InvoiceSemanticErrorZ_free(_res_conv);
17020 }
17021
17022 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
17023         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17024         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
17025         return (uint32_t)ret_conv;
17026 }
17027 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceSemanticErrorZ_clone_ptr(uint32_t arg) {
17028         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
17029         uint32_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
17030         return ret_conv;
17031 }
17032
17033 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
17034         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
17035         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17036         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
17037         return (uint32_t)ret_conv;
17038 }
17039
17040 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_ok"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
17041         LDKDescription o_conv;
17042         o_conv.inner = (void*)(o & (~1));
17043         o_conv.is_owned = (o & 1) || (o == 0);
17044         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17045         o_conv = Description_clone(&o_conv);
17046         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17047         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
17048         return (uint32_t)ret_conv;
17049 }
17050
17051 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_err"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
17052         LDKCreationError e_conv = LDKCreationError_from_js(e);
17053         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17054         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
17055         return (uint32_t)ret_conv;
17056 }
17057
17058 jboolean  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_is_ok"))) TS_CResult_DescriptionCreationErrorZ_is_ok(uint32_t o) {
17059         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
17060         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
17061         return ret_conv;
17062 }
17063
17064 void  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_free"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
17065         if ((_res & 1) != 0) return;
17066         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17067         CHECK_ACCESS(_res_ptr);
17068         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
17069         FREE((void*)_res);
17070         CResult_DescriptionCreationErrorZ_free(_res_conv);
17071 }
17072
17073 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
17074         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17075         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
17076         return (uint32_t)ret_conv;
17077 }
17078 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone_ptr"))) TS_CResult_DescriptionCreationErrorZ_clone_ptr(uint32_t arg) {
17079         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
17080         uint32_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
17081         return ret_conv;
17082 }
17083
17084 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
17085         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
17086         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17087         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
17088         return (uint32_t)ret_conv;
17089 }
17090
17091 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_ok"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
17092         LDKPrivateRoute o_conv;
17093         o_conv.inner = (void*)(o & (~1));
17094         o_conv.is_owned = (o & 1) || (o == 0);
17095         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17096         o_conv = PrivateRoute_clone(&o_conv);
17097         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17098         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
17099         return (uint32_t)ret_conv;
17100 }
17101
17102 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_err"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
17103         LDKCreationError e_conv = LDKCreationError_from_js(e);
17104         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17105         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
17106         return (uint32_t)ret_conv;
17107 }
17108
17109 jboolean  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_is_ok"))) TS_CResult_PrivateRouteCreationErrorZ_is_ok(uint32_t o) {
17110         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
17111         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
17112         return ret_conv;
17113 }
17114
17115 void  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_free"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
17116         if ((_res & 1) != 0) return;
17117         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17118         CHECK_ACCESS(_res_ptr);
17119         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
17120         FREE((void*)_res);
17121         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
17122 }
17123
17124 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
17125         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17126         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
17127         return (uint32_t)ret_conv;
17128 }
17129 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone_ptr"))) TS_CResult_PrivateRouteCreationErrorZ_clone_ptr(uint32_t arg) {
17130         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
17131         uint32_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
17132         return ret_conv;
17133 }
17134
17135 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
17136         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
17137         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17138         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
17139         return (uint32_t)ret_conv;
17140 }
17141
17142 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
17143         LDKStr o_conv = str_ref_to_owned_c(o);
17144         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17145         *ret_conv = CResult_StringErrorZ_ok(o_conv);
17146         return (uint32_t)ret_conv;
17147 }
17148
17149 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
17150         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
17151         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17152         *ret_conv = CResult_StringErrorZ_err(e_conv);
17153         return (uint32_t)ret_conv;
17154 }
17155
17156 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
17157         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
17158         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
17159         return ret_conv;
17160 }
17161
17162 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
17163         if ((_res & 1) != 0) return;
17164         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17165         CHECK_ACCESS(_res_ptr);
17166         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
17167         FREE((void*)_res);
17168         CResult_StringErrorZ_free(_res_conv);
17169 }
17170
17171 static inline uintptr_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
17172         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17173         *ret_conv = CResult_StringErrorZ_clone(arg);
17174         return (uint32_t)ret_conv;
17175 }
17176 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_clone_ptr"))) TS_CResult_StringErrorZ_clone_ptr(uint32_t arg) {
17177         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)(arg & ~1);
17178         uint32_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
17179         return ret_conv;
17180 }
17181
17182 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_clone"))) TS_CResult_StringErrorZ_clone(uint32_t orig) {
17183         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)(orig & ~1);
17184         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17185         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
17186         return (uint32_t)ret_conv;
17187 }
17188
17189 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
17190         LDKChannelMonitorUpdate o_conv;
17191         o_conv.inner = (void*)(o & (~1));
17192         o_conv.is_owned = (o & 1) || (o == 0);
17193         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17194         o_conv = ChannelMonitorUpdate_clone(&o_conv);
17195         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17196         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
17197         return (uint32_t)ret_conv;
17198 }
17199
17200 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
17201         LDKDecodeError e_conv;
17202         e_conv.inner = (void*)(e & (~1));
17203         e_conv.is_owned = (e & 1) || (e == 0);
17204         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17205         e_conv = DecodeError_clone(&e_conv);
17206         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17207         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
17208         return (uint32_t)ret_conv;
17209 }
17210
17211 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
17212         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
17213         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
17214         return ret_conv;
17215 }
17216
17217 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
17218         if ((_res & 1) != 0) return;
17219         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17220         CHECK_ACCESS(_res_ptr);
17221         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
17222         FREE((void*)_res);
17223         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
17224 }
17225
17226 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
17227         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17228         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
17229         return (uint32_t)ret_conv;
17230 }
17231 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
17232         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
17233         uint32_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
17234         return ret_conv;
17235 }
17236
17237 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
17238         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
17239         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17240         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
17241         return (uint32_t)ret_conv;
17242 }
17243
17244 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint32_t o) {
17245         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17246         CHECK_ACCESS(o_ptr);
17247         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
17248         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
17249         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17250         *ret_copy = COption_MonitorEventZ_some(o_conv);
17251         uint32_t ret_ref = (uintptr_t)ret_copy;
17252         return ret_ref;
17253 }
17254
17255 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
17256         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17257         *ret_copy = COption_MonitorEventZ_none();
17258         uint32_t ret_ref = (uintptr_t)ret_copy;
17259         return ret_ref;
17260 }
17261
17262 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
17263         if ((_res & 1) != 0) return;
17264         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17265         CHECK_ACCESS(_res_ptr);
17266         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
17267         FREE((void*)_res);
17268         COption_MonitorEventZ_free(_res_conv);
17269 }
17270
17271 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
17272         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17273         *ret_copy = COption_MonitorEventZ_clone(arg);
17274 uint32_t ret_ref = (uintptr_t)ret_copy;
17275         return ret_ref;
17276 }
17277 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
17278         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
17279         uint32_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
17280         return ret_conv;
17281 }
17282
17283 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
17284         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
17285         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17286         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
17287         uint32_t ret_ref = (uintptr_t)ret_copy;
17288         return ret_ref;
17289 }
17290
17291 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
17292         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17293         CHECK_ACCESS(o_ptr);
17294         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
17295         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
17296         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17297         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
17298         return (uint32_t)ret_conv;
17299 }
17300
17301 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
17302         LDKDecodeError e_conv;
17303         e_conv.inner = (void*)(e & (~1));
17304         e_conv.is_owned = (e & 1) || (e == 0);
17305         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17306         e_conv = DecodeError_clone(&e_conv);
17307         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17308         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
17309         return (uint32_t)ret_conv;
17310 }
17311
17312 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
17313         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
17314         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
17315         return ret_conv;
17316 }
17317
17318 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
17319         if ((_res & 1) != 0) return;
17320         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17321         CHECK_ACCESS(_res_ptr);
17322         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
17323         FREE((void*)_res);
17324         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
17325 }
17326
17327 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
17328         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17329         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
17330         return (uint32_t)ret_conv;
17331 }
17332 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
17333         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
17334         uint32_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
17335         return ret_conv;
17336 }
17337
17338 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
17339         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
17340         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17341         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
17342         return (uint32_t)ret_conv;
17343 }
17344
17345 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
17346         LDKHTLCUpdate o_conv;
17347         o_conv.inner = (void*)(o & (~1));
17348         o_conv.is_owned = (o & 1) || (o == 0);
17349         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17350         o_conv = HTLCUpdate_clone(&o_conv);
17351         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17352         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
17353         return (uint32_t)ret_conv;
17354 }
17355
17356 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
17357         LDKDecodeError e_conv;
17358         e_conv.inner = (void*)(e & (~1));
17359         e_conv.is_owned = (e & 1) || (e == 0);
17360         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17361         e_conv = DecodeError_clone(&e_conv);
17362         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17363         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
17364         return (uint32_t)ret_conv;
17365 }
17366
17367 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
17368         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
17369         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
17370         return ret_conv;
17371 }
17372
17373 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
17374         if ((_res & 1) != 0) return;
17375         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17376         CHECK_ACCESS(_res_ptr);
17377         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
17378         FREE((void*)_res);
17379         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
17380 }
17381
17382 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
17383         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17384         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
17385         return (uint32_t)ret_conv;
17386 }
17387 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
17388         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
17389         uint32_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
17390         return ret_conv;
17391 }
17392
17393 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
17394         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
17395         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17396         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
17397         return (uint32_t)ret_conv;
17398 }
17399
17400 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
17401         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17402         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
17403         return ((uint32_t)ret_conv);
17404 }
17405 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone_ptr"))) TS_C2Tuple_OutPointScriptZ_clone_ptr(uint32_t arg) {
17406         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
17407         uint32_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
17408         return ret_conv;
17409 }
17410
17411 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
17412         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
17413         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17414         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
17415         return ((uint32_t)ret_conv);
17416 }
17417
17418 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
17419         LDKOutPoint a_conv;
17420         a_conv.inner = (void*)(a & (~1));
17421         a_conv.is_owned = (a & 1) || (a == 0);
17422         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17423         a_conv = OutPoint_clone(&a_conv);
17424         LDKCVec_u8Z b_ref;
17425         b_ref.datalen = b->arr_len;
17426         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
17427         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
17428         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17429         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
17430         return ((uint32_t)ret_conv);
17431 }
17432
17433 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
17434         if ((_res & 1) != 0) return;
17435         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17436         CHECK_ACCESS(_res_ptr);
17437         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
17438         FREE((void*)_res);
17439         C2Tuple_OutPointScriptZ_free(_res_conv);
17440 }
17441
17442 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
17443         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17444         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
17445         return ((uint32_t)ret_conv);
17446 }
17447 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone_ptr"))) TS_C2Tuple_u32ScriptZ_clone_ptr(uint32_t arg) {
17448         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
17449         uint32_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
17450         return ret_conv;
17451 }
17452
17453 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
17454         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
17455         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17456         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
17457         return ((uint32_t)ret_conv);
17458 }
17459
17460 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
17461         LDKCVec_u8Z b_ref;
17462         b_ref.datalen = b->arr_len;
17463         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
17464         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
17465         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17466         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
17467         return ((uint32_t)ret_conv);
17468 }
17469
17470 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
17471         if ((_res & 1) != 0) return;
17472         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17473         CHECK_ACCESS(_res_ptr);
17474         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
17475         FREE((void*)_res);
17476         C2Tuple_u32ScriptZ_free(_res_conv);
17477 }
17478
17479 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
17480         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
17481         _res_constr.datalen = _res->arr_len;
17482         if (_res_constr.datalen > 0)
17483                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
17484         else
17485                 _res_constr.data = NULL;
17486         uint32_t* _res_vals = _res->elems;
17487         for (size_t v = 0; v < _res_constr.datalen; v++) {
17488                 uint32_t _res_conv_21 = _res_vals[v];
17489                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
17490                 CHECK_ACCESS(_res_conv_21_ptr);
17491                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
17492                 FREE((void*)_res_conv_21);
17493                 _res_constr.data[v] = _res_conv_21_conv;
17494         }
17495         FREE(_res);
17496         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
17497 }
17498
17499 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
17500         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17501         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
17502         return ((uint32_t)ret_conv);
17503 }
17504 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(uint32_t arg) {
17505         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
17506         uint32_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
17507         return ret_conv;
17508 }
17509
17510 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
17511         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
17512         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17513         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
17514         return ((uint32_t)ret_conv);
17515 }
17516
17517 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
17518         LDKThirtyTwoBytes a_ref;
17519         CHECK(a->arr_len == 32);
17520         memcpy(a_ref.data, a->elems, 32); FREE(a);
17521         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
17522         b_constr.datalen = b->arr_len;
17523         if (b_constr.datalen > 0)
17524                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
17525         else
17526                 b_constr.data = NULL;
17527         uint32_t* b_vals = b->elems;
17528         for (size_t v = 0; v < b_constr.datalen; v++) {
17529                 uint32_t b_conv_21 = b_vals[v];
17530                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
17531                 CHECK_ACCESS(b_conv_21_ptr);
17532                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
17533                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
17534                 b_constr.data[v] = b_conv_21_conv;
17535         }
17536         FREE(b);
17537         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17538         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
17539         return ((uint32_t)ret_conv);
17540 }
17541
17542 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
17543         if ((_res & 1) != 0) return;
17544         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17545         CHECK_ACCESS(_res_ptr);
17546         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
17547         FREE((void*)_res);
17548         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
17549 }
17550
17551 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
17552         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
17553         _res_constr.datalen = _res->arr_len;
17554         if (_res_constr.datalen > 0)
17555                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
17556         else
17557                 _res_constr.data = NULL;
17558         uint32_t* _res_vals = _res->elems;
17559         for (size_t o = 0; o < _res_constr.datalen; o++) {
17560                 uint32_t _res_conv_40 = _res_vals[o];
17561                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
17562                 CHECK_ACCESS(_res_conv_40_ptr);
17563                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
17564                 FREE((void*)_res_conv_40);
17565                 _res_constr.data[o] = _res_conv_40_conv;
17566         }
17567         FREE(_res);
17568         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
17569 }
17570
17571 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint32_tArray _res) {
17572         LDKCVec_EventZ _res_constr;
17573         _res_constr.datalen = _res->arr_len;
17574         if (_res_constr.datalen > 0)
17575                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
17576         else
17577                 _res_constr.data = NULL;
17578         uint32_t* _res_vals = _res->elems;
17579         for (size_t h = 0; h < _res_constr.datalen; h++) {
17580                 uint32_t _res_conv_7 = _res_vals[h];
17581                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
17582                 CHECK_ACCESS(_res_conv_7_ptr);
17583                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
17584                 FREE((void*)_res_conv_7);
17585                 _res_constr.data[h] = _res_conv_7_conv;
17586         }
17587         FREE(_res);
17588         CVec_EventZ_free(_res_constr);
17589 }
17590
17591 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
17592         LDKCVec_TransactionZ _res_constr;
17593         _res_constr.datalen = _res->arr_len;
17594         if (_res_constr.datalen > 0)
17595                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
17596         else
17597                 _res_constr.data = NULL;
17598         int8_tArray* _res_vals = (void*) _res->elems;
17599         for (size_t m = 0; m < _res_constr.datalen; m++) {
17600                 int8_tArray _res_conv_12 = _res_vals[m];
17601                 LDKTransaction _res_conv_12_ref;
17602                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
17603                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
17604                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
17605                 _res_conv_12_ref.data_is_owned = true;
17606                 _res_constr.data[m] = _res_conv_12_ref;
17607         }
17608         FREE(_res);
17609         CVec_TransactionZ_free(_res_constr);
17610 }
17611
17612 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
17613         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
17614         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
17615         return ((uint32_t)ret_conv);
17616 }
17617 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
17618         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
17619         uint32_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
17620         return ret_conv;
17621 }
17622
17623 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
17624         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
17625         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
17626         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
17627         return ((uint32_t)ret_conv);
17628 }
17629
17630 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
17631         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
17632         CHECK_ACCESS(b_ptr);
17633         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
17634         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
17635         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
17636         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
17637         return ((uint32_t)ret_conv);
17638 }
17639
17640 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
17641         if ((_res & 1) != 0) return;
17642         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17643         CHECK_ACCESS(_res_ptr);
17644         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
17645         FREE((void*)_res);
17646         C2Tuple_u32TxOutZ_free(_res_conv);
17647 }
17648
17649 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
17650         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
17651         _res_constr.datalen = _res->arr_len;
17652         if (_res_constr.datalen > 0)
17653                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
17654         else
17655                 _res_constr.data = NULL;
17656         uint32_t* _res_vals = _res->elems;
17657         for (size_t u = 0; u < _res_constr.datalen; u++) {
17658                 uint32_t _res_conv_20 = _res_vals[u];
17659                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
17660                 CHECK_ACCESS(_res_conv_20_ptr);
17661                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
17662                 FREE((void*)_res_conv_20);
17663                 _res_constr.data[u] = _res_conv_20_conv;
17664         }
17665         FREE(_res);
17666         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
17667 }
17668
17669 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
17670         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
17671         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
17672         return ((uint32_t)ret_conv);
17673 }
17674 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
17675         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
17676         uint32_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
17677         return ret_conv;
17678 }
17679
17680 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
17681         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
17682         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
17683         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
17684         return ((uint32_t)ret_conv);
17685 }
17686
17687 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
17688         LDKThirtyTwoBytes a_ref;
17689         CHECK(a->arr_len == 32);
17690         memcpy(a_ref.data, a->elems, 32); FREE(a);
17691         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
17692         b_constr.datalen = b->arr_len;
17693         if (b_constr.datalen > 0)
17694                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
17695         else
17696                 b_constr.data = NULL;
17697         uint32_t* b_vals = b->elems;
17698         for (size_t u = 0; u < b_constr.datalen; u++) {
17699                 uint32_t b_conv_20 = b_vals[u];
17700                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
17701                 CHECK_ACCESS(b_conv_20_ptr);
17702                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
17703                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
17704                 b_constr.data[u] = b_conv_20_conv;
17705         }
17706         FREE(b);
17707         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
17708         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
17709         return ((uint32_t)ret_conv);
17710 }
17711
17712 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
17713         if ((_res & 1) != 0) return;
17714         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17715         CHECK_ACCESS(_res_ptr);
17716         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
17717         FREE((void*)_res);
17718         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
17719 }
17720
17721 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
17722         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
17723         _res_constr.datalen = _res->arr_len;
17724         if (_res_constr.datalen > 0)
17725                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
17726         else
17727                 _res_constr.data = NULL;
17728         uint32_t* _res_vals = _res->elems;
17729         for (size_t n = 0; n < _res_constr.datalen; n++) {
17730                 uint32_t _res_conv_39 = _res_vals[n];
17731                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
17732                 CHECK_ACCESS(_res_conv_39_ptr);
17733                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
17734                 FREE((void*)_res_conv_39);
17735                 _res_constr.data[n] = _res_conv_39_conv;
17736         }
17737         FREE(_res);
17738         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
17739 }
17740
17741 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
17742         LDKCVec_BalanceZ _res_constr;
17743         _res_constr.datalen = _res->arr_len;
17744         if (_res_constr.datalen > 0)
17745                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
17746         else
17747                 _res_constr.data = NULL;
17748         uint32_t* _res_vals = _res->elems;
17749         for (size_t j = 0; j < _res_constr.datalen; j++) {
17750                 uint32_t _res_conv_9 = _res_vals[j];
17751                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
17752                 CHECK_ACCESS(_res_conv_9_ptr);
17753                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
17754                 FREE((void*)_res_conv_9);
17755                 _res_constr.data[j] = _res_conv_9_conv;
17756         }
17757         FREE(_res);
17758         CVec_BalanceZ_free(_res_constr);
17759 }
17760
17761 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
17762         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17763         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
17764         return ((uint32_t)ret_conv);
17765 }
17766 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
17767         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
17768         uint32_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
17769         return ret_conv;
17770 }
17771
17772 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
17773         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
17774         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17775         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
17776         return ((uint32_t)ret_conv);
17777 }
17778
17779 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
17780         LDKThirtyTwoBytes a_ref;
17781         CHECK(a->arr_len == 32);
17782         memcpy(a_ref.data, a->elems, 32); FREE(a);
17783         LDKChannelMonitor b_conv;
17784         b_conv.inner = (void*)(b & (~1));
17785         b_conv.is_owned = (b & 1) || (b == 0);
17786         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
17787         b_conv = ChannelMonitor_clone(&b_conv);
17788         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17789         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
17790         return ((uint32_t)ret_conv);
17791 }
17792
17793 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
17794         if ((_res & 1) != 0) return;
17795         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17796         CHECK_ACCESS(_res_ptr);
17797         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
17798         FREE((void*)_res);
17799         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
17800 }
17801
17802 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
17803         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17804         CHECK_ACCESS(o_ptr);
17805         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
17806         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
17807         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
17808         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
17809         return (uint32_t)ret_conv;
17810 }
17811
17812 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
17813         LDKDecodeError e_conv;
17814         e_conv.inner = (void*)(e & (~1));
17815         e_conv.is_owned = (e & 1) || (e == 0);
17816         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17817         e_conv = DecodeError_clone(&e_conv);
17818         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
17819         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
17820         return (uint32_t)ret_conv;
17821 }
17822
17823 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
17824         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
17825         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
17826         return ret_conv;
17827 }
17828
17829 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
17830         if ((_res & 1) != 0) return;
17831         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17832         CHECK_ACCESS(_res_ptr);
17833         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
17834         FREE((void*)_res);
17835         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
17836 }
17837
17838 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
17839         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
17840         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
17841         return (uint32_t)ret_conv;
17842 }
17843 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
17844         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
17845         uint32_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
17846         return ret_conv;
17847 }
17848
17849 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
17850         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
17851         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
17852         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
17853         return (uint32_t)ret_conv;
17854 }
17855
17856 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
17857         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
17858         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
17859         return ((uint32_t)ret_conv);
17860 }
17861 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
17862         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
17863         uint32_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
17864         return ret_conv;
17865 }
17866
17867 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
17868         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
17869         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
17870         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
17871         return ((uint32_t)ret_conv);
17872 }
17873
17874 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
17875         LDKPublicKey a_ref;
17876         CHECK(a->arr_len == 33);
17877         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
17878         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
17879         CHECK_ACCESS(b_ptr);
17880         LDKType b_conv = *(LDKType*)(b_ptr);
17881         if (b_conv.free == LDKType_JCalls_free) {
17882                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17883                 LDKType_JCalls_cloned(&b_conv);
17884         }
17885         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
17886         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
17887         return ((uint32_t)ret_conv);
17888 }
17889
17890 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
17891         if ((_res & 1) != 0) return;
17892         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17893         CHECK_ACCESS(_res_ptr);
17894         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
17895         FREE((void*)_res);
17896         C2Tuple_PublicKeyTypeZ_free(_res_conv);
17897 }
17898
17899 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
17900         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
17901         _res_constr.datalen = _res->arr_len;
17902         if (_res_constr.datalen > 0)
17903                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
17904         else
17905                 _res_constr.data = NULL;
17906         uint32_t* _res_vals = _res->elems;
17907         for (size_t z = 0; z < _res_constr.datalen; z++) {
17908                 uint32_t _res_conv_25 = _res_vals[z];
17909                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
17910                 CHECK_ACCESS(_res_conv_25_ptr);
17911                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
17912                 FREE((void*)_res_conv_25);
17913                 _res_constr.data[z] = _res_conv_25_conv;
17914         }
17915         FREE(_res);
17916         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
17917 }
17918
17919 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_some"))) TS_COption_NetAddressZ_some(uint32_t o) {
17920         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17921         CHECK_ACCESS(o_ptr);
17922         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
17923         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
17924         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
17925         *ret_copy = COption_NetAddressZ_some(o_conv);
17926         uint32_t ret_ref = (uintptr_t)ret_copy;
17927         return ret_ref;
17928 }
17929
17930 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_none"))) TS_COption_NetAddressZ_none() {
17931         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
17932         *ret_copy = COption_NetAddressZ_none();
17933         uint32_t ret_ref = (uintptr_t)ret_copy;
17934         return ret_ref;
17935 }
17936
17937 void  __attribute__((export_name("TS_COption_NetAddressZ_free"))) TS_COption_NetAddressZ_free(uint32_t _res) {
17938         if ((_res & 1) != 0) return;
17939         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17940         CHECK_ACCESS(_res_ptr);
17941         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
17942         FREE((void*)_res);
17943         COption_NetAddressZ_free(_res_conv);
17944 }
17945
17946 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
17947         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
17948         *ret_copy = COption_NetAddressZ_clone(arg);
17949 uint32_t ret_ref = (uintptr_t)ret_copy;
17950         return ret_ref;
17951 }
17952 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone_ptr"))) TS_COption_NetAddressZ_clone_ptr(uint32_t arg) {
17953         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
17954         uint32_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
17955         return ret_conv;
17956 }
17957
17958 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone"))) TS_COption_NetAddressZ_clone(uint32_t orig) {
17959         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
17960         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
17961         *ret_copy = COption_NetAddressZ_clone(orig_conv);
17962         uint32_t ret_ref = (uintptr_t)ret_copy;
17963         return ret_ref;
17964 }
17965
17966 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
17967         LDKCVec_u8Z o_ref;
17968         o_ref.datalen = o->arr_len;
17969         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
17970         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
17971         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
17972         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
17973         return (uint32_t)ret_conv;
17974 }
17975
17976 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
17977         LDKPeerHandleError e_conv;
17978         e_conv.inner = (void*)(e & (~1));
17979         e_conv.is_owned = (e & 1) || (e == 0);
17980         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17981         e_conv = PeerHandleError_clone(&e_conv);
17982         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
17983         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
17984         return (uint32_t)ret_conv;
17985 }
17986
17987 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
17988         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
17989         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
17990         return ret_conv;
17991 }
17992
17993 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
17994         if ((_res & 1) != 0) return;
17995         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17996         CHECK_ACCESS(_res_ptr);
17997         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
17998         FREE((void*)_res);
17999         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
18000 }
18001
18002 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
18003         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18004         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
18005         return (uint32_t)ret_conv;
18006 }
18007 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
18008         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
18009         uint32_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
18010         return ret_conv;
18011 }
18012
18013 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
18014         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
18015         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18016         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
18017         return (uint32_t)ret_conv;
18018 }
18019
18020 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
18021         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18022         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
18023         return (uint32_t)ret_conv;
18024 }
18025
18026 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
18027         LDKPeerHandleError e_conv;
18028         e_conv.inner = (void*)(e & (~1));
18029         e_conv.is_owned = (e & 1) || (e == 0);
18030         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18031         e_conv = PeerHandleError_clone(&e_conv);
18032         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18033         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
18034         return (uint32_t)ret_conv;
18035 }
18036
18037 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
18038         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
18039         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
18040         return ret_conv;
18041 }
18042
18043 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
18044         if ((_res & 1) != 0) return;
18045         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18046         CHECK_ACCESS(_res_ptr);
18047         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
18048         FREE((void*)_res);
18049         CResult_NonePeerHandleErrorZ_free(_res_conv);
18050 }
18051
18052 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
18053         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18054         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
18055         return (uint32_t)ret_conv;
18056 }
18057 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
18058         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
18059         uint32_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
18060         return ret_conv;
18061 }
18062
18063 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
18064         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
18065         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18066         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
18067         return (uint32_t)ret_conv;
18068 }
18069
18070 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
18071         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18072         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
18073         return (uint32_t)ret_conv;
18074 }
18075
18076 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
18077         LDKPeerHandleError e_conv;
18078         e_conv.inner = (void*)(e & (~1));
18079         e_conv.is_owned = (e & 1) || (e == 0);
18080         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18081         e_conv = PeerHandleError_clone(&e_conv);
18082         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18083         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
18084         return (uint32_t)ret_conv;
18085 }
18086
18087 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
18088         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
18089         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
18090         return ret_conv;
18091 }
18092
18093 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
18094         if ((_res & 1) != 0) return;
18095         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18096         CHECK_ACCESS(_res_ptr);
18097         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
18098         FREE((void*)_res);
18099         CResult_boolPeerHandleErrorZ_free(_res_conv);
18100 }
18101
18102 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
18103         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18104         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
18105         return (uint32_t)ret_conv;
18106 }
18107 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
18108         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
18109         uint32_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
18110         return ret_conv;
18111 }
18112
18113 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
18114         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
18115         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18116         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
18117         return (uint32_t)ret_conv;
18118 }
18119
18120 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_ok"))) TS_CResult_NoneErrorZ_ok() {
18121         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18122         *ret_conv = CResult_NoneErrorZ_ok();
18123         return (uint32_t)ret_conv;
18124 }
18125
18126 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_err"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
18127         LDKIOError e_conv = LDKIOError_from_js(e);
18128         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18129         *ret_conv = CResult_NoneErrorZ_err(e_conv);
18130         return (uint32_t)ret_conv;
18131 }
18132
18133 jboolean  __attribute__((export_name("TS_CResult_NoneErrorZ_is_ok"))) TS_CResult_NoneErrorZ_is_ok(uint32_t o) {
18134         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
18135         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
18136         return ret_conv;
18137 }
18138
18139 void  __attribute__((export_name("TS_CResult_NoneErrorZ_free"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
18140         if ((_res & 1) != 0) return;
18141         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18142         CHECK_ACCESS(_res_ptr);
18143         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
18144         FREE((void*)_res);
18145         CResult_NoneErrorZ_free(_res_conv);
18146 }
18147
18148 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
18149         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18150         *ret_conv = CResult_NoneErrorZ_clone(arg);
18151         return (uint32_t)ret_conv;
18152 }
18153 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_clone_ptr"))) TS_CResult_NoneErrorZ_clone_ptr(uint32_t arg) {
18154         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
18155         uint32_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
18156         return ret_conv;
18157 }
18158
18159 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_clone"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
18160         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
18161         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18162         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
18163         return (uint32_t)ret_conv;
18164 }
18165
18166 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
18167         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18168         CHECK_ACCESS(o_ptr);
18169         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
18170         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
18171         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18172         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
18173         return (uint32_t)ret_conv;
18174 }
18175
18176 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
18177         LDKDecodeError e_conv;
18178         e_conv.inner = (void*)(e & (~1));
18179         e_conv.is_owned = (e & 1) || (e == 0);
18180         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18181         e_conv = DecodeError_clone(&e_conv);
18182         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18183         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
18184         return (uint32_t)ret_conv;
18185 }
18186
18187 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
18188         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
18189         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
18190         return ret_conv;
18191 }
18192
18193 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
18194         if ((_res & 1) != 0) return;
18195         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18196         CHECK_ACCESS(_res_ptr);
18197         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
18198         FREE((void*)_res);
18199         CResult_NetAddressDecodeErrorZ_free(_res_conv);
18200 }
18201
18202 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
18203         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18204         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
18205         return (uint32_t)ret_conv;
18206 }
18207 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
18208         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
18209         uint32_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
18210         return ret_conv;
18211 }
18212
18213 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
18214         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
18215         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18216         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
18217         return (uint32_t)ret_conv;
18218 }
18219
18220 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
18221         LDKCVec_UpdateAddHTLCZ _res_constr;
18222         _res_constr.datalen = _res->arr_len;
18223         if (_res_constr.datalen > 0)
18224                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
18225         else
18226                 _res_constr.data = NULL;
18227         uint32_t* _res_vals = _res->elems;
18228         for (size_t p = 0; p < _res_constr.datalen; p++) {
18229                 uint32_t _res_conv_15 = _res_vals[p];
18230                 LDKUpdateAddHTLC _res_conv_15_conv;
18231                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
18232                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
18233                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
18234                 _res_constr.data[p] = _res_conv_15_conv;
18235         }
18236         FREE(_res);
18237         CVec_UpdateAddHTLCZ_free(_res_constr);
18238 }
18239
18240 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
18241         LDKCVec_UpdateFulfillHTLCZ _res_constr;
18242         _res_constr.datalen = _res->arr_len;
18243         if (_res_constr.datalen > 0)
18244                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
18245         else
18246                 _res_constr.data = NULL;
18247         uint32_t* _res_vals = _res->elems;
18248         for (size_t t = 0; t < _res_constr.datalen; t++) {
18249                 uint32_t _res_conv_19 = _res_vals[t];
18250                 LDKUpdateFulfillHTLC _res_conv_19_conv;
18251                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
18252                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
18253                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
18254                 _res_constr.data[t] = _res_conv_19_conv;
18255         }
18256         FREE(_res);
18257         CVec_UpdateFulfillHTLCZ_free(_res_constr);
18258 }
18259
18260 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
18261         LDKCVec_UpdateFailHTLCZ _res_constr;
18262         _res_constr.datalen = _res->arr_len;
18263         if (_res_constr.datalen > 0)
18264                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
18265         else
18266                 _res_constr.data = NULL;
18267         uint32_t* _res_vals = _res->elems;
18268         for (size_t q = 0; q < _res_constr.datalen; q++) {
18269                 uint32_t _res_conv_16 = _res_vals[q];
18270                 LDKUpdateFailHTLC _res_conv_16_conv;
18271                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
18272                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
18273                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
18274                 _res_constr.data[q] = _res_conv_16_conv;
18275         }
18276         FREE(_res);
18277         CVec_UpdateFailHTLCZ_free(_res_constr);
18278 }
18279
18280 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
18281         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
18282         _res_constr.datalen = _res->arr_len;
18283         if (_res_constr.datalen > 0)
18284                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
18285         else
18286                 _res_constr.data = NULL;
18287         uint32_t* _res_vals = _res->elems;
18288         for (size_t z = 0; z < _res_constr.datalen; z++) {
18289                 uint32_t _res_conv_25 = _res_vals[z];
18290                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
18291                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
18292                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
18293                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
18294                 _res_constr.data[z] = _res_conv_25_conv;
18295         }
18296         FREE(_res);
18297         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
18298 }
18299
18300 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
18301         LDKAcceptChannel o_conv;
18302         o_conv.inner = (void*)(o & (~1));
18303         o_conv.is_owned = (o & 1) || (o == 0);
18304         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18305         o_conv = AcceptChannel_clone(&o_conv);
18306         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18307         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
18308         return (uint32_t)ret_conv;
18309 }
18310
18311 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
18312         LDKDecodeError e_conv;
18313         e_conv.inner = (void*)(e & (~1));
18314         e_conv.is_owned = (e & 1) || (e == 0);
18315         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18316         e_conv = DecodeError_clone(&e_conv);
18317         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18318         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
18319         return (uint32_t)ret_conv;
18320 }
18321
18322 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
18323         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
18324         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
18325         return ret_conv;
18326 }
18327
18328 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
18329         if ((_res & 1) != 0) return;
18330         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18331         CHECK_ACCESS(_res_ptr);
18332         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
18333         FREE((void*)_res);
18334         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
18335 }
18336
18337 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
18338         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18339         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
18340         return (uint32_t)ret_conv;
18341 }
18342 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
18343         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
18344         uint32_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
18345         return ret_conv;
18346 }
18347
18348 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
18349         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
18350         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18351         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
18352         return (uint32_t)ret_conv;
18353 }
18354
18355 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
18356         LDKAnnouncementSignatures o_conv;
18357         o_conv.inner = (void*)(o & (~1));
18358         o_conv.is_owned = (o & 1) || (o == 0);
18359         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18360         o_conv = AnnouncementSignatures_clone(&o_conv);
18361         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18362         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
18363         return (uint32_t)ret_conv;
18364 }
18365
18366 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
18367         LDKDecodeError e_conv;
18368         e_conv.inner = (void*)(e & (~1));
18369         e_conv.is_owned = (e & 1) || (e == 0);
18370         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18371         e_conv = DecodeError_clone(&e_conv);
18372         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18373         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
18374         return (uint32_t)ret_conv;
18375 }
18376
18377 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
18378         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
18379         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
18380         return ret_conv;
18381 }
18382
18383 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
18384         if ((_res & 1) != 0) return;
18385         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18386         CHECK_ACCESS(_res_ptr);
18387         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
18388         FREE((void*)_res);
18389         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
18390 }
18391
18392 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
18393         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18394         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
18395         return (uint32_t)ret_conv;
18396 }
18397 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
18398         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
18399         uint32_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
18400         return ret_conv;
18401 }
18402
18403 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
18404         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
18405         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18406         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
18407         return (uint32_t)ret_conv;
18408 }
18409
18410 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
18411         LDKChannelReestablish o_conv;
18412         o_conv.inner = (void*)(o & (~1));
18413         o_conv.is_owned = (o & 1) || (o == 0);
18414         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18415         o_conv = ChannelReestablish_clone(&o_conv);
18416         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18417         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
18418         return (uint32_t)ret_conv;
18419 }
18420
18421 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
18422         LDKDecodeError e_conv;
18423         e_conv.inner = (void*)(e & (~1));
18424         e_conv.is_owned = (e & 1) || (e == 0);
18425         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18426         e_conv = DecodeError_clone(&e_conv);
18427         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18428         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
18429         return (uint32_t)ret_conv;
18430 }
18431
18432 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
18433         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
18434         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
18435         return ret_conv;
18436 }
18437
18438 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
18439         if ((_res & 1) != 0) return;
18440         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18441         CHECK_ACCESS(_res_ptr);
18442         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
18443         FREE((void*)_res);
18444         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
18445 }
18446
18447 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
18448         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18449         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
18450         return (uint32_t)ret_conv;
18451 }
18452 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
18453         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
18454         uint32_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
18455         return ret_conv;
18456 }
18457
18458 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
18459         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
18460         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18461         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
18462         return (uint32_t)ret_conv;
18463 }
18464
18465 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
18466         LDKClosingSigned o_conv;
18467         o_conv.inner = (void*)(o & (~1));
18468         o_conv.is_owned = (o & 1) || (o == 0);
18469         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18470         o_conv = ClosingSigned_clone(&o_conv);
18471         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18472         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
18473         return (uint32_t)ret_conv;
18474 }
18475
18476 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
18477         LDKDecodeError e_conv;
18478         e_conv.inner = (void*)(e & (~1));
18479         e_conv.is_owned = (e & 1) || (e == 0);
18480         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18481         e_conv = DecodeError_clone(&e_conv);
18482         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18483         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
18484         return (uint32_t)ret_conv;
18485 }
18486
18487 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
18488         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
18489         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
18490         return ret_conv;
18491 }
18492
18493 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
18494         if ((_res & 1) != 0) return;
18495         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18496         CHECK_ACCESS(_res_ptr);
18497         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
18498         FREE((void*)_res);
18499         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
18500 }
18501
18502 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
18503         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18504         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
18505         return (uint32_t)ret_conv;
18506 }
18507 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
18508         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
18509         uint32_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
18510         return ret_conv;
18511 }
18512
18513 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
18514         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
18515         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18516         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
18517         return (uint32_t)ret_conv;
18518 }
18519
18520 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
18521         LDKClosingSignedFeeRange o_conv;
18522         o_conv.inner = (void*)(o & (~1));
18523         o_conv.is_owned = (o & 1) || (o == 0);
18524         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18525         o_conv = ClosingSignedFeeRange_clone(&o_conv);
18526         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18527         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
18528         return (uint32_t)ret_conv;
18529 }
18530
18531 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
18532         LDKDecodeError e_conv;
18533         e_conv.inner = (void*)(e & (~1));
18534         e_conv.is_owned = (e & 1) || (e == 0);
18535         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18536         e_conv = DecodeError_clone(&e_conv);
18537         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18538         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
18539         return (uint32_t)ret_conv;
18540 }
18541
18542 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
18543         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
18544         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
18545         return ret_conv;
18546 }
18547
18548 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
18549         if ((_res & 1) != 0) return;
18550         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18551         CHECK_ACCESS(_res_ptr);
18552         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
18553         FREE((void*)_res);
18554         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
18555 }
18556
18557 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
18558         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18559         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
18560         return (uint32_t)ret_conv;
18561 }
18562 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
18563         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
18564         uint32_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
18565         return ret_conv;
18566 }
18567
18568 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
18569         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
18570         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18571         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
18572         return (uint32_t)ret_conv;
18573 }
18574
18575 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
18576         LDKCommitmentSigned o_conv;
18577         o_conv.inner = (void*)(o & (~1));
18578         o_conv.is_owned = (o & 1) || (o == 0);
18579         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18580         o_conv = CommitmentSigned_clone(&o_conv);
18581         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18582         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
18583         return (uint32_t)ret_conv;
18584 }
18585
18586 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
18587         LDKDecodeError e_conv;
18588         e_conv.inner = (void*)(e & (~1));
18589         e_conv.is_owned = (e & 1) || (e == 0);
18590         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18591         e_conv = DecodeError_clone(&e_conv);
18592         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18593         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
18594         return (uint32_t)ret_conv;
18595 }
18596
18597 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
18598         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
18599         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
18600         return ret_conv;
18601 }
18602
18603 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
18604         if ((_res & 1) != 0) return;
18605         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18606         CHECK_ACCESS(_res_ptr);
18607         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
18608         FREE((void*)_res);
18609         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
18610 }
18611
18612 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
18613         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18614         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
18615         return (uint32_t)ret_conv;
18616 }
18617 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
18618         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
18619         uint32_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
18620         return ret_conv;
18621 }
18622
18623 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
18624         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
18625         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18626         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
18627         return (uint32_t)ret_conv;
18628 }
18629
18630 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
18631         LDKFundingCreated o_conv;
18632         o_conv.inner = (void*)(o & (~1));
18633         o_conv.is_owned = (o & 1) || (o == 0);
18634         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18635         o_conv = FundingCreated_clone(&o_conv);
18636         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
18637         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
18638         return (uint32_t)ret_conv;
18639 }
18640
18641 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
18642         LDKDecodeError e_conv;
18643         e_conv.inner = (void*)(e & (~1));
18644         e_conv.is_owned = (e & 1) || (e == 0);
18645         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18646         e_conv = DecodeError_clone(&e_conv);
18647         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
18648         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
18649         return (uint32_t)ret_conv;
18650 }
18651
18652 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
18653         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
18654         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
18655         return ret_conv;
18656 }
18657
18658 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
18659         if ((_res & 1) != 0) return;
18660         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18661         CHECK_ACCESS(_res_ptr);
18662         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
18663         FREE((void*)_res);
18664         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
18665 }
18666
18667 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
18668         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
18669         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
18670         return (uint32_t)ret_conv;
18671 }
18672 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
18673         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
18674         uint32_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
18675         return ret_conv;
18676 }
18677
18678 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
18679         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
18680         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
18681         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
18682         return (uint32_t)ret_conv;
18683 }
18684
18685 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
18686         LDKFundingSigned o_conv;
18687         o_conv.inner = (void*)(o & (~1));
18688         o_conv.is_owned = (o & 1) || (o == 0);
18689         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18690         o_conv = FundingSigned_clone(&o_conv);
18691         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
18692         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
18693         return (uint32_t)ret_conv;
18694 }
18695
18696 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
18697         LDKDecodeError e_conv;
18698         e_conv.inner = (void*)(e & (~1));
18699         e_conv.is_owned = (e & 1) || (e == 0);
18700         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18701         e_conv = DecodeError_clone(&e_conv);
18702         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
18703         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
18704         return (uint32_t)ret_conv;
18705 }
18706
18707 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
18708         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
18709         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
18710         return ret_conv;
18711 }
18712
18713 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
18714         if ((_res & 1) != 0) return;
18715         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18716         CHECK_ACCESS(_res_ptr);
18717         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
18718         FREE((void*)_res);
18719         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
18720 }
18721
18722 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
18723         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
18724         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
18725         return (uint32_t)ret_conv;
18726 }
18727 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
18728         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
18729         uint32_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
18730         return ret_conv;
18731 }
18732
18733 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
18734         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
18735         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
18736         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
18737         return (uint32_t)ret_conv;
18738 }
18739
18740 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_ok(uint32_t o) {
18741         LDKChannelReady o_conv;
18742         o_conv.inner = (void*)(o & (~1));
18743         o_conv.is_owned = (o & 1) || (o == 0);
18744         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18745         o_conv = ChannelReady_clone(&o_conv);
18746         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
18747         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
18748         return (uint32_t)ret_conv;
18749 }
18750
18751 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_err"))) TS_CResult_ChannelReadyDecodeErrorZ_err(uint32_t e) {
18752         LDKDecodeError e_conv;
18753         e_conv.inner = (void*)(e & (~1));
18754         e_conv.is_owned = (e & 1) || (e == 0);
18755         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18756         e_conv = DecodeError_clone(&e_conv);
18757         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
18758         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
18759         return (uint32_t)ret_conv;
18760 }
18761
18762 jboolean  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_is_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_is_ok(uint32_t o) {
18763         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(o & ~1);
18764         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
18765         return ret_conv;
18766 }
18767
18768 void  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_free"))) TS_CResult_ChannelReadyDecodeErrorZ_free(uint32_t _res) {
18769         if ((_res & 1) != 0) return;
18770         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18771         CHECK_ACCESS(_res_ptr);
18772         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
18773         FREE((void*)_res);
18774         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
18775 }
18776
18777 static inline uintptr_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
18778         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
18779         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
18780         return (uint32_t)ret_conv;
18781 }
18782 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReadyDecodeErrorZ_clone_ptr(uint32_t arg) {
18783         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(arg & ~1);
18784         uint32_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
18785         return ret_conv;
18786 }
18787
18788 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_clone"))) TS_CResult_ChannelReadyDecodeErrorZ_clone(uint32_t orig) {
18789         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(orig & ~1);
18790         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
18791         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
18792         return (uint32_t)ret_conv;
18793 }
18794
18795 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
18796         LDKInit o_conv;
18797         o_conv.inner = (void*)(o & (~1));
18798         o_conv.is_owned = (o & 1) || (o == 0);
18799         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18800         o_conv = Init_clone(&o_conv);
18801         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18802         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
18803         return (uint32_t)ret_conv;
18804 }
18805
18806 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
18807         LDKDecodeError e_conv;
18808         e_conv.inner = (void*)(e & (~1));
18809         e_conv.is_owned = (e & 1) || (e == 0);
18810         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18811         e_conv = DecodeError_clone(&e_conv);
18812         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18813         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
18814         return (uint32_t)ret_conv;
18815 }
18816
18817 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
18818         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
18819         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
18820         return ret_conv;
18821 }
18822
18823 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
18824         if ((_res & 1) != 0) return;
18825         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18826         CHECK_ACCESS(_res_ptr);
18827         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
18828         FREE((void*)_res);
18829         CResult_InitDecodeErrorZ_free(_res_conv);
18830 }
18831
18832 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
18833         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18834         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
18835         return (uint32_t)ret_conv;
18836 }
18837 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
18838         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
18839         uint32_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
18840         return ret_conv;
18841 }
18842
18843 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
18844         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
18845         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18846         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
18847         return (uint32_t)ret_conv;
18848 }
18849
18850 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
18851         LDKOpenChannel o_conv;
18852         o_conv.inner = (void*)(o & (~1));
18853         o_conv.is_owned = (o & 1) || (o == 0);
18854         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18855         o_conv = OpenChannel_clone(&o_conv);
18856         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18857         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
18858         return (uint32_t)ret_conv;
18859 }
18860
18861 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
18862         LDKDecodeError e_conv;
18863         e_conv.inner = (void*)(e & (~1));
18864         e_conv.is_owned = (e & 1) || (e == 0);
18865         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18866         e_conv = DecodeError_clone(&e_conv);
18867         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18868         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
18869         return (uint32_t)ret_conv;
18870 }
18871
18872 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
18873         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
18874         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
18875         return ret_conv;
18876 }
18877
18878 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
18879         if ((_res & 1) != 0) return;
18880         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18881         CHECK_ACCESS(_res_ptr);
18882         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
18883         FREE((void*)_res);
18884         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
18885 }
18886
18887 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
18888         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18889         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
18890         return (uint32_t)ret_conv;
18891 }
18892 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
18893         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
18894         uint32_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
18895         return ret_conv;
18896 }
18897
18898 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
18899         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
18900         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18901         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
18902         return (uint32_t)ret_conv;
18903 }
18904
18905 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
18906         LDKRevokeAndACK o_conv;
18907         o_conv.inner = (void*)(o & (~1));
18908         o_conv.is_owned = (o & 1) || (o == 0);
18909         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18910         o_conv = RevokeAndACK_clone(&o_conv);
18911         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18912         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
18913         return (uint32_t)ret_conv;
18914 }
18915
18916 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
18917         LDKDecodeError e_conv;
18918         e_conv.inner = (void*)(e & (~1));
18919         e_conv.is_owned = (e & 1) || (e == 0);
18920         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18921         e_conv = DecodeError_clone(&e_conv);
18922         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18923         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
18924         return (uint32_t)ret_conv;
18925 }
18926
18927 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
18928         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
18929         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
18930         return ret_conv;
18931 }
18932
18933 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
18934         if ((_res & 1) != 0) return;
18935         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18936         CHECK_ACCESS(_res_ptr);
18937         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
18938         FREE((void*)_res);
18939         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
18940 }
18941
18942 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
18943         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18944         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
18945         return (uint32_t)ret_conv;
18946 }
18947 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
18948         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
18949         uint32_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
18950         return ret_conv;
18951 }
18952
18953 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
18954         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
18955         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18956         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
18957         return (uint32_t)ret_conv;
18958 }
18959
18960 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
18961         LDKShutdown o_conv;
18962         o_conv.inner = (void*)(o & (~1));
18963         o_conv.is_owned = (o & 1) || (o == 0);
18964         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18965         o_conv = Shutdown_clone(&o_conv);
18966         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18967         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
18968         return (uint32_t)ret_conv;
18969 }
18970
18971 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
18972         LDKDecodeError e_conv;
18973         e_conv.inner = (void*)(e & (~1));
18974         e_conv.is_owned = (e & 1) || (e == 0);
18975         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18976         e_conv = DecodeError_clone(&e_conv);
18977         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18978         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
18979         return (uint32_t)ret_conv;
18980 }
18981
18982 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
18983         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
18984         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
18985         return ret_conv;
18986 }
18987
18988 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
18989         if ((_res & 1) != 0) return;
18990         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18991         CHECK_ACCESS(_res_ptr);
18992         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
18993         FREE((void*)_res);
18994         CResult_ShutdownDecodeErrorZ_free(_res_conv);
18995 }
18996
18997 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
18998         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18999         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
19000         return (uint32_t)ret_conv;
19001 }
19002 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
19003         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
19004         uint32_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
19005         return ret_conv;
19006 }
19007
19008 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
19009         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
19010         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19011         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
19012         return (uint32_t)ret_conv;
19013 }
19014
19015 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
19016         LDKUpdateFailHTLC o_conv;
19017         o_conv.inner = (void*)(o & (~1));
19018         o_conv.is_owned = (o & 1) || (o == 0);
19019         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19020         o_conv = UpdateFailHTLC_clone(&o_conv);
19021         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19022         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
19023         return (uint32_t)ret_conv;
19024 }
19025
19026 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
19027         LDKDecodeError e_conv;
19028         e_conv.inner = (void*)(e & (~1));
19029         e_conv.is_owned = (e & 1) || (e == 0);
19030         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19031         e_conv = DecodeError_clone(&e_conv);
19032         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19033         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
19034         return (uint32_t)ret_conv;
19035 }
19036
19037 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
19038         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
19039         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
19040         return ret_conv;
19041 }
19042
19043 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
19044         if ((_res & 1) != 0) return;
19045         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19046         CHECK_ACCESS(_res_ptr);
19047         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
19048         FREE((void*)_res);
19049         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
19050 }
19051
19052 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
19053         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19054         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
19055         return (uint32_t)ret_conv;
19056 }
19057 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19058         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
19059         uint32_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
19060         return ret_conv;
19061 }
19062
19063 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
19064         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
19065         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19066         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
19067         return (uint32_t)ret_conv;
19068 }
19069
19070 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
19071         LDKUpdateFailMalformedHTLC o_conv;
19072         o_conv.inner = (void*)(o & (~1));
19073         o_conv.is_owned = (o & 1) || (o == 0);
19074         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19075         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
19076         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19077         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
19078         return (uint32_t)ret_conv;
19079 }
19080
19081 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
19082         LDKDecodeError e_conv;
19083         e_conv.inner = (void*)(e & (~1));
19084         e_conv.is_owned = (e & 1) || (e == 0);
19085         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19086         e_conv = DecodeError_clone(&e_conv);
19087         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19088         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
19089         return (uint32_t)ret_conv;
19090 }
19091
19092 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
19093         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
19094         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
19095         return ret_conv;
19096 }
19097
19098 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
19099         if ((_res & 1) != 0) return;
19100         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19101         CHECK_ACCESS(_res_ptr);
19102         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
19103         FREE((void*)_res);
19104         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
19105 }
19106
19107 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
19108         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19109         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
19110         return (uint32_t)ret_conv;
19111 }
19112 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19113         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
19114         uint32_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
19115         return ret_conv;
19116 }
19117
19118 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
19119         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
19120         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19121         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
19122         return (uint32_t)ret_conv;
19123 }
19124
19125 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
19126         LDKUpdateFee o_conv;
19127         o_conv.inner = (void*)(o & (~1));
19128         o_conv.is_owned = (o & 1) || (o == 0);
19129         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19130         o_conv = UpdateFee_clone(&o_conv);
19131         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19132         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
19133         return (uint32_t)ret_conv;
19134 }
19135
19136 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
19137         LDKDecodeError e_conv;
19138         e_conv.inner = (void*)(e & (~1));
19139         e_conv.is_owned = (e & 1) || (e == 0);
19140         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19141         e_conv = DecodeError_clone(&e_conv);
19142         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19143         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
19144         return (uint32_t)ret_conv;
19145 }
19146
19147 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
19148         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
19149         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
19150         return ret_conv;
19151 }
19152
19153 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
19154         if ((_res & 1) != 0) return;
19155         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19156         CHECK_ACCESS(_res_ptr);
19157         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
19158         FREE((void*)_res);
19159         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
19160 }
19161
19162 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
19163         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19164         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
19165         return (uint32_t)ret_conv;
19166 }
19167 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
19168         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
19169         uint32_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
19170         return ret_conv;
19171 }
19172
19173 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
19174         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
19175         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19176         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
19177         return (uint32_t)ret_conv;
19178 }
19179
19180 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
19181         LDKUpdateFulfillHTLC o_conv;
19182         o_conv.inner = (void*)(o & (~1));
19183         o_conv.is_owned = (o & 1) || (o == 0);
19184         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19185         o_conv = UpdateFulfillHTLC_clone(&o_conv);
19186         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19187         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
19188         return (uint32_t)ret_conv;
19189 }
19190
19191 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
19192         LDKDecodeError e_conv;
19193         e_conv.inner = (void*)(e & (~1));
19194         e_conv.is_owned = (e & 1) || (e == 0);
19195         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19196         e_conv = DecodeError_clone(&e_conv);
19197         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19198         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
19199         return (uint32_t)ret_conv;
19200 }
19201
19202 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
19203         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
19204         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
19205         return ret_conv;
19206 }
19207
19208 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
19209         if ((_res & 1) != 0) return;
19210         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19211         CHECK_ACCESS(_res_ptr);
19212         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
19213         FREE((void*)_res);
19214         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
19215 }
19216
19217 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
19218         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19219         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
19220         return (uint32_t)ret_conv;
19221 }
19222 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19223         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
19224         uint32_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
19225         return ret_conv;
19226 }
19227
19228 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
19229         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
19230         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19231         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
19232         return (uint32_t)ret_conv;
19233 }
19234
19235 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
19236         LDKUpdateAddHTLC o_conv;
19237         o_conv.inner = (void*)(o & (~1));
19238         o_conv.is_owned = (o & 1) || (o == 0);
19239         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19240         o_conv = UpdateAddHTLC_clone(&o_conv);
19241         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19242         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
19243         return (uint32_t)ret_conv;
19244 }
19245
19246 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
19247         LDKDecodeError e_conv;
19248         e_conv.inner = (void*)(e & (~1));
19249         e_conv.is_owned = (e & 1) || (e == 0);
19250         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19251         e_conv = DecodeError_clone(&e_conv);
19252         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19253         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
19254         return (uint32_t)ret_conv;
19255 }
19256
19257 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
19258         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
19259         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
19260         return ret_conv;
19261 }
19262
19263 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
19264         if ((_res & 1) != 0) return;
19265         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19266         CHECK_ACCESS(_res_ptr);
19267         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
19268         FREE((void*)_res);
19269         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
19270 }
19271
19272 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
19273         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19274         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
19275         return (uint32_t)ret_conv;
19276 }
19277 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19278         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
19279         uint32_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
19280         return ret_conv;
19281 }
19282
19283 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
19284         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
19285         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19286         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
19287         return (uint32_t)ret_conv;
19288 }
19289
19290 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
19291         LDKPing o_conv;
19292         o_conv.inner = (void*)(o & (~1));
19293         o_conv.is_owned = (o & 1) || (o == 0);
19294         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19295         o_conv = Ping_clone(&o_conv);
19296         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19297         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
19298         return (uint32_t)ret_conv;
19299 }
19300
19301 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
19302         LDKDecodeError e_conv;
19303         e_conv.inner = (void*)(e & (~1));
19304         e_conv.is_owned = (e & 1) || (e == 0);
19305         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19306         e_conv = DecodeError_clone(&e_conv);
19307         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19308         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
19309         return (uint32_t)ret_conv;
19310 }
19311
19312 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
19313         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
19314         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
19315         return ret_conv;
19316 }
19317
19318 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
19319         if ((_res & 1) != 0) return;
19320         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19321         CHECK_ACCESS(_res_ptr);
19322         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
19323         FREE((void*)_res);
19324         CResult_PingDecodeErrorZ_free(_res_conv);
19325 }
19326
19327 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
19328         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19329         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
19330         return (uint32_t)ret_conv;
19331 }
19332 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
19333         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
19334         uint32_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
19335         return ret_conv;
19336 }
19337
19338 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
19339         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
19340         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19341         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
19342         return (uint32_t)ret_conv;
19343 }
19344
19345 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
19346         LDKPong o_conv;
19347         o_conv.inner = (void*)(o & (~1));
19348         o_conv.is_owned = (o & 1) || (o == 0);
19349         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19350         o_conv = Pong_clone(&o_conv);
19351         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19352         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
19353         return (uint32_t)ret_conv;
19354 }
19355
19356 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
19357         LDKDecodeError e_conv;
19358         e_conv.inner = (void*)(e & (~1));
19359         e_conv.is_owned = (e & 1) || (e == 0);
19360         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19361         e_conv = DecodeError_clone(&e_conv);
19362         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19363         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
19364         return (uint32_t)ret_conv;
19365 }
19366
19367 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
19368         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
19369         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
19370         return ret_conv;
19371 }
19372
19373 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
19374         if ((_res & 1) != 0) return;
19375         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19376         CHECK_ACCESS(_res_ptr);
19377         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
19378         FREE((void*)_res);
19379         CResult_PongDecodeErrorZ_free(_res_conv);
19380 }
19381
19382 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
19383         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19384         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
19385         return (uint32_t)ret_conv;
19386 }
19387 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
19388         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
19389         uint32_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
19390         return ret_conv;
19391 }
19392
19393 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
19394         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
19395         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19396         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
19397         return (uint32_t)ret_conv;
19398 }
19399
19400 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
19401         LDKUnsignedChannelAnnouncement o_conv;
19402         o_conv.inner = (void*)(o & (~1));
19403         o_conv.is_owned = (o & 1) || (o == 0);
19404         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19405         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
19406         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19407         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
19408         return (uint32_t)ret_conv;
19409 }
19410
19411 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
19412         LDKDecodeError e_conv;
19413         e_conv.inner = (void*)(e & (~1));
19414         e_conv.is_owned = (e & 1) || (e == 0);
19415         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19416         e_conv = DecodeError_clone(&e_conv);
19417         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19418         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
19419         return (uint32_t)ret_conv;
19420 }
19421
19422 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19423         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
19424         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
19425         return ret_conv;
19426 }
19427
19428 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
19429         if ((_res & 1) != 0) return;
19430         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19431         CHECK_ACCESS(_res_ptr);
19432         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
19433         FREE((void*)_res);
19434         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
19435 }
19436
19437 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19438         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19439         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
19440         return (uint32_t)ret_conv;
19441 }
19442 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19443         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
19444         uint32_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19445         return ret_conv;
19446 }
19447
19448 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19449         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
19450         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19451         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
19452         return (uint32_t)ret_conv;
19453 }
19454
19455 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
19456         LDKChannelAnnouncement o_conv;
19457         o_conv.inner = (void*)(o & (~1));
19458         o_conv.is_owned = (o & 1) || (o == 0);
19459         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19460         o_conv = ChannelAnnouncement_clone(&o_conv);
19461         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19462         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
19463         return (uint32_t)ret_conv;
19464 }
19465
19466 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
19467         LDKDecodeError e_conv;
19468         e_conv.inner = (void*)(e & (~1));
19469         e_conv.is_owned = (e & 1) || (e == 0);
19470         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19471         e_conv = DecodeError_clone(&e_conv);
19472         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19473         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
19474         return (uint32_t)ret_conv;
19475 }
19476
19477 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19478         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
19479         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
19480         return ret_conv;
19481 }
19482
19483 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
19484         if ((_res & 1) != 0) return;
19485         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19486         CHECK_ACCESS(_res_ptr);
19487         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
19488         FREE((void*)_res);
19489         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
19490 }
19491
19492 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19493         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19494         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
19495         return (uint32_t)ret_conv;
19496 }
19497 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19498         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
19499         uint32_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19500         return ret_conv;
19501 }
19502
19503 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19504         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
19505         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19506         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
19507         return (uint32_t)ret_conv;
19508 }
19509
19510 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
19511         LDKUnsignedChannelUpdate o_conv;
19512         o_conv.inner = (void*)(o & (~1));
19513         o_conv.is_owned = (o & 1) || (o == 0);
19514         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19515         o_conv = UnsignedChannelUpdate_clone(&o_conv);
19516         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19517         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
19518         return (uint32_t)ret_conv;
19519 }
19520
19521 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
19522         LDKDecodeError e_conv;
19523         e_conv.inner = (void*)(e & (~1));
19524         e_conv.is_owned = (e & 1) || (e == 0);
19525         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19526         e_conv = DecodeError_clone(&e_conv);
19527         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19528         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
19529         return (uint32_t)ret_conv;
19530 }
19531
19532 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
19533         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
19534         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
19535         return ret_conv;
19536 }
19537
19538 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
19539         if ((_res & 1) != 0) return;
19540         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19541         CHECK_ACCESS(_res_ptr);
19542         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
19543         FREE((void*)_res);
19544         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
19545 }
19546
19547 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
19548         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19549         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
19550         return (uint32_t)ret_conv;
19551 }
19552 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
19553         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
19554         uint32_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
19555         return ret_conv;
19556 }
19557
19558 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
19559         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
19560         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19561         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
19562         return (uint32_t)ret_conv;
19563 }
19564
19565 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
19566         LDKChannelUpdate o_conv;
19567         o_conv.inner = (void*)(o & (~1));
19568         o_conv.is_owned = (o & 1) || (o == 0);
19569         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19570         o_conv = ChannelUpdate_clone(&o_conv);
19571         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19572         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
19573         return (uint32_t)ret_conv;
19574 }
19575
19576 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
19577         LDKDecodeError e_conv;
19578         e_conv.inner = (void*)(e & (~1));
19579         e_conv.is_owned = (e & 1) || (e == 0);
19580         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19581         e_conv = DecodeError_clone(&e_conv);
19582         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19583         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
19584         return (uint32_t)ret_conv;
19585 }
19586
19587 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
19588         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
19589         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
19590         return ret_conv;
19591 }
19592
19593 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
19594         if ((_res & 1) != 0) return;
19595         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19596         CHECK_ACCESS(_res_ptr);
19597         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
19598         FREE((void*)_res);
19599         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
19600 }
19601
19602 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
19603         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19604         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
19605         return (uint32_t)ret_conv;
19606 }
19607 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
19608         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
19609         uint32_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
19610         return ret_conv;
19611 }
19612
19613 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
19614         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
19615         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19616         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
19617         return (uint32_t)ret_conv;
19618 }
19619
19620 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
19621         LDKErrorMessage o_conv;
19622         o_conv.inner = (void*)(o & (~1));
19623         o_conv.is_owned = (o & 1) || (o == 0);
19624         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19625         o_conv = ErrorMessage_clone(&o_conv);
19626         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19627         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
19628         return (uint32_t)ret_conv;
19629 }
19630
19631 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
19632         LDKDecodeError e_conv;
19633         e_conv.inner = (void*)(e & (~1));
19634         e_conv.is_owned = (e & 1) || (e == 0);
19635         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19636         e_conv = DecodeError_clone(&e_conv);
19637         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19638         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
19639         return (uint32_t)ret_conv;
19640 }
19641
19642 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
19643         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
19644         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
19645         return ret_conv;
19646 }
19647
19648 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
19649         if ((_res & 1) != 0) return;
19650         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19651         CHECK_ACCESS(_res_ptr);
19652         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
19653         FREE((void*)_res);
19654         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
19655 }
19656
19657 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
19658         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19659         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
19660         return (uint32_t)ret_conv;
19661 }
19662 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
19663         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
19664         uint32_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
19665         return ret_conv;
19666 }
19667
19668 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
19669         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
19670         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19671         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
19672         return (uint32_t)ret_conv;
19673 }
19674
19675 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_ok"))) TS_CResult_WarningMessageDecodeErrorZ_ok(uint32_t o) {
19676         LDKWarningMessage o_conv;
19677         o_conv.inner = (void*)(o & (~1));
19678         o_conv.is_owned = (o & 1) || (o == 0);
19679         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19680         o_conv = WarningMessage_clone(&o_conv);
19681         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
19682         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
19683         return (uint32_t)ret_conv;
19684 }
19685
19686 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_err"))) TS_CResult_WarningMessageDecodeErrorZ_err(uint32_t e) {
19687         LDKDecodeError e_conv;
19688         e_conv.inner = (void*)(e & (~1));
19689         e_conv.is_owned = (e & 1) || (e == 0);
19690         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19691         e_conv = DecodeError_clone(&e_conv);
19692         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
19693         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
19694         return (uint32_t)ret_conv;
19695 }
19696
19697 jboolean  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_is_ok"))) TS_CResult_WarningMessageDecodeErrorZ_is_ok(uint32_t o) {
19698         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
19699         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
19700         return ret_conv;
19701 }
19702
19703 void  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_free"))) TS_CResult_WarningMessageDecodeErrorZ_free(uint32_t _res) {
19704         if ((_res & 1) != 0) return;
19705         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19706         CHECK_ACCESS(_res_ptr);
19707         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
19708         FREE((void*)_res);
19709         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
19710 }
19711
19712 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
19713         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
19714         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
19715         return (uint32_t)ret_conv;
19716 }
19717 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone_ptr"))) TS_CResult_WarningMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
19718         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
19719         uint32_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
19720         return ret_conv;
19721 }
19722
19723 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone"))) TS_CResult_WarningMessageDecodeErrorZ_clone(uint32_t orig) {
19724         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
19725         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
19726         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
19727         return (uint32_t)ret_conv;
19728 }
19729
19730 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
19731         LDKUnsignedNodeAnnouncement o_conv;
19732         o_conv.inner = (void*)(o & (~1));
19733         o_conv.is_owned = (o & 1) || (o == 0);
19734         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19735         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
19736         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19737         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
19738         return (uint32_t)ret_conv;
19739 }
19740
19741 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
19742         LDKDecodeError e_conv;
19743         e_conv.inner = (void*)(e & (~1));
19744         e_conv.is_owned = (e & 1) || (e == 0);
19745         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19746         e_conv = DecodeError_clone(&e_conv);
19747         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19748         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
19749         return (uint32_t)ret_conv;
19750 }
19751
19752 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19753         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
19754         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
19755         return ret_conv;
19756 }
19757
19758 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
19759         if ((_res & 1) != 0) return;
19760         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19761         CHECK_ACCESS(_res_ptr);
19762         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
19763         FREE((void*)_res);
19764         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
19765 }
19766
19767 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19768         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19769         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
19770         return (uint32_t)ret_conv;
19771 }
19772 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19773         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
19774         uint32_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19775         return ret_conv;
19776 }
19777
19778 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19779         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
19780         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19781         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
19782         return (uint32_t)ret_conv;
19783 }
19784
19785 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
19786         LDKNodeAnnouncement o_conv;
19787         o_conv.inner = (void*)(o & (~1));
19788         o_conv.is_owned = (o & 1) || (o == 0);
19789         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19790         o_conv = NodeAnnouncement_clone(&o_conv);
19791         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19792         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
19793         return (uint32_t)ret_conv;
19794 }
19795
19796 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
19797         LDKDecodeError e_conv;
19798         e_conv.inner = (void*)(e & (~1));
19799         e_conv.is_owned = (e & 1) || (e == 0);
19800         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19801         e_conv = DecodeError_clone(&e_conv);
19802         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19803         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
19804         return (uint32_t)ret_conv;
19805 }
19806
19807 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19808         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
19809         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
19810         return ret_conv;
19811 }
19812
19813 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
19814         if ((_res & 1) != 0) return;
19815         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19816         CHECK_ACCESS(_res_ptr);
19817         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
19818         FREE((void*)_res);
19819         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
19820 }
19821
19822 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19823         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19824         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
19825         return (uint32_t)ret_conv;
19826 }
19827 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19828         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
19829         uint32_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19830         return ret_conv;
19831 }
19832
19833 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19834         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
19835         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19836         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
19837         return (uint32_t)ret_conv;
19838 }
19839
19840 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
19841         LDKQueryShortChannelIds o_conv;
19842         o_conv.inner = (void*)(o & (~1));
19843         o_conv.is_owned = (o & 1) || (o == 0);
19844         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19845         o_conv = QueryShortChannelIds_clone(&o_conv);
19846         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19847         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
19848         return (uint32_t)ret_conv;
19849 }
19850
19851 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
19852         LDKDecodeError e_conv;
19853         e_conv.inner = (void*)(e & (~1));
19854         e_conv.is_owned = (e & 1) || (e == 0);
19855         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19856         e_conv = DecodeError_clone(&e_conv);
19857         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19858         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
19859         return (uint32_t)ret_conv;
19860 }
19861
19862 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
19863         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
19864         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
19865         return ret_conv;
19866 }
19867
19868 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
19869         if ((_res & 1) != 0) return;
19870         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19871         CHECK_ACCESS(_res_ptr);
19872         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
19873         FREE((void*)_res);
19874         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
19875 }
19876
19877 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
19878         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19879         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
19880         return (uint32_t)ret_conv;
19881 }
19882 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
19883         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
19884         uint32_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
19885         return ret_conv;
19886 }
19887
19888 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
19889         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
19890         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19891         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
19892         return (uint32_t)ret_conv;
19893 }
19894
19895 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
19896         LDKReplyShortChannelIdsEnd o_conv;
19897         o_conv.inner = (void*)(o & (~1));
19898         o_conv.is_owned = (o & 1) || (o == 0);
19899         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19900         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
19901         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19902         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
19903         return (uint32_t)ret_conv;
19904 }
19905
19906 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
19907         LDKDecodeError e_conv;
19908         e_conv.inner = (void*)(e & (~1));
19909         e_conv.is_owned = (e & 1) || (e == 0);
19910         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19911         e_conv = DecodeError_clone(&e_conv);
19912         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19913         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
19914         return (uint32_t)ret_conv;
19915 }
19916
19917 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
19918         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
19919         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
19920         return ret_conv;
19921 }
19922
19923 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
19924         if ((_res & 1) != 0) return;
19925         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19926         CHECK_ACCESS(_res_ptr);
19927         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
19928         FREE((void*)_res);
19929         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
19930 }
19931
19932 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
19933         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19934         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
19935         return (uint32_t)ret_conv;
19936 }
19937 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
19938         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
19939         uint32_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
19940         return ret_conv;
19941 }
19942
19943 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
19944         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
19945         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19946         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
19947         return (uint32_t)ret_conv;
19948 }
19949
19950 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
19951         LDKQueryChannelRange o_conv;
19952         o_conv.inner = (void*)(o & (~1));
19953         o_conv.is_owned = (o & 1) || (o == 0);
19954         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19955         o_conv = QueryChannelRange_clone(&o_conv);
19956         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19957         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
19958         return (uint32_t)ret_conv;
19959 }
19960
19961 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
19962         LDKDecodeError e_conv;
19963         e_conv.inner = (void*)(e & (~1));
19964         e_conv.is_owned = (e & 1) || (e == 0);
19965         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19966         e_conv = DecodeError_clone(&e_conv);
19967         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19968         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
19969         return (uint32_t)ret_conv;
19970 }
19971
19972 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
19973         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
19974         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
19975         return ret_conv;
19976 }
19977
19978 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
19979         if ((_res & 1) != 0) return;
19980         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19981         CHECK_ACCESS(_res_ptr);
19982         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
19983         FREE((void*)_res);
19984         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
19985 }
19986
19987 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
19988         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19989         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
19990         return (uint32_t)ret_conv;
19991 }
19992 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
19993         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
19994         uint32_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
19995         return ret_conv;
19996 }
19997
19998 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
19999         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
20000         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20001         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
20002         return (uint32_t)ret_conv;
20003 }
20004
20005 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
20006         LDKReplyChannelRange o_conv;
20007         o_conv.inner = (void*)(o & (~1));
20008         o_conv.is_owned = (o & 1) || (o == 0);
20009         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20010         o_conv = ReplyChannelRange_clone(&o_conv);
20011         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20012         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
20013         return (uint32_t)ret_conv;
20014 }
20015
20016 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
20017         LDKDecodeError e_conv;
20018         e_conv.inner = (void*)(e & (~1));
20019         e_conv.is_owned = (e & 1) || (e == 0);
20020         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20021         e_conv = DecodeError_clone(&e_conv);
20022         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20023         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
20024         return (uint32_t)ret_conv;
20025 }
20026
20027 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
20028         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
20029         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
20030         return ret_conv;
20031 }
20032
20033 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
20034         if ((_res & 1) != 0) return;
20035         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20036         CHECK_ACCESS(_res_ptr);
20037         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
20038         FREE((void*)_res);
20039         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
20040 }
20041
20042 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
20043         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20044         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
20045         return (uint32_t)ret_conv;
20046 }
20047 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
20048         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
20049         uint32_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
20050         return ret_conv;
20051 }
20052
20053 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
20054         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
20055         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20056         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
20057         return (uint32_t)ret_conv;
20058 }
20059
20060 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
20061         LDKGossipTimestampFilter o_conv;
20062         o_conv.inner = (void*)(o & (~1));
20063         o_conv.is_owned = (o & 1) || (o == 0);
20064         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20065         o_conv = GossipTimestampFilter_clone(&o_conv);
20066         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20067         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
20068         return (uint32_t)ret_conv;
20069 }
20070
20071 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
20072         LDKDecodeError e_conv;
20073         e_conv.inner = (void*)(e & (~1));
20074         e_conv.is_owned = (e & 1) || (e == 0);
20075         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20076         e_conv = DecodeError_clone(&e_conv);
20077         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20078         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
20079         return (uint32_t)ret_conv;
20080 }
20081
20082 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
20083         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
20084         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
20085         return ret_conv;
20086 }
20087
20088 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
20089         if ((_res & 1) != 0) return;
20090         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20091         CHECK_ACCESS(_res_ptr);
20092         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
20093         FREE((void*)_res);
20094         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
20095 }
20096
20097 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
20098         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20099         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
20100         return (uint32_t)ret_conv;
20101 }
20102 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
20103         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
20104         uint32_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
20105         return ret_conv;
20106 }
20107
20108 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
20109         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
20110         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20111         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
20112         return (uint32_t)ret_conv;
20113 }
20114
20115 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
20116         LDKInvoice o_conv;
20117         o_conv.inner = (void*)(o & (~1));
20118         o_conv.is_owned = (o & 1) || (o == 0);
20119         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20120         o_conv = Invoice_clone(&o_conv);
20121         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20122         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
20123         return (uint32_t)ret_conv;
20124 }
20125
20126 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
20127         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20128         CHECK_ACCESS(e_ptr);
20129         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
20130         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
20131         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20132         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
20133         return (uint32_t)ret_conv;
20134 }
20135
20136 jboolean  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_is_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_is_ok(uint32_t o) {
20137         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
20138         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
20139         return ret_conv;
20140 }
20141
20142 void  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_free"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
20143         if ((_res & 1) != 0) return;
20144         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20145         CHECK_ACCESS(_res_ptr);
20146         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
20147         FREE((void*)_res);
20148         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
20149 }
20150
20151 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
20152         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20153         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
20154         return (uint32_t)ret_conv;
20155 }
20156 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr(uint32_t arg) {
20157         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
20158         uint32_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
20159         return ret_conv;
20160 }
20161
20162 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
20163         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
20164         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20165         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
20166         return (uint32_t)ret_conv;
20167 }
20168
20169 uint32_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint32_t o) {
20170         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20171         CHECK_ACCESS(o_ptr);
20172         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
20173         if (o_conv.free == LDKFilter_JCalls_free) {
20174                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20175                 LDKFilter_JCalls_cloned(&o_conv);
20176         }
20177         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
20178         *ret_copy = COption_FilterZ_some(o_conv);
20179         uint32_t ret_ref = (uintptr_t)ret_copy;
20180         return ret_ref;
20181 }
20182
20183 uint32_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
20184         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
20185         *ret_copy = COption_FilterZ_none();
20186         uint32_t ret_ref = (uintptr_t)ret_copy;
20187         return ret_ref;
20188 }
20189
20190 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint32_t _res) {
20191         if ((_res & 1) != 0) return;
20192         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20193         CHECK_ACCESS(_res_ptr);
20194         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
20195         FREE((void*)_res);
20196         COption_FilterZ_free(_res_conv);
20197 }
20198
20199 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
20200         LDKLockedChannelMonitor o_conv;
20201         o_conv.inner = (void*)(o & (~1));
20202         o_conv.is_owned = (o & 1) || (o == 0);
20203         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20204         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
20205         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
20206         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
20207         return (uint32_t)ret_conv;
20208 }
20209
20210 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
20211         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
20212         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
20213         return (uint32_t)ret_conv;
20214 }
20215
20216 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
20217         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
20218         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
20219         return ret_conv;
20220 }
20221
20222 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
20223         if ((_res & 1) != 0) return;
20224         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20225         CHECK_ACCESS(_res_ptr);
20226         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
20227         FREE((void*)_res);
20228         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
20229 }
20230
20231 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
20232         LDKCVec_OutPointZ _res_constr;
20233         _res_constr.datalen = _res->arr_len;
20234         if (_res_constr.datalen > 0)
20235                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
20236         else
20237                 _res_constr.data = NULL;
20238         uint32_t* _res_vals = _res->elems;
20239         for (size_t k = 0; k < _res_constr.datalen; k++) {
20240                 uint32_t _res_conv_10 = _res_vals[k];
20241                 LDKOutPoint _res_conv_10_conv;
20242                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
20243                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
20244                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
20245                 _res_constr.data[k] = _res_conv_10_conv;
20246         }
20247         FREE(_res);
20248         CVec_OutPointZ_free(_res_constr);
20249 }
20250
20251 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
20252         if ((this_ptr & 1) != 0) return;
20253         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20254         CHECK_ACCESS(this_ptr_ptr);
20255         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
20256         FREE((void*)this_ptr);
20257         PaymentPurpose_free(this_ptr_conv);
20258 }
20259
20260 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
20261         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20262         *ret_copy = PaymentPurpose_clone(arg);
20263 uint32_t ret_ref = (uintptr_t)ret_copy;
20264         return ret_ref;
20265 }
20266 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
20267         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
20268         uint32_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
20269         return ret_conv;
20270 }
20271
20272 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint32_t orig) {
20273         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
20274         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20275         *ret_copy = PaymentPurpose_clone(orig_conv);
20276         uint32_t ret_ref = (uintptr_t)ret_copy;
20277         return ret_ref;
20278 }
20279
20280 uint32_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
20281         LDKThirtyTwoBytes payment_preimage_ref;
20282         CHECK(payment_preimage->arr_len == 32);
20283         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
20284         LDKThirtyTwoBytes payment_secret_ref;
20285         CHECK(payment_secret->arr_len == 32);
20286         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
20287         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20288         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
20289         uint32_t ret_ref = (uintptr_t)ret_copy;
20290         return ret_ref;
20291 }
20292
20293 uint32_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
20294         LDKThirtyTwoBytes a_ref;
20295         CHECK(a->arr_len == 32);
20296         memcpy(a_ref.data, a->elems, 32); FREE(a);
20297         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20298         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
20299         uint32_t ret_ref = (uintptr_t)ret_copy;
20300         return ret_ref;
20301 }
20302
20303 int8_tArray  __attribute__((export_name("TS_PaymentPurpose_write"))) TS_PaymentPurpose_write(uint32_t obj) {
20304         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)obj;
20305         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
20306         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20307         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20308         CVec_u8Z_free(ret_var);
20309         return ret_arr;
20310 }
20311
20312 uint32_t  __attribute__((export_name("TS_PaymentPurpose_read"))) TS_PaymentPurpose_read(int8_tArray ser) {
20313         LDKu8slice ser_ref;
20314         ser_ref.datalen = ser->arr_len;
20315         ser_ref.data = ser->elems;
20316         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
20317         *ret_conv = PaymentPurpose_read(ser_ref);
20318         FREE(ser);
20319         return (uint32_t)ret_conv;
20320 }
20321
20322 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint32_t this_ptr) {
20323         if ((this_ptr & 1) != 0) return;
20324         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20325         CHECK_ACCESS(this_ptr_ptr);
20326         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
20327         FREE((void*)this_ptr);
20328         ClosureReason_free(this_ptr_conv);
20329 }
20330
20331 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
20332         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20333         *ret_copy = ClosureReason_clone(arg);
20334 uint32_t ret_ref = (uintptr_t)ret_copy;
20335         return ret_ref;
20336 }
20337 uint32_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
20338         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
20339         uint32_t ret_conv = ClosureReason_clone_ptr(arg_conv);
20340         return ret_conv;
20341 }
20342
20343 uint32_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint32_t orig) {
20344         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
20345         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20346         *ret_copy = ClosureReason_clone(orig_conv);
20347         uint32_t ret_ref = (uintptr_t)ret_copy;
20348         return ret_ref;
20349 }
20350
20351 uint32_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
20352         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
20353         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20354         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
20355         uint32_t ret_ref = (uintptr_t)ret_copy;
20356         return ret_ref;
20357 }
20358
20359 uint32_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
20360         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20361         *ret_copy = ClosureReason_holder_force_closed();
20362         uint32_t ret_ref = (uintptr_t)ret_copy;
20363         return ret_ref;
20364 }
20365
20366 uint32_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
20367         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20368         *ret_copy = ClosureReason_cooperative_closure();
20369         uint32_t ret_ref = (uintptr_t)ret_copy;
20370         return ret_ref;
20371 }
20372
20373 uint32_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
20374         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20375         *ret_copy = ClosureReason_commitment_tx_confirmed();
20376         uint32_t ret_ref = (uintptr_t)ret_copy;
20377         return ret_ref;
20378 }
20379
20380 uint32_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
20381         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20382         *ret_copy = ClosureReason_funding_timed_out();
20383         uint32_t ret_ref = (uintptr_t)ret_copy;
20384         return ret_ref;
20385 }
20386
20387 uint32_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
20388         LDKStr err_conv = str_ref_to_owned_c(err);
20389         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20390         *ret_copy = ClosureReason_processing_error(err_conv);
20391         uint32_t ret_ref = (uintptr_t)ret_copy;
20392         return ret_ref;
20393 }
20394
20395 uint32_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
20396         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20397         *ret_copy = ClosureReason_disconnected_peer();
20398         uint32_t ret_ref = (uintptr_t)ret_copy;
20399         return ret_ref;
20400 }
20401
20402 uint32_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
20403         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20404         *ret_copy = ClosureReason_outdated_channel_manager();
20405         uint32_t ret_ref = (uintptr_t)ret_copy;
20406         return ret_ref;
20407 }
20408
20409 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint32_t obj) {
20410         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
20411         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
20412         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20413         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20414         CVec_u8Z_free(ret_var);
20415         return ret_arr;
20416 }
20417
20418 uint32_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
20419         LDKu8slice ser_ref;
20420         ser_ref.datalen = ser->arr_len;
20421         ser_ref.data = ser->elems;
20422         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
20423         *ret_conv = ClosureReason_read(ser_ref);
20424         FREE(ser);
20425         return (uint32_t)ret_conv;
20426 }
20427
20428 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint32_t this_ptr) {
20429         if ((this_ptr & 1) != 0) return;
20430         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20431         CHECK_ACCESS(this_ptr_ptr);
20432         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
20433         FREE((void*)this_ptr);
20434         Event_free(this_ptr_conv);
20435 }
20436
20437 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
20438         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20439         *ret_copy = Event_clone(arg);
20440 uint32_t ret_ref = (uintptr_t)ret_copy;
20441         return ret_ref;
20442 }
20443 uint32_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint32_t arg) {
20444         LDKEvent* arg_conv = (LDKEvent*)arg;
20445         uint32_t ret_conv = Event_clone_ptr(arg_conv);
20446         return ret_conv;
20447 }
20448
20449 uint32_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint32_t orig) {
20450         LDKEvent* orig_conv = (LDKEvent*)orig;
20451         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20452         *ret_copy = Event_clone(orig_conv);
20453         uint32_t ret_ref = (uintptr_t)ret_copy;
20454         return ret_ref;
20455 }
20456
20457 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) {
20458         LDKThirtyTwoBytes temporary_channel_id_ref;
20459         CHECK(temporary_channel_id->arr_len == 32);
20460         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
20461         LDKPublicKey counterparty_node_id_ref;
20462         CHECK(counterparty_node_id->arr_len == 33);
20463         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
20464         LDKCVec_u8Z output_script_ref;
20465         output_script_ref.datalen = output_script->arr_len;
20466         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
20467         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
20468         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20469         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
20470         uint32_t ret_ref = (uintptr_t)ret_copy;
20471         return ret_ref;
20472 }
20473
20474 uint32_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amount_msat, uint32_t purpose) {
20475         LDKThirtyTwoBytes payment_hash_ref;
20476         CHECK(payment_hash->arr_len == 32);
20477         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20478         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
20479         CHECK_ACCESS(purpose_ptr);
20480         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
20481         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
20482         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20483         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
20484         uint32_t ret_ref = (uintptr_t)ret_copy;
20485         return ret_ref;
20486 }
20487
20488 uint32_t  __attribute__((export_name("TS_Event_payment_claimed"))) TS_Event_payment_claimed(int8_tArray payment_hash, int64_t amount_msat, uint32_t purpose) {
20489         LDKThirtyTwoBytes payment_hash_ref;
20490         CHECK(payment_hash->arr_len == 32);
20491         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20492         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
20493         CHECK_ACCESS(purpose_ptr);
20494         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
20495         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
20496         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20497         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
20498         uint32_t ret_ref = (uintptr_t)ret_copy;
20499         return ret_ref;
20500 }
20501
20502 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) {
20503         LDKThirtyTwoBytes payment_id_ref;
20504         CHECK(payment_id->arr_len == 32);
20505         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20506         LDKThirtyTwoBytes payment_preimage_ref;
20507         CHECK(payment_preimage->arr_len == 32);
20508         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
20509         LDKThirtyTwoBytes payment_hash_ref;
20510         CHECK(payment_hash->arr_len == 32);
20511         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20512         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
20513         CHECK_ACCESS(fee_paid_msat_ptr);
20514         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
20515         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
20516         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20517         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
20518         uint32_t ret_ref = (uintptr_t)ret_copy;
20519         return ret_ref;
20520 }
20521
20522 uint32_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
20523         LDKThirtyTwoBytes payment_id_ref;
20524         CHECK(payment_id->arr_len == 32);
20525         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20526         LDKThirtyTwoBytes payment_hash_ref;
20527         CHECK(payment_hash->arr_len == 32);
20528         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20529         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20530         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
20531         uint32_t ret_ref = (uintptr_t)ret_copy;
20532         return ret_ref;
20533 }
20534
20535 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) {
20536         LDKThirtyTwoBytes payment_id_ref;
20537         CHECK(payment_id->arr_len == 32);
20538         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20539         LDKThirtyTwoBytes payment_hash_ref;
20540         CHECK(payment_hash->arr_len == 32);
20541         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20542         LDKCVec_RouteHopZ path_constr;
20543         path_constr.datalen = path->arr_len;
20544         if (path_constr.datalen > 0)
20545                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20546         else
20547                 path_constr.data = NULL;
20548         uint32_t* path_vals = path->elems;
20549         for (size_t k = 0; k < path_constr.datalen; k++) {
20550                 uint32_t path_conv_10 = path_vals[k];
20551                 LDKRouteHop path_conv_10_conv;
20552                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
20553                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
20554                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
20555                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
20556                 path_constr.data[k] = path_conv_10_conv;
20557         }
20558         FREE(path);
20559         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20560         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
20561         uint32_t ret_ref = (uintptr_t)ret_copy;
20562         return ret_ref;
20563 }
20564
20565 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) {
20566         LDKThirtyTwoBytes payment_id_ref;
20567         CHECK(payment_id->arr_len == 32);
20568         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20569         LDKThirtyTwoBytes payment_hash_ref;
20570         CHECK(payment_hash->arr_len == 32);
20571         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20572         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
20573         CHECK_ACCESS(network_update_ptr);
20574         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
20575         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
20576         LDKCVec_RouteHopZ path_constr;
20577         path_constr.datalen = path->arr_len;
20578         if (path_constr.datalen > 0)
20579                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20580         else
20581                 path_constr.data = NULL;
20582         uint32_t* path_vals = path->elems;
20583         for (size_t k = 0; k < path_constr.datalen; k++) {
20584                 uint32_t path_conv_10 = path_vals[k];
20585                 LDKRouteHop path_conv_10_conv;
20586                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
20587                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
20588                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
20589                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
20590                 path_constr.data[k] = path_conv_10_conv;
20591         }
20592         FREE(path);
20593         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
20594         CHECK_ACCESS(short_channel_id_ptr);
20595         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
20596         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
20597         LDKRouteParameters retry_conv;
20598         retry_conv.inner = (void*)(retry & (~1));
20599         retry_conv.is_owned = (retry & 1) || (retry == 0);
20600         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
20601         retry_conv = RouteParameters_clone(&retry_conv);
20602         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20603         *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);
20604         uint32_t ret_ref = (uintptr_t)ret_copy;
20605         return ret_ref;
20606 }
20607
20608 uint32_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
20609         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20610         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
20611         uint32_t ret_ref = (uintptr_t)ret_copy;
20612         return ret_ref;
20613 }
20614
20615 uint32_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
20616         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
20617         outputs_constr.datalen = outputs->arr_len;
20618         if (outputs_constr.datalen > 0)
20619                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
20620         else
20621                 outputs_constr.data = NULL;
20622         uint32_t* outputs_vals = outputs->elems;
20623         for (size_t b = 0; b < outputs_constr.datalen; b++) {
20624                 uint32_t outputs_conv_27 = outputs_vals[b];
20625                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
20626                 CHECK_ACCESS(outputs_conv_27_ptr);
20627                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
20628                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
20629                 outputs_constr.data[b] = outputs_conv_27_conv;
20630         }
20631         FREE(outputs);
20632         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20633         *ret_copy = Event_spendable_outputs(outputs_constr);
20634         uint32_t ret_ref = (uintptr_t)ret_copy;
20635         return ret_ref;
20636 }
20637
20638 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) {
20639         LDKThirtyTwoBytes prev_channel_id_ref;
20640         CHECK(prev_channel_id->arr_len == 32);
20641         memcpy(prev_channel_id_ref.data, prev_channel_id->elems, 32); FREE(prev_channel_id);
20642         LDKThirtyTwoBytes next_channel_id_ref;
20643         CHECK(next_channel_id->arr_len == 32);
20644         memcpy(next_channel_id_ref.data, next_channel_id->elems, 32); FREE(next_channel_id);
20645         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
20646         CHECK_ACCESS(fee_earned_msat_ptr);
20647         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
20648         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
20649         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20650         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
20651         uint32_t ret_ref = (uintptr_t)ret_copy;
20652         return ret_ref;
20653 }
20654
20655 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) {
20656         LDKThirtyTwoBytes channel_id_ref;
20657         CHECK(channel_id->arr_len == 32);
20658         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
20659         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
20660         CHECK_ACCESS(reason_ptr);
20661         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
20662         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
20663         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20664         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
20665         uint32_t ret_ref = (uintptr_t)ret_copy;
20666         return ret_ref;
20667 }
20668
20669 uint32_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
20670         LDKThirtyTwoBytes channel_id_ref;
20671         CHECK(channel_id->arr_len == 32);
20672         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
20673         LDKTransaction transaction_ref;
20674         transaction_ref.datalen = transaction->arr_len;
20675         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
20676         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
20677         transaction_ref.data_is_owned = true;
20678         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20679         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
20680         uint32_t ret_ref = (uintptr_t)ret_copy;
20681         return ret_ref;
20682 }
20683
20684 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) {
20685         LDKThirtyTwoBytes temporary_channel_id_ref;
20686         CHECK(temporary_channel_id->arr_len == 32);
20687         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
20688         LDKPublicKey counterparty_node_id_ref;
20689         CHECK(counterparty_node_id->arr_len == 33);
20690         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
20691         LDKChannelTypeFeatures channel_type_conv;
20692         channel_type_conv.inner = (void*)(channel_type & (~1));
20693         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
20694         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
20695         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
20696         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20697         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
20698         uint32_t ret_ref = (uintptr_t)ret_copy;
20699         return ret_ref;
20700 }
20701
20702 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint32_t obj) {
20703         LDKEvent* obj_conv = (LDKEvent*)obj;
20704         LDKCVec_u8Z ret_var = Event_write(obj_conv);
20705         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20706         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20707         CVec_u8Z_free(ret_var);
20708         return ret_arr;
20709 }
20710
20711 uint32_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
20712         LDKu8slice ser_ref;
20713         ser_ref.datalen = ser->arr_len;
20714         ser_ref.data = ser->elems;
20715         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
20716         *ret_conv = Event_read(ser_ref);
20717         FREE(ser);
20718         return (uint32_t)ret_conv;
20719 }
20720
20721 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
20722         if ((this_ptr & 1) != 0) return;
20723         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20724         CHECK_ACCESS(this_ptr_ptr);
20725         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
20726         FREE((void*)this_ptr);
20727         MessageSendEvent_free(this_ptr_conv);
20728 }
20729
20730 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
20731         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20732         *ret_copy = MessageSendEvent_clone(arg);
20733 uint32_t ret_ref = (uintptr_t)ret_copy;
20734         return ret_ref;
20735 }
20736 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
20737         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
20738         uint32_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
20739         return ret_conv;
20740 }
20741
20742 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint32_t orig) {
20743         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
20744         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20745         *ret_copy = MessageSendEvent_clone(orig_conv);
20746         uint32_t ret_ref = (uintptr_t)ret_copy;
20747         return ret_ref;
20748 }
20749
20750 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
20751         LDKPublicKey node_id_ref;
20752         CHECK(node_id->arr_len == 33);
20753         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20754         LDKAcceptChannel msg_conv;
20755         msg_conv.inner = (void*)(msg & (~1));
20756         msg_conv.is_owned = (msg & 1) || (msg == 0);
20757         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20758         msg_conv = AcceptChannel_clone(&msg_conv);
20759         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20760         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
20761         uint32_t ret_ref = (uintptr_t)ret_copy;
20762         return ret_ref;
20763 }
20764
20765 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
20766         LDKPublicKey node_id_ref;
20767         CHECK(node_id->arr_len == 33);
20768         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20769         LDKOpenChannel msg_conv;
20770         msg_conv.inner = (void*)(msg & (~1));
20771         msg_conv.is_owned = (msg & 1) || (msg == 0);
20772         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20773         msg_conv = OpenChannel_clone(&msg_conv);
20774         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20775         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
20776         uint32_t ret_ref = (uintptr_t)ret_copy;
20777         return ret_ref;
20778 }
20779
20780 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
20781         LDKPublicKey node_id_ref;
20782         CHECK(node_id->arr_len == 33);
20783         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20784         LDKFundingCreated msg_conv;
20785         msg_conv.inner = (void*)(msg & (~1));
20786         msg_conv.is_owned = (msg & 1) || (msg == 0);
20787         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20788         msg_conv = FundingCreated_clone(&msg_conv);
20789         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20790         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
20791         uint32_t ret_ref = (uintptr_t)ret_copy;
20792         return ret_ref;
20793 }
20794
20795 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
20796         LDKPublicKey node_id_ref;
20797         CHECK(node_id->arr_len == 33);
20798         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20799         LDKFundingSigned msg_conv;
20800         msg_conv.inner = (void*)(msg & (~1));
20801         msg_conv.is_owned = (msg & 1) || (msg == 0);
20802         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20803         msg_conv = FundingSigned_clone(&msg_conv);
20804         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20805         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
20806         uint32_t ret_ref = (uintptr_t)ret_copy;
20807         return ret_ref;
20808 }
20809
20810 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_ready"))) TS_MessageSendEvent_send_channel_ready(int8_tArray node_id, uint32_t msg) {
20811         LDKPublicKey node_id_ref;
20812         CHECK(node_id->arr_len == 33);
20813         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20814         LDKChannelReady msg_conv;
20815         msg_conv.inner = (void*)(msg & (~1));
20816         msg_conv.is_owned = (msg & 1) || (msg == 0);
20817         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20818         msg_conv = ChannelReady_clone(&msg_conv);
20819         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20820         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
20821         uint32_t ret_ref = (uintptr_t)ret_copy;
20822         return ret_ref;
20823 }
20824
20825 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
20826         LDKPublicKey node_id_ref;
20827         CHECK(node_id->arr_len == 33);
20828         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20829         LDKAnnouncementSignatures msg_conv;
20830         msg_conv.inner = (void*)(msg & (~1));
20831         msg_conv.is_owned = (msg & 1) || (msg == 0);
20832         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20833         msg_conv = AnnouncementSignatures_clone(&msg_conv);
20834         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20835         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
20836         uint32_t ret_ref = (uintptr_t)ret_copy;
20837         return ret_ref;
20838 }
20839
20840 uint32_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
20841         LDKPublicKey node_id_ref;
20842         CHECK(node_id->arr_len == 33);
20843         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20844         LDKCommitmentUpdate updates_conv;
20845         updates_conv.inner = (void*)(updates & (~1));
20846         updates_conv.is_owned = (updates & 1) || (updates == 0);
20847         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
20848         updates_conv = CommitmentUpdate_clone(&updates_conv);
20849         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20850         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
20851         uint32_t ret_ref = (uintptr_t)ret_copy;
20852         return ret_ref;
20853 }
20854
20855 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
20856         LDKPublicKey node_id_ref;
20857         CHECK(node_id->arr_len == 33);
20858         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20859         LDKRevokeAndACK msg_conv;
20860         msg_conv.inner = (void*)(msg & (~1));
20861         msg_conv.is_owned = (msg & 1) || (msg == 0);
20862         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20863         msg_conv = RevokeAndACK_clone(&msg_conv);
20864         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20865         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
20866         uint32_t ret_ref = (uintptr_t)ret_copy;
20867         return ret_ref;
20868 }
20869
20870 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
20871         LDKPublicKey node_id_ref;
20872         CHECK(node_id->arr_len == 33);
20873         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20874         LDKClosingSigned msg_conv;
20875         msg_conv.inner = (void*)(msg & (~1));
20876         msg_conv.is_owned = (msg & 1) || (msg == 0);
20877         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20878         msg_conv = ClosingSigned_clone(&msg_conv);
20879         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20880         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
20881         uint32_t ret_ref = (uintptr_t)ret_copy;
20882         return ret_ref;
20883 }
20884
20885 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
20886         LDKPublicKey node_id_ref;
20887         CHECK(node_id->arr_len == 33);
20888         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20889         LDKShutdown msg_conv;
20890         msg_conv.inner = (void*)(msg & (~1));
20891         msg_conv.is_owned = (msg & 1) || (msg == 0);
20892         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20893         msg_conv = Shutdown_clone(&msg_conv);
20894         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20895         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
20896         uint32_t ret_ref = (uintptr_t)ret_copy;
20897         return ret_ref;
20898 }
20899
20900 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
20901         LDKPublicKey node_id_ref;
20902         CHECK(node_id->arr_len == 33);
20903         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20904         LDKChannelReestablish msg_conv;
20905         msg_conv.inner = (void*)(msg & (~1));
20906         msg_conv.is_owned = (msg & 1) || (msg == 0);
20907         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20908         msg_conv = ChannelReestablish_clone(&msg_conv);
20909         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20910         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
20911         uint32_t ret_ref = (uintptr_t)ret_copy;
20912         return ret_ref;
20913 }
20914
20915 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
20916         LDKChannelAnnouncement msg_conv;
20917         msg_conv.inner = (void*)(msg & (~1));
20918         msg_conv.is_owned = (msg & 1) || (msg == 0);
20919         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20920         msg_conv = ChannelAnnouncement_clone(&msg_conv);
20921         LDKChannelUpdate update_msg_conv;
20922         update_msg_conv.inner = (void*)(update_msg & (~1));
20923         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
20924         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
20925         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
20926         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20927         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
20928         uint32_t ret_ref = (uintptr_t)ret_copy;
20929         return ret_ref;
20930 }
20931
20932 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_node_announcement"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
20933         LDKNodeAnnouncement msg_conv;
20934         msg_conv.inner = (void*)(msg & (~1));
20935         msg_conv.is_owned = (msg & 1) || (msg == 0);
20936         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20937         msg_conv = NodeAnnouncement_clone(&msg_conv);
20938         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20939         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
20940         uint32_t ret_ref = (uintptr_t)ret_copy;
20941         return ret_ref;
20942 }
20943
20944 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
20945         LDKChannelUpdate msg_conv;
20946         msg_conv.inner = (void*)(msg & (~1));
20947         msg_conv.is_owned = (msg & 1) || (msg == 0);
20948         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20949         msg_conv = ChannelUpdate_clone(&msg_conv);
20950         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20951         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
20952         uint32_t ret_ref = (uintptr_t)ret_copy;
20953         return ret_ref;
20954 }
20955
20956 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
20957         LDKPublicKey node_id_ref;
20958         CHECK(node_id->arr_len == 33);
20959         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20960         LDKChannelUpdate msg_conv;
20961         msg_conv.inner = (void*)(msg & (~1));
20962         msg_conv.is_owned = (msg & 1) || (msg == 0);
20963         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20964         msg_conv = ChannelUpdate_clone(&msg_conv);
20965         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20966         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
20967         uint32_t ret_ref = (uintptr_t)ret_copy;
20968         return ret_ref;
20969 }
20970
20971 uint32_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
20972         LDKPublicKey node_id_ref;
20973         CHECK(node_id->arr_len == 33);
20974         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20975         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
20976         CHECK_ACCESS(action_ptr);
20977         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
20978         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
20979         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20980         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
20981         uint32_t ret_ref = (uintptr_t)ret_copy;
20982         return ret_ref;
20983 }
20984
20985 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
20986         LDKPublicKey node_id_ref;
20987         CHECK(node_id->arr_len == 33);
20988         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20989         LDKQueryChannelRange msg_conv;
20990         msg_conv.inner = (void*)(msg & (~1));
20991         msg_conv.is_owned = (msg & 1) || (msg == 0);
20992         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20993         msg_conv = QueryChannelRange_clone(&msg_conv);
20994         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20995         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
20996         uint32_t ret_ref = (uintptr_t)ret_copy;
20997         return ret_ref;
20998 }
20999
21000 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
21001         LDKPublicKey node_id_ref;
21002         CHECK(node_id->arr_len == 33);
21003         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21004         LDKQueryShortChannelIds msg_conv;
21005         msg_conv.inner = (void*)(msg & (~1));
21006         msg_conv.is_owned = (msg & 1) || (msg == 0);
21007         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21008         msg_conv = QueryShortChannelIds_clone(&msg_conv);
21009         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21010         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
21011         uint32_t ret_ref = (uintptr_t)ret_copy;
21012         return ret_ref;
21013 }
21014
21015 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
21016         LDKPublicKey node_id_ref;
21017         CHECK(node_id->arr_len == 33);
21018         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21019         LDKReplyChannelRange msg_conv;
21020         msg_conv.inner = (void*)(msg & (~1));
21021         msg_conv.is_owned = (msg & 1) || (msg == 0);
21022         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21023         msg_conv = ReplyChannelRange_clone(&msg_conv);
21024         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21025         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
21026         uint32_t ret_ref = (uintptr_t)ret_copy;
21027         return ret_ref;
21028 }
21029
21030 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_gossip_timestamp_filter"))) TS_MessageSendEvent_send_gossip_timestamp_filter(int8_tArray node_id, uint32_t msg) {
21031         LDKPublicKey node_id_ref;
21032         CHECK(node_id->arr_len == 33);
21033         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21034         LDKGossipTimestampFilter msg_conv;
21035         msg_conv.inner = (void*)(msg & (~1));
21036         msg_conv.is_owned = (msg & 1) || (msg == 0);
21037         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21038         msg_conv = GossipTimestampFilter_clone(&msg_conv);
21039         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21040         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
21041         uint32_t ret_ref = (uintptr_t)ret_copy;
21042         return ret_ref;
21043 }
21044
21045 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
21046         if ((this_ptr & 1) != 0) return;
21047         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21048         CHECK_ACCESS(this_ptr_ptr);
21049         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
21050         FREE((void*)this_ptr);
21051         MessageSendEventsProvider_free(this_ptr_conv);
21052 }
21053
21054 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint32_t this_ptr) {
21055         if ((this_ptr & 1) != 0) return;
21056         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21057         CHECK_ACCESS(this_ptr_ptr);
21058         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
21059         FREE((void*)this_ptr);
21060         EventsProvider_free(this_ptr_conv);
21061 }
21062
21063 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint32_t this_ptr) {
21064         if ((this_ptr & 1) != 0) return;
21065         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21066         CHECK_ACCESS(this_ptr_ptr);
21067         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
21068         FREE((void*)this_ptr);
21069         EventHandler_free(this_ptr_conv);
21070 }
21071
21072 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint32_t this_ptr) {
21073         if ((this_ptr & 1) != 0) return;
21074         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21075         CHECK_ACCESS(this_ptr_ptr);
21076         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
21077         FREE((void*)this_ptr);
21078         APIError_free(this_ptr_conv);
21079 }
21080
21081 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
21082         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21083         *ret_copy = APIError_clone(arg);
21084 uint32_t ret_ref = (uintptr_t)ret_copy;
21085         return ret_ref;
21086 }
21087 uint32_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint32_t arg) {
21088         LDKAPIError* arg_conv = (LDKAPIError*)arg;
21089         uint32_t ret_conv = APIError_clone_ptr(arg_conv);
21090         return ret_conv;
21091 }
21092
21093 uint32_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint32_t orig) {
21094         LDKAPIError* orig_conv = (LDKAPIError*)orig;
21095         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21096         *ret_copy = APIError_clone(orig_conv);
21097         uint32_t ret_ref = (uintptr_t)ret_copy;
21098         return ret_ref;
21099 }
21100
21101 uint32_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
21102         LDKStr err_conv = str_ref_to_owned_c(err);
21103         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21104         *ret_copy = APIError_apimisuse_error(err_conv);
21105         uint32_t ret_ref = (uintptr_t)ret_copy;
21106         return ret_ref;
21107 }
21108
21109 uint32_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
21110         LDKStr err_conv = str_ref_to_owned_c(err);
21111         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21112         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
21113         uint32_t ret_ref = (uintptr_t)ret_copy;
21114         return ret_ref;
21115 }
21116
21117 uint32_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
21118         LDKStr err_conv = str_ref_to_owned_c(err);
21119         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21120         *ret_copy = APIError_route_error(err_conv);
21121         uint32_t ret_ref = (uintptr_t)ret_copy;
21122         return ret_ref;
21123 }
21124
21125 uint32_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
21126         LDKStr err_conv = str_ref_to_owned_c(err);
21127         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21128         *ret_copy = APIError_channel_unavailable(err_conv);
21129         uint32_t ret_ref = (uintptr_t)ret_copy;
21130         return ret_ref;
21131 }
21132
21133 uint32_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
21134         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21135         *ret_copy = APIError_monitor_update_failed();
21136         uint32_t ret_ref = (uintptr_t)ret_copy;
21137         return ret_ref;
21138 }
21139
21140 uint32_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
21141         LDKShutdownScript script_conv;
21142         script_conv.inner = (void*)(script & (~1));
21143         script_conv.is_owned = (script & 1) || (script == 0);
21144         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
21145         script_conv = ShutdownScript_clone(&script_conv);
21146         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21147         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
21148         uint32_t ret_ref = (uintptr_t)ret_copy;
21149         return ret_ref;
21150 }
21151
21152 void  __attribute__((export_name("TS_BigSize_free"))) TS_BigSize_free(uint32_t this_obj) {
21153         LDKBigSize this_obj_conv;
21154         this_obj_conv.inner = (void*)(this_obj & (~1));
21155         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21157         BigSize_free(this_obj_conv);
21158 }
21159
21160 int64_t  __attribute__((export_name("TS_BigSize_get_a"))) TS_BigSize_get_a(uint32_t this_ptr) {
21161         LDKBigSize this_ptr_conv;
21162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21163         this_ptr_conv.is_owned = false;
21164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21165         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
21166         return ret_conv;
21167 }
21168
21169 void  __attribute__((export_name("TS_BigSize_set_a"))) TS_BigSize_set_a(uint32_t this_ptr, int64_t val) {
21170         LDKBigSize this_ptr_conv;
21171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21172         this_ptr_conv.is_owned = false;
21173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21174         BigSize_set_a(&this_ptr_conv, val);
21175 }
21176
21177 uint32_t  __attribute__((export_name("TS_BigSize_new"))) TS_BigSize_new(int64_t a_arg) {
21178         LDKBigSize ret_var = BigSize_new(a_arg);
21179         uint32_t ret_ref = 0;
21180         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21181         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21182         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21183         ret_ref = (uintptr_t)ret_var.inner;
21184         if (ret_var.is_owned) {
21185                 ret_ref |= 1;
21186         }
21187         return ret_ref;
21188 }
21189
21190 uint32_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
21191         LDKu8slice msg_ref;
21192         msg_ref.datalen = msg->arr_len;
21193         msg_ref.data = msg->elems;
21194         unsigned char sk_arr[32];
21195         CHECK(sk->arr_len == 32);
21196         memcpy(sk_arr, sk->elems, 32); FREE(sk);
21197         unsigned char (*sk_ref)[32] = &sk_arr;
21198         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21199         *ret_conv = sign(msg_ref, sk_ref);
21200         FREE(msg);
21201         return (uint32_t)ret_conv;
21202 }
21203
21204 uint32_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
21205         LDKu8slice msg_ref;
21206         msg_ref.datalen = msg->arr_len;
21207         msg_ref.data = msg->elems;
21208         LDKStr sig_conv = str_ref_to_owned_c(sig);
21209         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21210         *ret_conv = recover_pk(msg_ref, sig_conv);
21211         FREE(msg);
21212         return (uint32_t)ret_conv;
21213 }
21214
21215 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
21216         LDKu8slice msg_ref;
21217         msg_ref.datalen = msg->arr_len;
21218         msg_ref.data = msg->elems;
21219         LDKStr sig_conv = str_ref_to_owned_c(sig);
21220         LDKPublicKey pk_ref;
21221         CHECK(pk->arr_len == 33);
21222         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
21223         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
21224         FREE(msg);
21225         return ret_conv;
21226 }
21227
21228 int8_tArray  __attribute__((export_name("TS_construct_invoice_preimage"))) TS_construct_invoice_preimage(int8_tArray hrp_bytes, ptrArray data_without_signature) {
21229         LDKu8slice hrp_bytes_ref;
21230         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
21231         hrp_bytes_ref.data = hrp_bytes->elems;
21232         LDKCVec_u5Z data_without_signature_constr;
21233         data_without_signature_constr.datalen = data_without_signature->arr_len;
21234         if (data_without_signature_constr.datalen > 0)
21235                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
21236         else
21237                 data_without_signature_constr.data = NULL;
21238         int8_t* data_without_signature_vals = (void*) data_without_signature->elems;
21239         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
21240                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
21241                 
21242                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
21243         }
21244         FREE(data_without_signature);
21245         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
21246         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21247         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21248         CVec_u8Z_free(ret_var);
21249         FREE(hrp_bytes);
21250         return ret_arr;
21251 }
21252
21253 void  __attribute__((export_name("TS_Persister_free"))) TS_Persister_free(uint32_t this_ptr) {
21254         if ((this_ptr & 1) != 0) return;
21255         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21256         CHECK_ACCESS(this_ptr_ptr);
21257         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
21258         FREE((void*)this_ptr);
21259         Persister_free(this_ptr_conv);
21260 }
21261
21262 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint32_t orig) {
21263         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
21264         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
21265         return ret_conv;
21266 }
21267
21268 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
21269         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
21270         return ret_conv;
21271 }
21272
21273 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
21274         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
21275         return ret_conv;
21276 }
21277
21278 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
21279         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
21280         return ret_conv;
21281 }
21282
21283 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
21284         uint32_t ret_conv = LDKLevel_to_js(Level_info());
21285         return ret_conv;
21286 }
21287
21288 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
21289         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
21290         return ret_conv;
21291 }
21292
21293 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
21294         uint32_t ret_conv = LDKLevel_to_js(Level_error());
21295         return ret_conv;
21296 }
21297
21298 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint32_t a, uint32_t b) {
21299         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
21300         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
21301         jboolean ret_conv = Level_eq(a_conv, b_conv);
21302         return ret_conv;
21303 }
21304
21305 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint32_t o) {
21306         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
21307         int64_t ret_conv = Level_hash(o_conv);
21308         return ret_conv;
21309 }
21310
21311 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
21312         uint32_t ret_conv = LDKLevel_to_js(Level_max());
21313         return ret_conv;
21314 }
21315
21316 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint32_t this_obj) {
21317         LDKRecord this_obj_conv;
21318         this_obj_conv.inner = (void*)(this_obj & (~1));
21319         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21321         Record_free(this_obj_conv);
21322 }
21323
21324 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint32_t this_ptr) {
21325         LDKRecord this_ptr_conv;
21326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21327         this_ptr_conv.is_owned = false;
21328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21329         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
21330         return ret_conv;
21331 }
21332
21333 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
21334         LDKRecord this_ptr_conv;
21335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21336         this_ptr_conv.is_owned = false;
21337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21338         LDKLevel val_conv = LDKLevel_from_js(val);
21339         Record_set_level(&this_ptr_conv, val_conv);
21340 }
21341
21342 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint32_t this_ptr) {
21343         LDKRecord this_ptr_conv;
21344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21345         this_ptr_conv.is_owned = false;
21346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21347         LDKStr ret_str = Record_get_args(&this_ptr_conv);
21348         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21349         Str_free(ret_str);
21350         return ret_conv;
21351 }
21352
21353 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
21354         LDKRecord this_ptr_conv;
21355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21356         this_ptr_conv.is_owned = false;
21357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21358         LDKStr val_conv = str_ref_to_owned_c(val);
21359         Record_set_args(&this_ptr_conv, val_conv);
21360 }
21361
21362 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint32_t this_ptr) {
21363         LDKRecord this_ptr_conv;
21364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21365         this_ptr_conv.is_owned = false;
21366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21367         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
21368         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21369         Str_free(ret_str);
21370         return ret_conv;
21371 }
21372
21373 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
21374         LDKRecord this_ptr_conv;
21375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21376         this_ptr_conv.is_owned = false;
21377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21378         LDKStr val_conv = str_ref_to_owned_c(val);
21379         Record_set_module_path(&this_ptr_conv, val_conv);
21380 }
21381
21382 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint32_t this_ptr) {
21383         LDKRecord this_ptr_conv;
21384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21385         this_ptr_conv.is_owned = false;
21386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21387         LDKStr ret_str = Record_get_file(&this_ptr_conv);
21388         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21389         Str_free(ret_str);
21390         return ret_conv;
21391 }
21392
21393 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
21394         LDKRecord this_ptr_conv;
21395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21396         this_ptr_conv.is_owned = false;
21397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21398         LDKStr val_conv = str_ref_to_owned_c(val);
21399         Record_set_file(&this_ptr_conv, val_conv);
21400 }
21401
21402 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint32_t this_ptr) {
21403         LDKRecord this_ptr_conv;
21404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21405         this_ptr_conv.is_owned = false;
21406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21407         int32_t ret_conv = Record_get_line(&this_ptr_conv);
21408         return ret_conv;
21409 }
21410
21411 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
21412         LDKRecord this_ptr_conv;
21413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21414         this_ptr_conv.is_owned = false;
21415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21416         Record_set_line(&this_ptr_conv, val);
21417 }
21418
21419 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
21420         LDKRecord ret_var = Record_clone(arg);
21421 uint32_t ret_ref = 0;
21422 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21423 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21424 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21425 ret_ref = (uintptr_t)ret_var.inner;
21426 if (ret_var.is_owned) {
21427         ret_ref |= 1;
21428 }
21429         return ret_ref;
21430 }
21431 uint32_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint32_t arg) {
21432         LDKRecord arg_conv;
21433         arg_conv.inner = (void*)(arg & (~1));
21434         arg_conv.is_owned = false;
21435         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21436         uint32_t ret_conv = Record_clone_ptr(&arg_conv);
21437         return ret_conv;
21438 }
21439
21440 uint32_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint32_t orig) {
21441         LDKRecord orig_conv;
21442         orig_conv.inner = (void*)(orig & (~1));
21443         orig_conv.is_owned = false;
21444         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21445         LDKRecord ret_var = Record_clone(&orig_conv);
21446         uint32_t ret_ref = 0;
21447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21450         ret_ref = (uintptr_t)ret_var.inner;
21451         if (ret_var.is_owned) {
21452                 ret_ref |= 1;
21453         }
21454         return ret_ref;
21455 }
21456
21457 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint32_t this_ptr) {
21458         if ((this_ptr & 1) != 0) return;
21459         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21460         CHECK_ACCESS(this_ptr_ptr);
21461         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
21462         FREE((void*)this_ptr);
21463         Logger_free(this_ptr_conv);
21464 }
21465
21466 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
21467         LDKChannelHandshakeConfig this_obj_conv;
21468         this_obj_conv.inner = (void*)(this_obj & (~1));
21469         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21471         ChannelHandshakeConfig_free(this_obj_conv);
21472 }
21473
21474 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
21475         LDKChannelHandshakeConfig this_ptr_conv;
21476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21477         this_ptr_conv.is_owned = false;
21478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21479         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
21480         return ret_conv;
21481 }
21482
21483 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
21484         LDKChannelHandshakeConfig this_ptr_conv;
21485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21486         this_ptr_conv.is_owned = false;
21487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21488         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
21489 }
21490
21491 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
21492         LDKChannelHandshakeConfig this_ptr_conv;
21493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21494         this_ptr_conv.is_owned = false;
21495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21496         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
21497         return ret_conv;
21498 }
21499
21500 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) {
21501         LDKChannelHandshakeConfig this_ptr_conv;
21502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21503         this_ptr_conv.is_owned = false;
21504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21505         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
21506 }
21507
21508 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
21509         LDKChannelHandshakeConfig this_ptr_conv;
21510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21511         this_ptr_conv.is_owned = false;
21512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21513         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
21514         return ret_conv;
21515 }
21516
21517 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) {
21518         LDKChannelHandshakeConfig this_ptr_conv;
21519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21520         this_ptr_conv.is_owned = false;
21521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21522         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
21523 }
21524
21525 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) {
21526         LDKChannelHandshakeConfig this_ptr_conv;
21527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21528         this_ptr_conv.is_owned = false;
21529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21530         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
21531         return ret_conv;
21532 }
21533
21534 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) {
21535         LDKChannelHandshakeConfig this_ptr_conv;
21536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21537         this_ptr_conv.is_owned = false;
21538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21539         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
21540 }
21541
21542 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_get_negotiate_scid_privacy(uint32_t this_ptr) {
21543         LDKChannelHandshakeConfig this_ptr_conv;
21544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21545         this_ptr_conv.is_owned = false;
21546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21547         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
21548         return ret_conv;
21549 }
21550
21551 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_set_negotiate_scid_privacy(uint32_t this_ptr, jboolean val) {
21552         LDKChannelHandshakeConfig this_ptr_conv;
21553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21554         this_ptr_conv.is_owned = false;
21555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21556         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
21557 }
21558
21559 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_announced_channel"))) TS_ChannelHandshakeConfig_get_announced_channel(uint32_t this_ptr) {
21560         LDKChannelHandshakeConfig this_ptr_conv;
21561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21562         this_ptr_conv.is_owned = false;
21563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21564         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
21565         return ret_conv;
21566 }
21567
21568 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_announced_channel"))) TS_ChannelHandshakeConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
21569         LDKChannelHandshakeConfig this_ptr_conv;
21570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21571         this_ptr_conv.is_owned = false;
21572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21573         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
21574 }
21575
21576 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
21577         LDKChannelHandshakeConfig this_ptr_conv;
21578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21579         this_ptr_conv.is_owned = false;
21580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21581         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
21582         return ret_conv;
21583 }
21584
21585 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
21586         LDKChannelHandshakeConfig this_ptr_conv;
21587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21588         this_ptr_conv.is_owned = false;
21589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21590         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
21591 }
21592
21593 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) {
21594         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);
21595         uint32_t ret_ref = 0;
21596         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21597         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21599         ret_ref = (uintptr_t)ret_var.inner;
21600         if (ret_var.is_owned) {
21601                 ret_ref |= 1;
21602         }
21603         return ret_ref;
21604 }
21605
21606 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
21607         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
21608 uint32_t ret_ref = 0;
21609 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21610 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21611 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21612 ret_ref = (uintptr_t)ret_var.inner;
21613 if (ret_var.is_owned) {
21614         ret_ref |= 1;
21615 }
21616         return ret_ref;
21617 }
21618 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
21619         LDKChannelHandshakeConfig arg_conv;
21620         arg_conv.inner = (void*)(arg & (~1));
21621         arg_conv.is_owned = false;
21622         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21623         uint32_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
21624         return ret_conv;
21625 }
21626
21627 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
21628         LDKChannelHandshakeConfig orig_conv;
21629         orig_conv.inner = (void*)(orig & (~1));
21630         orig_conv.is_owned = false;
21631         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21632         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
21633         uint32_t ret_ref = 0;
21634         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21635         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21637         ret_ref = (uintptr_t)ret_var.inner;
21638         if (ret_var.is_owned) {
21639                 ret_ref |= 1;
21640         }
21641         return ret_ref;
21642 }
21643
21644 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
21645         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
21646         uint32_t ret_ref = 0;
21647         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21648         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21650         ret_ref = (uintptr_t)ret_var.inner;
21651         if (ret_var.is_owned) {
21652                 ret_ref |= 1;
21653         }
21654         return ret_ref;
21655 }
21656
21657 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
21658         LDKChannelHandshakeLimits this_obj_conv;
21659         this_obj_conv.inner = (void*)(this_obj & (~1));
21660         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21662         ChannelHandshakeLimits_free(this_obj_conv);
21663 }
21664
21665 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
21666         LDKChannelHandshakeLimits this_ptr_conv;
21667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21668         this_ptr_conv.is_owned = false;
21669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21670         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
21671         return ret_conv;
21672 }
21673
21674 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
21675         LDKChannelHandshakeLimits this_ptr_conv;
21676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21677         this_ptr_conv.is_owned = false;
21678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21679         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
21680 }
21681
21682 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_funding_satoshis"))) TS_ChannelHandshakeLimits_get_max_funding_satoshis(uint32_t this_ptr) {
21683         LDKChannelHandshakeLimits this_ptr_conv;
21684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21685         this_ptr_conv.is_owned = false;
21686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21687         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
21688         return ret_conv;
21689 }
21690
21691 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_funding_satoshis"))) TS_ChannelHandshakeLimits_set_max_funding_satoshis(uint32_t this_ptr, int64_t val) {
21692         LDKChannelHandshakeLimits this_ptr_conv;
21693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21694         this_ptr_conv.is_owned = false;
21695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21696         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
21697 }
21698
21699 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
21700         LDKChannelHandshakeLimits this_ptr_conv;
21701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21702         this_ptr_conv.is_owned = false;
21703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21704         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
21705         return ret_conv;
21706 }
21707
21708 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) {
21709         LDKChannelHandshakeLimits this_ptr_conv;
21710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21711         this_ptr_conv.is_owned = false;
21712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21713         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
21714 }
21715
21716 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) {
21717         LDKChannelHandshakeLimits this_ptr_conv;
21718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21719         this_ptr_conv.is_owned = false;
21720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21721         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
21722         return ret_conv;
21723 }
21724
21725 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) {
21726         LDKChannelHandshakeLimits this_ptr_conv;
21727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21728         this_ptr_conv.is_owned = false;
21729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21730         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
21731 }
21732
21733 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
21734         LDKChannelHandshakeLimits this_ptr_conv;
21735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21736         this_ptr_conv.is_owned = false;
21737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21738         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
21739         return ret_conv;
21740 }
21741
21742 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) {
21743         LDKChannelHandshakeLimits this_ptr_conv;
21744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21745         this_ptr_conv.is_owned = false;
21746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21747         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
21748 }
21749
21750 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
21751         LDKChannelHandshakeLimits this_ptr_conv;
21752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21753         this_ptr_conv.is_owned = false;
21754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21755         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
21756         return ret_conv;
21757 }
21758
21759 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) {
21760         LDKChannelHandshakeLimits this_ptr_conv;
21761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21762         this_ptr_conv.is_owned = false;
21763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21764         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
21765 }
21766
21767 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
21768         LDKChannelHandshakeLimits this_ptr_conv;
21769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21770         this_ptr_conv.is_owned = false;
21771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21772         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
21773         return ret_conv;
21774 }
21775
21776 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
21777         LDKChannelHandshakeLimits this_ptr_conv;
21778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21779         this_ptr_conv.is_owned = false;
21780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21781         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
21782 }
21783
21784 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_trust_own_funding_0conf"))) TS_ChannelHandshakeLimits_get_trust_own_funding_0conf(uint32_t this_ptr) {
21785         LDKChannelHandshakeLimits this_ptr_conv;
21786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21787         this_ptr_conv.is_owned = false;
21788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21789         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
21790         return ret_conv;
21791 }
21792
21793 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_trust_own_funding_0conf"))) TS_ChannelHandshakeLimits_set_trust_own_funding_0conf(uint32_t this_ptr, jboolean val) {
21794         LDKChannelHandshakeLimits this_ptr_conv;
21795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21796         this_ptr_conv.is_owned = false;
21797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21798         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
21799 }
21800
21801 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
21802         LDKChannelHandshakeLimits this_ptr_conv;
21803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21804         this_ptr_conv.is_owned = false;
21805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21806         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
21807         return ret_conv;
21808 }
21809
21810 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
21811         LDKChannelHandshakeLimits this_ptr_conv;
21812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21813         this_ptr_conv.is_owned = false;
21814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21815         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
21816 }
21817
21818 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
21819         LDKChannelHandshakeLimits this_ptr_conv;
21820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21821         this_ptr_conv.is_owned = false;
21822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21823         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
21824         return ret_conv;
21825 }
21826
21827 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) {
21828         LDKChannelHandshakeLimits this_ptr_conv;
21829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21830         this_ptr_conv.is_owned = false;
21831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21832         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
21833 }
21834
21835 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) {
21836         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);
21837         uint32_t ret_ref = 0;
21838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21841         ret_ref = (uintptr_t)ret_var.inner;
21842         if (ret_var.is_owned) {
21843                 ret_ref |= 1;
21844         }
21845         return ret_ref;
21846 }
21847
21848 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
21849         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
21850 uint32_t ret_ref = 0;
21851 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21852 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21853 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21854 ret_ref = (uintptr_t)ret_var.inner;
21855 if (ret_var.is_owned) {
21856         ret_ref |= 1;
21857 }
21858         return ret_ref;
21859 }
21860 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
21861         LDKChannelHandshakeLimits arg_conv;
21862         arg_conv.inner = (void*)(arg & (~1));
21863         arg_conv.is_owned = false;
21864         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21865         uint32_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
21866         return ret_conv;
21867 }
21868
21869 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
21870         LDKChannelHandshakeLimits orig_conv;
21871         orig_conv.inner = (void*)(orig & (~1));
21872         orig_conv.is_owned = false;
21873         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21874         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
21875         uint32_t ret_ref = 0;
21876         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21877         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21879         ret_ref = (uintptr_t)ret_var.inner;
21880         if (ret_var.is_owned) {
21881                 ret_ref |= 1;
21882         }
21883         return ret_ref;
21884 }
21885
21886 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
21887         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
21888         uint32_t ret_ref = 0;
21889         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21890         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21892         ret_ref = (uintptr_t)ret_var.inner;
21893         if (ret_var.is_owned) {
21894                 ret_ref |= 1;
21895         }
21896         return ret_ref;
21897 }
21898
21899 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint32_t this_obj) {
21900         LDKChannelConfig this_obj_conv;
21901         this_obj_conv.inner = (void*)(this_obj & (~1));
21902         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21904         ChannelConfig_free(this_obj_conv);
21905 }
21906
21907 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
21908         LDKChannelConfig this_ptr_conv;
21909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21910         this_ptr_conv.is_owned = false;
21911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21912         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
21913         return ret_conv;
21914 }
21915
21916 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) {
21917         LDKChannelConfig this_ptr_conv;
21918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21919         this_ptr_conv.is_owned = false;
21920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21921         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
21922 }
21923
21924 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
21925         LDKChannelConfig this_ptr_conv;
21926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21927         this_ptr_conv.is_owned = false;
21928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21929         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
21930         return ret_conv;
21931 }
21932
21933 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) {
21934         LDKChannelConfig this_ptr_conv;
21935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21936         this_ptr_conv.is_owned = false;
21937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21938         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
21939 }
21940
21941 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
21942         LDKChannelConfig this_ptr_conv;
21943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21944         this_ptr_conv.is_owned = false;
21945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21946         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
21947         return ret_conv;
21948 }
21949
21950 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
21951         LDKChannelConfig this_ptr_conv;
21952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21953         this_ptr_conv.is_owned = false;
21954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21955         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
21956 }
21957
21958 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) {
21959         LDKChannelConfig this_ptr_conv;
21960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21961         this_ptr_conv.is_owned = false;
21962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21963         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
21964         return ret_conv;
21965 }
21966
21967 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) {
21968         LDKChannelConfig this_ptr_conv;
21969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21970         this_ptr_conv.is_owned = false;
21971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21972         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
21973 }
21974
21975 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) {
21976         LDKChannelConfig this_ptr_conv;
21977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21978         this_ptr_conv.is_owned = false;
21979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21980         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
21981         return ret_conv;
21982 }
21983
21984 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) {
21985         LDKChannelConfig this_ptr_conv;
21986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21987         this_ptr_conv.is_owned = false;
21988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21989         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
21990 }
21991
21992 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) {
21993         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);
21994         uint32_t ret_ref = 0;
21995         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21996         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21998         ret_ref = (uintptr_t)ret_var.inner;
21999         if (ret_var.is_owned) {
22000                 ret_ref |= 1;
22001         }
22002         return ret_ref;
22003 }
22004
22005 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
22006         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
22007 uint32_t ret_ref = 0;
22008 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22009 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22010 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22011 ret_ref = (uintptr_t)ret_var.inner;
22012 if (ret_var.is_owned) {
22013         ret_ref |= 1;
22014 }
22015         return ret_ref;
22016 }
22017 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
22018         LDKChannelConfig arg_conv;
22019         arg_conv.inner = (void*)(arg & (~1));
22020         arg_conv.is_owned = false;
22021         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22022         uint32_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
22023         return ret_conv;
22024 }
22025
22026 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint32_t orig) {
22027         LDKChannelConfig orig_conv;
22028         orig_conv.inner = (void*)(orig & (~1));
22029         orig_conv.is_owned = false;
22030         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22031         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
22032         uint32_t ret_ref = 0;
22033         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22034         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22036         ret_ref = (uintptr_t)ret_var.inner;
22037         if (ret_var.is_owned) {
22038                 ret_ref |= 1;
22039         }
22040         return ret_ref;
22041 }
22042
22043 uint32_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
22044         LDKChannelConfig ret_var = ChannelConfig_default();
22045         uint32_t ret_ref = 0;
22046         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22047         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22049         ret_ref = (uintptr_t)ret_var.inner;
22050         if (ret_var.is_owned) {
22051                 ret_ref |= 1;
22052         }
22053         return ret_ref;
22054 }
22055
22056 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint32_t obj) {
22057         LDKChannelConfig obj_conv;
22058         obj_conv.inner = (void*)(obj & (~1));
22059         obj_conv.is_owned = false;
22060         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22061         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
22062         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22063         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22064         CVec_u8Z_free(ret_var);
22065         return ret_arr;
22066 }
22067
22068 uint32_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
22069         LDKu8slice ser_ref;
22070         ser_ref.datalen = ser->arr_len;
22071         ser_ref.data = ser->elems;
22072         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22073         *ret_conv = ChannelConfig_read(ser_ref);
22074         FREE(ser);
22075         return (uint32_t)ret_conv;
22076 }
22077
22078 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint32_t this_obj) {
22079         LDKUserConfig this_obj_conv;
22080         this_obj_conv.inner = (void*)(this_obj & (~1));
22081         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22083         UserConfig_free(this_obj_conv);
22084 }
22085
22086 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_handshake_config"))) TS_UserConfig_get_channel_handshake_config(uint32_t this_ptr) {
22087         LDKUserConfig this_ptr_conv;
22088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22089         this_ptr_conv.is_owned = false;
22090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22091         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
22092         uint32_t ret_ref = 0;
22093         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22094         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22096         ret_ref = (uintptr_t)ret_var.inner;
22097         if (ret_var.is_owned) {
22098                 ret_ref |= 1;
22099         }
22100         return ret_ref;
22101 }
22102
22103 void  __attribute__((export_name("TS_UserConfig_set_channel_handshake_config"))) TS_UserConfig_set_channel_handshake_config(uint32_t this_ptr, uint32_t val) {
22104         LDKUserConfig this_ptr_conv;
22105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22106         this_ptr_conv.is_owned = false;
22107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22108         LDKChannelHandshakeConfig val_conv;
22109         val_conv.inner = (void*)(val & (~1));
22110         val_conv.is_owned = (val & 1) || (val == 0);
22111         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22112         val_conv = ChannelHandshakeConfig_clone(&val_conv);
22113         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
22114 }
22115
22116 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_handshake_limits"))) TS_UserConfig_get_channel_handshake_limits(uint32_t this_ptr) {
22117         LDKUserConfig this_ptr_conv;
22118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22119         this_ptr_conv.is_owned = false;
22120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22121         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
22122         uint32_t ret_ref = 0;
22123         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22124         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22126         ret_ref = (uintptr_t)ret_var.inner;
22127         if (ret_var.is_owned) {
22128                 ret_ref |= 1;
22129         }
22130         return ret_ref;
22131 }
22132
22133 void  __attribute__((export_name("TS_UserConfig_set_channel_handshake_limits"))) TS_UserConfig_set_channel_handshake_limits(uint32_t this_ptr, uint32_t val) {
22134         LDKUserConfig this_ptr_conv;
22135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22136         this_ptr_conv.is_owned = false;
22137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22138         LDKChannelHandshakeLimits val_conv;
22139         val_conv.inner = (void*)(val & (~1));
22140         val_conv.is_owned = (val & 1) || (val == 0);
22141         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22142         val_conv = ChannelHandshakeLimits_clone(&val_conv);
22143         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
22144 }
22145
22146 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_config"))) TS_UserConfig_get_channel_config(uint32_t this_ptr) {
22147         LDKUserConfig this_ptr_conv;
22148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22149         this_ptr_conv.is_owned = false;
22150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22151         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
22152         uint32_t ret_ref = 0;
22153         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22154         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22155         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22156         ret_ref = (uintptr_t)ret_var.inner;
22157         if (ret_var.is_owned) {
22158                 ret_ref |= 1;
22159         }
22160         return ret_ref;
22161 }
22162
22163 void  __attribute__((export_name("TS_UserConfig_set_channel_config"))) TS_UserConfig_set_channel_config(uint32_t this_ptr, uint32_t val) {
22164         LDKUserConfig this_ptr_conv;
22165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22166         this_ptr_conv.is_owned = false;
22167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22168         LDKChannelConfig val_conv;
22169         val_conv.inner = (void*)(val & (~1));
22170         val_conv.is_owned = (val & 1) || (val == 0);
22171         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22172         val_conv = ChannelConfig_clone(&val_conv);
22173         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
22174 }
22175
22176 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
22177         LDKUserConfig this_ptr_conv;
22178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22179         this_ptr_conv.is_owned = false;
22180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22181         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
22182         return ret_conv;
22183 }
22184
22185 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) {
22186         LDKUserConfig this_ptr_conv;
22187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22188         this_ptr_conv.is_owned = false;
22189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22190         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
22191 }
22192
22193 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
22194         LDKUserConfig this_ptr_conv;
22195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22196         this_ptr_conv.is_owned = false;
22197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22198         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
22199         return ret_conv;
22200 }
22201
22202 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
22203         LDKUserConfig this_ptr_conv;
22204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22205         this_ptr_conv.is_owned = false;
22206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22207         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
22208 }
22209
22210 jboolean  __attribute__((export_name("TS_UserConfig_get_manually_accept_inbound_channels"))) TS_UserConfig_get_manually_accept_inbound_channels(uint32_t this_ptr) {
22211         LDKUserConfig this_ptr_conv;
22212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22213         this_ptr_conv.is_owned = false;
22214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22215         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
22216         return ret_conv;
22217 }
22218
22219 void  __attribute__((export_name("TS_UserConfig_set_manually_accept_inbound_channels"))) TS_UserConfig_set_manually_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
22220         LDKUserConfig this_ptr_conv;
22221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22222         this_ptr_conv.is_owned = false;
22223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22224         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
22225 }
22226
22227 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) {
22228         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
22229         channel_handshake_config_arg_conv.inner = (void*)(channel_handshake_config_arg & (~1));
22230         channel_handshake_config_arg_conv.is_owned = (channel_handshake_config_arg & 1) || (channel_handshake_config_arg == 0);
22231         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
22232         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
22233         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
22234         channel_handshake_limits_arg_conv.inner = (void*)(channel_handshake_limits_arg & (~1));
22235         channel_handshake_limits_arg_conv.is_owned = (channel_handshake_limits_arg & 1) || (channel_handshake_limits_arg == 0);
22236         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
22237         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
22238         LDKChannelConfig channel_config_arg_conv;
22239         channel_config_arg_conv.inner = (void*)(channel_config_arg & (~1));
22240         channel_config_arg_conv.is_owned = (channel_config_arg & 1) || (channel_config_arg == 0);
22241         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
22242         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
22243         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);
22244         uint32_t ret_ref = 0;
22245         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22246         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22248         ret_ref = (uintptr_t)ret_var.inner;
22249         if (ret_var.is_owned) {
22250                 ret_ref |= 1;
22251         }
22252         return ret_ref;
22253 }
22254
22255 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
22256         LDKUserConfig ret_var = UserConfig_clone(arg);
22257 uint32_t ret_ref = 0;
22258 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22259 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22260 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22261 ret_ref = (uintptr_t)ret_var.inner;
22262 if (ret_var.is_owned) {
22263         ret_ref |= 1;
22264 }
22265         return ret_ref;
22266 }
22267 uint32_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint32_t arg) {
22268         LDKUserConfig arg_conv;
22269         arg_conv.inner = (void*)(arg & (~1));
22270         arg_conv.is_owned = false;
22271         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22272         uint32_t ret_conv = UserConfig_clone_ptr(&arg_conv);
22273         return ret_conv;
22274 }
22275
22276 uint32_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint32_t orig) {
22277         LDKUserConfig orig_conv;
22278         orig_conv.inner = (void*)(orig & (~1));
22279         orig_conv.is_owned = false;
22280         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22281         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
22282         uint32_t ret_ref = 0;
22283         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22284         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22286         ret_ref = (uintptr_t)ret_var.inner;
22287         if (ret_var.is_owned) {
22288                 ret_ref |= 1;
22289         }
22290         return ret_ref;
22291 }
22292
22293 uint32_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
22294         LDKUserConfig ret_var = UserConfig_default();
22295         uint32_t ret_ref = 0;
22296         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22297         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22299         ret_ref = (uintptr_t)ret_var.inner;
22300         if (ret_var.is_owned) {
22301                 ret_ref |= 1;
22302         }
22303         return ret_ref;
22304 }
22305
22306 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint32_t this_obj) {
22307         LDKBestBlock this_obj_conv;
22308         this_obj_conv.inner = (void*)(this_obj & (~1));
22309         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22311         BestBlock_free(this_obj_conv);
22312 }
22313
22314 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
22315         LDKBestBlock ret_var = BestBlock_clone(arg);
22316 uint32_t ret_ref = 0;
22317 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22318 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22319 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22320 ret_ref = (uintptr_t)ret_var.inner;
22321 if (ret_var.is_owned) {
22322         ret_ref |= 1;
22323 }
22324         return ret_ref;
22325 }
22326 uint32_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint32_t arg) {
22327         LDKBestBlock arg_conv;
22328         arg_conv.inner = (void*)(arg & (~1));
22329         arg_conv.is_owned = false;
22330         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22331         uint32_t ret_conv = BestBlock_clone_ptr(&arg_conv);
22332         return ret_conv;
22333 }
22334
22335 uint32_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint32_t orig) {
22336         LDKBestBlock orig_conv;
22337         orig_conv.inner = (void*)(orig & (~1));
22338         orig_conv.is_owned = false;
22339         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22340         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
22341         uint32_t ret_ref = 0;
22342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22345         ret_ref = (uintptr_t)ret_var.inner;
22346         if (ret_var.is_owned) {
22347                 ret_ref |= 1;
22348         }
22349         return ret_ref;
22350 }
22351
22352 uint32_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
22353         LDKNetwork network_conv = LDKNetwork_from_js(network);
22354         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
22355         uint32_t ret_ref = 0;
22356         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22357         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22359         ret_ref = (uintptr_t)ret_var.inner;
22360         if (ret_var.is_owned) {
22361                 ret_ref |= 1;
22362         }
22363         return ret_ref;
22364 }
22365
22366 uint32_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
22367         LDKThirtyTwoBytes block_hash_ref;
22368         CHECK(block_hash->arr_len == 32);
22369         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
22370         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
22371         uint32_t ret_ref = 0;
22372         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22373         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22375         ret_ref = (uintptr_t)ret_var.inner;
22376         if (ret_var.is_owned) {
22377                 ret_ref |= 1;
22378         }
22379         return ret_ref;
22380 }
22381
22382 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint32_t this_arg) {
22383         LDKBestBlock this_arg_conv;
22384         this_arg_conv.inner = (void*)(this_arg & (~1));
22385         this_arg_conv.is_owned = false;
22386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22387         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22388         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
22389         return ret_arr;
22390 }
22391
22392 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint32_t this_arg) {
22393         LDKBestBlock this_arg_conv;
22394         this_arg_conv.inner = (void*)(this_arg & (~1));
22395         this_arg_conv.is_owned = false;
22396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22397         int32_t ret_conv = BestBlock_height(&this_arg_conv);
22398         return ret_conv;
22399 }
22400
22401 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint32_t orig) {
22402         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
22403         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
22404         return ret_conv;
22405 }
22406
22407 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
22408         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
22409         return ret_conv;
22410 }
22411
22412 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
22413         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
22414         return ret_conv;
22415 }
22416
22417 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint32_t this_ptr) {
22418         if ((this_ptr & 1) != 0) return;
22419         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22420         CHECK_ACCESS(this_ptr_ptr);
22421         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
22422         FREE((void*)this_ptr);
22423         Access_free(this_ptr_conv);
22424 }
22425
22426 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint32_t this_ptr) {
22427         if ((this_ptr & 1) != 0) return;
22428         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22429         CHECK_ACCESS(this_ptr_ptr);
22430         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
22431         FREE((void*)this_ptr);
22432         Listen_free(this_ptr_conv);
22433 }
22434
22435 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint32_t this_ptr) {
22436         if ((this_ptr & 1) != 0) return;
22437         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22438         CHECK_ACCESS(this_ptr_ptr);
22439         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
22440         FREE((void*)this_ptr);
22441         Confirm_free(this_ptr_conv);
22442 }
22443
22444 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
22445         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
22446         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
22447         return ret_conv;
22448 }
22449
22450 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
22451         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
22452         return ret_conv;
22453 }
22454
22455 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
22456         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
22457         return ret_conv;
22458 }
22459
22460 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint32_t this_ptr) {
22461         if ((this_ptr & 1) != 0) return;
22462         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22463         CHECK_ACCESS(this_ptr_ptr);
22464         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
22465         FREE((void*)this_ptr);
22466         Watch_free(this_ptr_conv);
22467 }
22468
22469 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint32_t this_ptr) {
22470         if ((this_ptr & 1) != 0) return;
22471         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22472         CHECK_ACCESS(this_ptr_ptr);
22473         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
22474         FREE((void*)this_ptr);
22475         Filter_free(this_ptr_conv);
22476 }
22477
22478 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint32_t this_obj) {
22479         LDKWatchedOutput this_obj_conv;
22480         this_obj_conv.inner = (void*)(this_obj & (~1));
22481         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22483         WatchedOutput_free(this_obj_conv);
22484 }
22485
22486 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
22487         LDKWatchedOutput this_ptr_conv;
22488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22489         this_ptr_conv.is_owned = false;
22490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22491         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22492         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
22493         return ret_arr;
22494 }
22495
22496 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
22497         LDKWatchedOutput this_ptr_conv;
22498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22499         this_ptr_conv.is_owned = false;
22500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22501         LDKThirtyTwoBytes val_ref;
22502         CHECK(val->arr_len == 32);
22503         memcpy(val_ref.data, val->elems, 32); FREE(val);
22504         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
22505 }
22506
22507 uint32_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
22508         LDKWatchedOutput this_ptr_conv;
22509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22510         this_ptr_conv.is_owned = false;
22511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22512         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
22513         uint32_t ret_ref = 0;
22514         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22515         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22517         ret_ref = (uintptr_t)ret_var.inner;
22518         if (ret_var.is_owned) {
22519                 ret_ref |= 1;
22520         }
22521         return ret_ref;
22522 }
22523
22524 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
22525         LDKWatchedOutput this_ptr_conv;
22526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22527         this_ptr_conv.is_owned = false;
22528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22529         LDKOutPoint val_conv;
22530         val_conv.inner = (void*)(val & (~1));
22531         val_conv.is_owned = (val & 1) || (val == 0);
22532         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22533         val_conv = OutPoint_clone(&val_conv);
22534         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
22535 }
22536
22537 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
22538         LDKWatchedOutput this_ptr_conv;
22539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22540         this_ptr_conv.is_owned = false;
22541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22542         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
22543         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22544         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22545         return ret_arr;
22546 }
22547
22548 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
22549         LDKWatchedOutput this_ptr_conv;
22550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22551         this_ptr_conv.is_owned = false;
22552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22553         LDKCVec_u8Z val_ref;
22554         val_ref.datalen = val->arr_len;
22555         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
22556         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
22557         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
22558 }
22559
22560 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) {
22561         LDKThirtyTwoBytes block_hash_arg_ref;
22562         CHECK(block_hash_arg->arr_len == 32);
22563         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32); FREE(block_hash_arg);
22564         LDKOutPoint outpoint_arg_conv;
22565         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
22566         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
22567         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
22568         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
22569         LDKCVec_u8Z script_pubkey_arg_ref;
22570         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
22571         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
22572         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
22573         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
22574         uint32_t ret_ref = 0;
22575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22578         ret_ref = (uintptr_t)ret_var.inner;
22579         if (ret_var.is_owned) {
22580                 ret_ref |= 1;
22581         }
22582         return ret_ref;
22583 }
22584
22585 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
22586         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
22587 uint32_t ret_ref = 0;
22588 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22589 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22590 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22591 ret_ref = (uintptr_t)ret_var.inner;
22592 if (ret_var.is_owned) {
22593         ret_ref |= 1;
22594 }
22595         return ret_ref;
22596 }
22597 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
22598         LDKWatchedOutput arg_conv;
22599         arg_conv.inner = (void*)(arg & (~1));
22600         arg_conv.is_owned = false;
22601         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22602         uint32_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
22603         return ret_conv;
22604 }
22605
22606 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint32_t orig) {
22607         LDKWatchedOutput orig_conv;
22608         orig_conv.inner = (void*)(orig & (~1));
22609         orig_conv.is_owned = false;
22610         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22611         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
22612         uint32_t ret_ref = 0;
22613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22616         ret_ref = (uintptr_t)ret_var.inner;
22617         if (ret_var.is_owned) {
22618                 ret_ref |= 1;
22619         }
22620         return ret_ref;
22621 }
22622
22623 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint32_t o) {
22624         LDKWatchedOutput o_conv;
22625         o_conv.inner = (void*)(o & (~1));
22626         o_conv.is_owned = false;
22627         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22628         int64_t ret_conv = WatchedOutput_hash(&o_conv);
22629         return ret_conv;
22630 }
22631
22632 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
22633         if ((this_ptr & 1) != 0) return;
22634         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22635         CHECK_ACCESS(this_ptr_ptr);
22636         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
22637         FREE((void*)this_ptr);
22638         BroadcasterInterface_free(this_ptr_conv);
22639 }
22640
22641 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint32_t orig) {
22642         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
22643         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
22644         return ret_conv;
22645 }
22646
22647 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
22648         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
22649         return ret_conv;
22650 }
22651
22652 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
22653         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
22654         return ret_conv;
22655 }
22656
22657 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
22658         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
22659         return ret_conv;
22660 }
22661
22662 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
22663         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
22664         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
22665         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
22666         return ret_conv;
22667 }
22668
22669 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint32_t this_ptr) {
22670         if ((this_ptr & 1) != 0) return;
22671         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22672         CHECK_ACCESS(this_ptr_ptr);
22673         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
22674         FREE((void*)this_ptr);
22675         FeeEstimator_free(this_ptr_conv);
22676 }
22677
22678 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
22679         LDKMonitorUpdateId this_obj_conv;
22680         this_obj_conv.inner = (void*)(this_obj & (~1));
22681         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22683         MonitorUpdateId_free(this_obj_conv);
22684 }
22685
22686 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
22687         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
22688 uint32_t ret_ref = 0;
22689 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22690 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22691 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22692 ret_ref = (uintptr_t)ret_var.inner;
22693 if (ret_var.is_owned) {
22694         ret_ref |= 1;
22695 }
22696         return ret_ref;
22697 }
22698 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
22699         LDKMonitorUpdateId arg_conv;
22700         arg_conv.inner = (void*)(arg & (~1));
22701         arg_conv.is_owned = false;
22702         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22703         uint32_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
22704         return ret_conv;
22705 }
22706
22707 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint32_t orig) {
22708         LDKMonitorUpdateId orig_conv;
22709         orig_conv.inner = (void*)(orig & (~1));
22710         orig_conv.is_owned = false;
22711         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22712         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
22713         uint32_t ret_ref = 0;
22714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22717         ret_ref = (uintptr_t)ret_var.inner;
22718         if (ret_var.is_owned) {
22719                 ret_ref |= 1;
22720         }
22721         return ret_ref;
22722 }
22723
22724 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint32_t o) {
22725         LDKMonitorUpdateId o_conv;
22726         o_conv.inner = (void*)(o & (~1));
22727         o_conv.is_owned = false;
22728         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22729         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
22730         return ret_conv;
22731 }
22732
22733 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
22734         LDKMonitorUpdateId a_conv;
22735         a_conv.inner = (void*)(a & (~1));
22736         a_conv.is_owned = false;
22737         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22738         LDKMonitorUpdateId b_conv;
22739         b_conv.inner = (void*)(b & (~1));
22740         b_conv.is_owned = false;
22741         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22742         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
22743         return ret_conv;
22744 }
22745
22746 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint32_t this_ptr) {
22747         if ((this_ptr & 1) != 0) return;
22748         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22749         CHECK_ACCESS(this_ptr_ptr);
22750         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
22751         FREE((void*)this_ptr);
22752         Persist_free(this_ptr_conv);
22753 }
22754
22755 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
22756         LDKLockedChannelMonitor this_obj_conv;
22757         this_obj_conv.inner = (void*)(this_obj & (~1));
22758         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22760         LockedChannelMonitor_free(this_obj_conv);
22761 }
22762
22763 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint32_t this_obj) {
22764         LDKChainMonitor this_obj_conv;
22765         this_obj_conv.inner = (void*)(this_obj & (~1));
22766         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22768         ChainMonitor_free(this_obj_conv);
22769 }
22770
22771 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) {
22772         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
22773         CHECK_ACCESS(chain_source_ptr);
22774         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
22775         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
22776         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
22777                 // Manually implement clone for Java trait instances
22778                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
22779                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22780                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
22781                 }
22782         }
22783         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22784         CHECK_ACCESS(broadcaster_ptr);
22785         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22786         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22787                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22788                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22789         }
22790         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22791         CHECK_ACCESS(logger_ptr);
22792         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22793         if (logger_conv.free == LDKLogger_JCalls_free) {
22794                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22795                 LDKLogger_JCalls_cloned(&logger_conv);
22796         }
22797         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
22798         CHECK_ACCESS(feeest_ptr);
22799         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
22800         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
22801                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22802                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
22803         }
22804         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
22805         CHECK_ACCESS(persister_ptr);
22806         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
22807         if (persister_conv.free == LDKPersist_JCalls_free) {
22808                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22809                 LDKPersist_JCalls_cloned(&persister_conv);
22810         }
22811         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
22812         uint32_t ret_ref = 0;
22813         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22814         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22816         ret_ref = (uintptr_t)ret_var.inner;
22817         if (ret_var.is_owned) {
22818                 ret_ref |= 1;
22819         }
22820         return ret_ref;
22821 }
22822
22823 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
22824         LDKChainMonitor this_arg_conv;
22825         this_arg_conv.inner = (void*)(this_arg & (~1));
22826         this_arg_conv.is_owned = false;
22827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22828         LDKCVec_ChannelDetailsZ ignored_channels_constr;
22829         ignored_channels_constr.datalen = ignored_channels->arr_len;
22830         if (ignored_channels_constr.datalen > 0)
22831                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
22832         else
22833                 ignored_channels_constr.data = NULL;
22834         uint32_t* ignored_channels_vals = ignored_channels->elems;
22835         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
22836                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
22837                 LDKChannelDetails ignored_channels_conv_16_conv;
22838                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
22839                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
22840                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
22841                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
22842                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
22843         }
22844         FREE(ignored_channels);
22845         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
22846         uint32_tArray ret_arr = NULL;
22847         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22848         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22849         for (size_t j = 0; j < ret_var.datalen; j++) {
22850                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22851                 *ret_conv_9_copy = ret_var.data[j];
22852                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
22853                 ret_arr_ptr[j] = ret_conv_9_ref;
22854         }
22855         
22856         FREE(ret_var.data);
22857         return ret_arr;
22858 }
22859
22860 uint32_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
22861         LDKChainMonitor this_arg_conv;
22862         this_arg_conv.inner = (void*)(this_arg & (~1));
22863         this_arg_conv.is_owned = false;
22864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22865         LDKOutPoint funding_txo_conv;
22866         funding_txo_conv.inner = (void*)(funding_txo & (~1));
22867         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
22868         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
22869         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
22870         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
22871         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
22872         return (uint32_t)ret_conv;
22873 }
22874
22875 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
22876         LDKChainMonitor this_arg_conv;
22877         this_arg_conv.inner = (void*)(this_arg & (~1));
22878         this_arg_conv.is_owned = false;
22879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22880         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
22881         uint32_tArray ret_arr = NULL;
22882         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22883         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22884         for (size_t k = 0; k < ret_var.datalen; k++) {
22885                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
22886                 uint32_t ret_conv_10_ref = 0;
22887                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22888                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22889                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
22890                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
22891                 if (ret_conv_10_var.is_owned) {
22892                         ret_conv_10_ref |= 1;
22893                 }
22894                 ret_arr_ptr[k] = ret_conv_10_ref;
22895         }
22896         
22897         FREE(ret_var.data);
22898         return ret_arr;
22899 }
22900
22901 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) {
22902         LDKChainMonitor this_arg_conv;
22903         this_arg_conv.inner = (void*)(this_arg & (~1));
22904         this_arg_conv.is_owned = false;
22905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22906         LDKOutPoint funding_txo_conv;
22907         funding_txo_conv.inner = (void*)(funding_txo & (~1));
22908         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
22909         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
22910         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
22911         LDKMonitorUpdateId completed_update_id_conv;
22912         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
22913         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
22914         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
22915         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
22916         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
22917         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
22918         return (uint32_t)ret_conv;
22919 }
22920
22921 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
22922         LDKChainMonitor this_arg_conv;
22923         this_arg_conv.inner = (void*)(this_arg & (~1));
22924         this_arg_conv.is_owned = false;
22925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22926         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
22927         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
22928         return (uint32_t)ret_ret;
22929 }
22930
22931 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
22932         LDKChainMonitor this_arg_conv;
22933         this_arg_conv.inner = (void*)(this_arg & (~1));
22934         this_arg_conv.is_owned = false;
22935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22936         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
22937         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
22938         return (uint32_t)ret_ret;
22939 }
22940
22941 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
22942         LDKChainMonitor this_arg_conv;
22943         this_arg_conv.inner = (void*)(this_arg & (~1));
22944         this_arg_conv.is_owned = false;
22945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22946         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
22947         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
22948         return (uint32_t)ret_ret;
22949 }
22950
22951 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
22952         LDKChainMonitor this_arg_conv;
22953         this_arg_conv.inner = (void*)(this_arg & (~1));
22954         this_arg_conv.is_owned = false;
22955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22956         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
22957         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
22958         return (uint32_t)ret_ret;
22959 }
22960
22961 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
22962         LDKChannelMonitorUpdate this_obj_conv;
22963         this_obj_conv.inner = (void*)(this_obj & (~1));
22964         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22966         ChannelMonitorUpdate_free(this_obj_conv);
22967 }
22968
22969 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
22970         LDKChannelMonitorUpdate this_ptr_conv;
22971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22972         this_ptr_conv.is_owned = false;
22973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22974         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
22975         return ret_conv;
22976 }
22977
22978 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
22979         LDKChannelMonitorUpdate this_ptr_conv;
22980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22981         this_ptr_conv.is_owned = false;
22982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22983         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
22984 }
22985
22986 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
22987         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
22988 uint32_t ret_ref = 0;
22989 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22990 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22991 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22992 ret_ref = (uintptr_t)ret_var.inner;
22993 if (ret_var.is_owned) {
22994         ret_ref |= 1;
22995 }
22996         return ret_ref;
22997 }
22998 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
22999         LDKChannelMonitorUpdate arg_conv;
23000         arg_conv.inner = (void*)(arg & (~1));
23001         arg_conv.is_owned = false;
23002         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23003         uint32_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
23004         return ret_conv;
23005 }
23006
23007 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
23008         LDKChannelMonitorUpdate orig_conv;
23009         orig_conv.inner = (void*)(orig & (~1));
23010         orig_conv.is_owned = false;
23011         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23012         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
23013         uint32_t ret_ref = 0;
23014         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23015         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23017         ret_ref = (uintptr_t)ret_var.inner;
23018         if (ret_var.is_owned) {
23019                 ret_ref |= 1;
23020         }
23021         return ret_ref;
23022 }
23023
23024 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
23025         LDKChannelMonitorUpdate obj_conv;
23026         obj_conv.inner = (void*)(obj & (~1));
23027         obj_conv.is_owned = false;
23028         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23029         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
23030         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23031         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23032         CVec_u8Z_free(ret_var);
23033         return ret_arr;
23034 }
23035
23036 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
23037         LDKu8slice ser_ref;
23038         ser_ref.datalen = ser->arr_len;
23039         ser_ref.data = ser->elems;
23040         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
23041         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
23042         FREE(ser);
23043         return (uint32_t)ret_conv;
23044 }
23045
23046 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint32_t this_ptr) {
23047         if ((this_ptr & 1) != 0) return;
23048         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23049         CHECK_ACCESS(this_ptr_ptr);
23050         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
23051         FREE((void*)this_ptr);
23052         MonitorEvent_free(this_ptr_conv);
23053 }
23054
23055 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
23056         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23057         *ret_copy = MonitorEvent_clone(arg);
23058 uint32_t ret_ref = (uintptr_t)ret_copy;
23059         return ret_ref;
23060 }
23061 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
23062         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
23063         uint32_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
23064         return ret_conv;
23065 }
23066
23067 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint32_t orig) {
23068         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
23069         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23070         *ret_copy = MonitorEvent_clone(orig_conv);
23071         uint32_t ret_ref = (uintptr_t)ret_copy;
23072         return ret_ref;
23073 }
23074
23075 uint32_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint32_t a) {
23076         LDKHTLCUpdate a_conv;
23077         a_conv.inner = (void*)(a & (~1));
23078         a_conv.is_owned = (a & 1) || (a == 0);
23079         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23080         a_conv = HTLCUpdate_clone(&a_conv);
23081         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23082         *ret_copy = MonitorEvent_htlcevent(a_conv);
23083         uint32_t ret_ref = (uintptr_t)ret_copy;
23084         return ret_ref;
23085 }
23086
23087 uint32_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
23088         LDKOutPoint a_conv;
23089         a_conv.inner = (void*)(a & (~1));
23090         a_conv.is_owned = (a & 1) || (a == 0);
23091         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23092         a_conv = OutPoint_clone(&a_conv);
23093         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23094         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
23095         uint32_t ret_ref = (uintptr_t)ret_copy;
23096         return ret_ref;
23097 }
23098
23099 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
23100         LDKOutPoint funding_txo_conv;
23101         funding_txo_conv.inner = (void*)(funding_txo & (~1));
23102         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
23103         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
23104         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
23105         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23106         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
23107         uint32_t ret_ref = (uintptr_t)ret_copy;
23108         return ret_ref;
23109 }
23110
23111 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint32_t a) {
23112         LDKOutPoint a_conv;
23113         a_conv.inner = (void*)(a & (~1));
23114         a_conv.is_owned = (a & 1) || (a == 0);
23115         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23116         a_conv = OutPoint_clone(&a_conv);
23117         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23118         *ret_copy = MonitorEvent_update_failed(a_conv);
23119         uint32_t ret_ref = (uintptr_t)ret_copy;
23120         return ret_ref;
23121 }
23122
23123 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint32_t obj) {
23124         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
23125         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
23126         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23127         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23128         CVec_u8Z_free(ret_var);
23129         return ret_arr;
23130 }
23131
23132 uint32_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
23133         LDKu8slice ser_ref;
23134         ser_ref.datalen = ser->arr_len;
23135         ser_ref.data = ser->elems;
23136         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23137         *ret_conv = MonitorEvent_read(ser_ref);
23138         FREE(ser);
23139         return (uint32_t)ret_conv;
23140 }
23141
23142 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint32_t this_obj) {
23143         LDKHTLCUpdate this_obj_conv;
23144         this_obj_conv.inner = (void*)(this_obj & (~1));
23145         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23147         HTLCUpdate_free(this_obj_conv);
23148 }
23149
23150 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
23151         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
23152 uint32_t ret_ref = 0;
23153 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23154 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23155 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23156 ret_ref = (uintptr_t)ret_var.inner;
23157 if (ret_var.is_owned) {
23158         ret_ref |= 1;
23159 }
23160         return ret_ref;
23161 }
23162 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
23163         LDKHTLCUpdate arg_conv;
23164         arg_conv.inner = (void*)(arg & (~1));
23165         arg_conv.is_owned = false;
23166         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23167         uint32_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
23168         return ret_conv;
23169 }
23170
23171 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint32_t orig) {
23172         LDKHTLCUpdate orig_conv;
23173         orig_conv.inner = (void*)(orig & (~1));
23174         orig_conv.is_owned = false;
23175         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23176         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
23177         uint32_t ret_ref = 0;
23178         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23179         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23181         ret_ref = (uintptr_t)ret_var.inner;
23182         if (ret_var.is_owned) {
23183                 ret_ref |= 1;
23184         }
23185         return ret_ref;
23186 }
23187
23188 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint32_t obj) {
23189         LDKHTLCUpdate obj_conv;
23190         obj_conv.inner = (void*)(obj & (~1));
23191         obj_conv.is_owned = false;
23192         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23193         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
23194         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23195         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23196         CVec_u8Z_free(ret_var);
23197         return ret_arr;
23198 }
23199
23200 uint32_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
23201         LDKu8slice ser_ref;
23202         ser_ref.datalen = ser->arr_len;
23203         ser_ref.data = ser->elems;
23204         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23205         *ret_conv = HTLCUpdate_read(ser_ref);
23206         FREE(ser);
23207         return (uint32_t)ret_conv;
23208 }
23209
23210 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint32_t this_ptr) {
23211         if ((this_ptr & 1) != 0) return;
23212         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23213         CHECK_ACCESS(this_ptr_ptr);
23214         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
23215         FREE((void*)this_ptr);
23216         Balance_free(this_ptr_conv);
23217 }
23218
23219 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
23220         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23221         *ret_copy = Balance_clone(arg);
23222 uint32_t ret_ref = (uintptr_t)ret_copy;
23223         return ret_ref;
23224 }
23225 uint32_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint32_t arg) {
23226         LDKBalance* arg_conv = (LDKBalance*)arg;
23227         uint32_t ret_conv = Balance_clone_ptr(arg_conv);
23228         return ret_conv;
23229 }
23230
23231 uint32_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint32_t orig) {
23232         LDKBalance* orig_conv = (LDKBalance*)orig;
23233         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23234         *ret_copy = Balance_clone(orig_conv);
23235         uint32_t ret_ref = (uintptr_t)ret_copy;
23236         return ret_ref;
23237 }
23238
23239 uint32_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
23240         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23241         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
23242         uint32_t ret_ref = (uintptr_t)ret_copy;
23243         return ret_ref;
23244 }
23245
23246 uint32_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
23247         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23248         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
23249         uint32_t ret_ref = (uintptr_t)ret_copy;
23250         return ret_ref;
23251 }
23252
23253 uint32_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
23254         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23255         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
23256         uint32_t ret_ref = (uintptr_t)ret_copy;
23257         return ret_ref;
23258 }
23259
23260 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) {
23261         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23262         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
23263         uint32_t ret_ref = (uintptr_t)ret_copy;
23264         return ret_ref;
23265 }
23266
23267 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint32_t a, uint32_t b) {
23268         LDKBalance* a_conv = (LDKBalance*)a;
23269         LDKBalance* b_conv = (LDKBalance*)b;
23270         jboolean ret_conv = Balance_eq(a_conv, b_conv);
23271         return ret_conv;
23272 }
23273
23274 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint32_t this_obj) {
23275         LDKChannelMonitor this_obj_conv;
23276         this_obj_conv.inner = (void*)(this_obj & (~1));
23277         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23279         ChannelMonitor_free(this_obj_conv);
23280 }
23281
23282 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
23283         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
23284 uint32_t ret_ref = 0;
23285 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23286 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23287 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23288 ret_ref = (uintptr_t)ret_var.inner;
23289 if (ret_var.is_owned) {
23290         ret_ref |= 1;
23291 }
23292         return ret_ref;
23293 }
23294 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
23295         LDKChannelMonitor arg_conv;
23296         arg_conv.inner = (void*)(arg & (~1));
23297         arg_conv.is_owned = false;
23298         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23299         uint32_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
23300         return ret_conv;
23301 }
23302
23303 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint32_t orig) {
23304         LDKChannelMonitor orig_conv;
23305         orig_conv.inner = (void*)(orig & (~1));
23306         orig_conv.is_owned = false;
23307         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23308         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
23309         uint32_t ret_ref = 0;
23310         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23311         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23312         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23313         ret_ref = (uintptr_t)ret_var.inner;
23314         if (ret_var.is_owned) {
23315                 ret_ref |= 1;
23316         }
23317         return ret_ref;
23318 }
23319
23320 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint32_t obj) {
23321         LDKChannelMonitor obj_conv;
23322         obj_conv.inner = (void*)(obj & (~1));
23323         obj_conv.is_owned = false;
23324         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23325         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
23326         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23327         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23328         CVec_u8Z_free(ret_var);
23329         return ret_arr;
23330 }
23331
23332 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) {
23333         LDKChannelMonitor this_arg_conv;
23334         this_arg_conv.inner = (void*)(this_arg & (~1));
23335         this_arg_conv.is_owned = false;
23336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23337         LDKChannelMonitorUpdate updates_conv;
23338         updates_conv.inner = (void*)(updates & (~1));
23339         updates_conv.is_owned = false;
23340         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
23341         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23342         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
23343         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
23344         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23345         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
23346         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
23347         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23348         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
23349         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
23350         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
23351         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
23352         return (uint32_t)ret_conv;
23353 }
23354
23355 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
23356         LDKChannelMonitor this_arg_conv;
23357         this_arg_conv.inner = (void*)(this_arg & (~1));
23358         this_arg_conv.is_owned = false;
23359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23360         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
23361         return ret_conv;
23362 }
23363
23364 uint32_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
23365         LDKChannelMonitor this_arg_conv;
23366         this_arg_conv.inner = (void*)(this_arg & (~1));
23367         this_arg_conv.is_owned = false;
23368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23369         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23370         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
23371         return ((uint32_t)ret_conv);
23372 }
23373
23374 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
23375         LDKChannelMonitor this_arg_conv;
23376         this_arg_conv.inner = (void*)(this_arg & (~1));
23377         this_arg_conv.is_owned = false;
23378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23379         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
23380         uint32_tArray ret_arr = NULL;
23381         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23382         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23383         for (size_t o = 0; o < ret_var.datalen; o++) {
23384                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23385                 *ret_conv_40_conv = ret_var.data[o];
23386                 ret_arr_ptr[o] = ((uint32_t)ret_conv_40_conv);
23387         }
23388         
23389         FREE(ret_var.data);
23390         return ret_arr;
23391 }
23392
23393 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
23394         LDKChannelMonitor this_arg_conv;
23395         this_arg_conv.inner = (void*)(this_arg & (~1));
23396         this_arg_conv.is_owned = false;
23397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23398         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
23399         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
23400         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
23401         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
23402 }
23403
23404 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) {
23405         LDKChannelMonitor this_arg_conv;
23406         this_arg_conv.inner = (void*)(this_arg & (~1));
23407         this_arg_conv.is_owned = false;
23408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23409         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
23410         uint32_tArray ret_arr = NULL;
23411         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23412         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23413         for (size_t o = 0; o < ret_var.datalen; o++) {
23414                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23415                 *ret_conv_14_copy = ret_var.data[o];
23416                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
23417                 ret_arr_ptr[o] = ret_conv_14_ref;
23418         }
23419         
23420         FREE(ret_var.data);
23421         return ret_arr;
23422 }
23423
23424 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
23425         LDKChannelMonitor this_arg_conv;
23426         this_arg_conv.inner = (void*)(this_arg & (~1));
23427         this_arg_conv.is_owned = false;
23428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23429         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
23430         uint32_tArray ret_arr = NULL;
23431         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23432         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23433         for (size_t h = 0; h < ret_var.datalen; h++) {
23434                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23435                 *ret_conv_7_copy = ret_var.data[h];
23436                 uint32_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
23437                 ret_arr_ptr[h] = ret_conv_7_ref;
23438         }
23439         
23440         FREE(ret_var.data);
23441         return ret_arr;
23442 }
23443
23444 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) {
23445         LDKChannelMonitor this_arg_conv;
23446         this_arg_conv.inner = (void*)(this_arg & (~1));
23447         this_arg_conv.is_owned = false;
23448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23449         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23450         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
23451         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
23452         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
23453         ptrArray ret_arr = NULL;
23454         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
23455         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
23456         for (size_t m = 0; m < ret_var.datalen; m++) {
23457                 LDKTransaction ret_conv_12_var = ret_var.data[m];
23458                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
23459                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
23460                 Transaction_free(ret_conv_12_var);
23461                 ret_arr_ptr[m] = ret_conv_12_arr;
23462         }
23463         
23464         FREE(ret_var.data);
23465         return ret_arr;
23466 }
23467
23468 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) {
23469         LDKChannelMonitor this_arg_conv;
23470         this_arg_conv.inner = (void*)(this_arg & (~1));
23471         this_arg_conv.is_owned = false;
23472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23473         unsigned char header_arr[80];
23474         CHECK(header->arr_len == 80);
23475         memcpy(header_arr, header->elems, 80); FREE(header);
23476         unsigned char (*header_ref)[80] = &header_arr;
23477         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
23478         txdata_constr.datalen = txdata->arr_len;
23479         if (txdata_constr.datalen > 0)
23480                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
23481         else
23482                 txdata_constr.data = NULL;
23483         uint32_t* txdata_vals = txdata->elems;
23484         for (size_t c = 0; c < txdata_constr.datalen; c++) {
23485                 uint32_t txdata_conv_28 = txdata_vals[c];
23486                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
23487                 CHECK_ACCESS(txdata_conv_28_ptr);
23488                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
23489                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
23490                 txdata_constr.data[c] = txdata_conv_28_conv;
23491         }
23492         FREE(txdata);
23493         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23494         CHECK_ACCESS(broadcaster_ptr);
23495         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23496         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23497                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23498                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23499         }
23500         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23501         CHECK_ACCESS(fee_estimator_ptr);
23502         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23503         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23504                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23505                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23506         }
23507         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23508         CHECK_ACCESS(logger_ptr);
23509         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23510         if (logger_conv.free == LDKLogger_JCalls_free) {
23511                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23512                 LDKLogger_JCalls_cloned(&logger_conv);
23513         }
23514         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);
23515         uint32_tArray ret_arr = NULL;
23516         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23517         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23518         for (size_t n = 0; n < ret_var.datalen; n++) {
23519                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23520                 *ret_conv_39_conv = ret_var.data[n];
23521                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
23522         }
23523         
23524         FREE(ret_var.data);
23525         return ret_arr;
23526 }
23527
23528 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) {
23529         LDKChannelMonitor this_arg_conv;
23530         this_arg_conv.inner = (void*)(this_arg & (~1));
23531         this_arg_conv.is_owned = false;
23532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23533         unsigned char header_arr[80];
23534         CHECK(header->arr_len == 80);
23535         memcpy(header_arr, header->elems, 80); FREE(header);
23536         unsigned char (*header_ref)[80] = &header_arr;
23537         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23538         CHECK_ACCESS(broadcaster_ptr);
23539         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23540         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23541                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23542                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23543         }
23544         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23545         CHECK_ACCESS(fee_estimator_ptr);
23546         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23547         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23548                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23549                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23550         }
23551         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23552         CHECK_ACCESS(logger_ptr);
23553         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23554         if (logger_conv.free == LDKLogger_JCalls_free) {
23555                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23556                 LDKLogger_JCalls_cloned(&logger_conv);
23557         }
23558         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
23559 }
23560
23561 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) {
23562         LDKChannelMonitor this_arg_conv;
23563         this_arg_conv.inner = (void*)(this_arg & (~1));
23564         this_arg_conv.is_owned = false;
23565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23566         unsigned char header_arr[80];
23567         CHECK(header->arr_len == 80);
23568         memcpy(header_arr, header->elems, 80); FREE(header);
23569         unsigned char (*header_ref)[80] = &header_arr;
23570         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
23571         txdata_constr.datalen = txdata->arr_len;
23572         if (txdata_constr.datalen > 0)
23573                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
23574         else
23575                 txdata_constr.data = NULL;
23576         uint32_t* txdata_vals = txdata->elems;
23577         for (size_t c = 0; c < txdata_constr.datalen; c++) {
23578                 uint32_t txdata_conv_28 = txdata_vals[c];
23579                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
23580                 CHECK_ACCESS(txdata_conv_28_ptr);
23581                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
23582                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
23583                 txdata_constr.data[c] = txdata_conv_28_conv;
23584         }
23585         FREE(txdata);
23586         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23587         CHECK_ACCESS(broadcaster_ptr);
23588         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23589         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23590                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23591                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23592         }
23593         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23594         CHECK_ACCESS(fee_estimator_ptr);
23595         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23596         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23597                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23598                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23599         }
23600         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23601         CHECK_ACCESS(logger_ptr);
23602         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23603         if (logger_conv.free == LDKLogger_JCalls_free) {
23604                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23605                 LDKLogger_JCalls_cloned(&logger_conv);
23606         }
23607         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);
23608         uint32_tArray ret_arr = NULL;
23609         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23610         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23611         for (size_t n = 0; n < ret_var.datalen; n++) {
23612                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23613                 *ret_conv_39_conv = ret_var.data[n];
23614                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
23615         }
23616         
23617         FREE(ret_var.data);
23618         return ret_arr;
23619 }
23620
23621 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) {
23622         LDKChannelMonitor this_arg_conv;
23623         this_arg_conv.inner = (void*)(this_arg & (~1));
23624         this_arg_conv.is_owned = false;
23625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23626         unsigned char txid_arr[32];
23627         CHECK(txid->arr_len == 32);
23628         memcpy(txid_arr, txid->elems, 32); FREE(txid);
23629         unsigned char (*txid_ref)[32] = &txid_arr;
23630         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23631         CHECK_ACCESS(broadcaster_ptr);
23632         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23633         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23634                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23635                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23636         }
23637         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23638         CHECK_ACCESS(fee_estimator_ptr);
23639         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23640         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23641                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23642                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23643         }
23644         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23645         CHECK_ACCESS(logger_ptr);
23646         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23647         if (logger_conv.free == LDKLogger_JCalls_free) {
23648                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23649                 LDKLogger_JCalls_cloned(&logger_conv);
23650         }
23651         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
23652 }
23653
23654 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) {
23655         LDKChannelMonitor this_arg_conv;
23656         this_arg_conv.inner = (void*)(this_arg & (~1));
23657         this_arg_conv.is_owned = false;
23658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23659         unsigned char header_arr[80];
23660         CHECK(header->arr_len == 80);
23661         memcpy(header_arr, header->elems, 80); FREE(header);
23662         unsigned char (*header_ref)[80] = &header_arr;
23663         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23664         CHECK_ACCESS(broadcaster_ptr);
23665         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23666         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23667                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23668                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23669         }
23670         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23671         CHECK_ACCESS(fee_estimator_ptr);
23672         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23673         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23674                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23675                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23676         }
23677         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23678         CHECK_ACCESS(logger_ptr);
23679         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23680         if (logger_conv.free == LDKLogger_JCalls_free) {
23681                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23682                 LDKLogger_JCalls_cloned(&logger_conv);
23683         }
23684         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
23685         uint32_tArray ret_arr = NULL;
23686         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23687         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23688         for (size_t n = 0; n < ret_var.datalen; n++) {
23689                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23690                 *ret_conv_39_conv = ret_var.data[n];
23691                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
23692         }
23693         
23694         FREE(ret_var.data);
23695         return ret_arr;
23696 }
23697
23698 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
23699         LDKChannelMonitor this_arg_conv;
23700         this_arg_conv.inner = (void*)(this_arg & (~1));
23701         this_arg_conv.is_owned = false;
23702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23703         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
23704         ptrArray ret_arr = NULL;
23705         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
23706         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
23707         for (size_t m = 0; m < ret_var.datalen; m++) {
23708                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
23709                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
23710                 ret_arr_ptr[m] = ret_conv_12_arr;
23711         }
23712         
23713         FREE(ret_var.data);
23714         return ret_arr;
23715 }
23716
23717 uint32_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
23718         LDKChannelMonitor this_arg_conv;
23719         this_arg_conv.inner = (void*)(this_arg & (~1));
23720         this_arg_conv.is_owned = false;
23721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23722         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
23723         uint32_t ret_ref = 0;
23724         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23725         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23727         ret_ref = (uintptr_t)ret_var.inner;
23728         if (ret_var.is_owned) {
23729                 ret_ref |= 1;
23730         }
23731         return ret_ref;
23732 }
23733
23734 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
23735         LDKChannelMonitor this_arg_conv;
23736         this_arg_conv.inner = (void*)(this_arg & (~1));
23737         this_arg_conv.is_owned = false;
23738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23739         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
23740         uint32_tArray ret_arr = NULL;
23741         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23742         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23743         for (size_t j = 0; j < ret_var.datalen; j++) {
23744                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23745                 *ret_conv_9_copy = ret_var.data[j];
23746                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
23747                 ret_arr_ptr[j] = ret_conv_9_ref;
23748         }
23749         
23750         FREE(ret_var.data);
23751         return ret_arr;
23752 }
23753
23754 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
23755         LDKu8slice ser_ref;
23756         ser_ref.datalen = ser->arr_len;
23757         ser_ref.data = ser->elems;
23758         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
23759         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
23760         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
23761         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23762         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
23763         FREE(ser);
23764         return (uint32_t)ret_conv;
23765 }
23766
23767 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint32_t this_obj) {
23768         LDKOutPoint this_obj_conv;
23769         this_obj_conv.inner = (void*)(this_obj & (~1));
23770         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23772         OutPoint_free(this_obj_conv);
23773 }
23774
23775 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
23776         LDKOutPoint this_ptr_conv;
23777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23778         this_ptr_conv.is_owned = false;
23779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23780         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23781         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
23782         return ret_arr;
23783 }
23784
23785 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
23786         LDKOutPoint this_ptr_conv;
23787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23788         this_ptr_conv.is_owned = false;
23789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23790         LDKThirtyTwoBytes val_ref;
23791         CHECK(val->arr_len == 32);
23792         memcpy(val_ref.data, val->elems, 32); FREE(val);
23793         OutPoint_set_txid(&this_ptr_conv, val_ref);
23794 }
23795
23796 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint32_t this_ptr) {
23797         LDKOutPoint this_ptr_conv;
23798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23799         this_ptr_conv.is_owned = false;
23800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23801         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
23802         return ret_conv;
23803 }
23804
23805 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
23806         LDKOutPoint this_ptr_conv;
23807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23808         this_ptr_conv.is_owned = false;
23809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23810         OutPoint_set_index(&this_ptr_conv, val);
23811 }
23812
23813 uint32_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
23814         LDKThirtyTwoBytes txid_arg_ref;
23815         CHECK(txid_arg->arr_len == 32);
23816         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
23817         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
23818         uint32_t ret_ref = 0;
23819         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23820         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23822         ret_ref = (uintptr_t)ret_var.inner;
23823         if (ret_var.is_owned) {
23824                 ret_ref |= 1;
23825         }
23826         return ret_ref;
23827 }
23828
23829 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
23830         LDKOutPoint ret_var = OutPoint_clone(arg);
23831 uint32_t ret_ref = 0;
23832 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23833 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23834 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23835 ret_ref = (uintptr_t)ret_var.inner;
23836 if (ret_var.is_owned) {
23837         ret_ref |= 1;
23838 }
23839         return ret_ref;
23840 }
23841 uint32_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint32_t arg) {
23842         LDKOutPoint arg_conv;
23843         arg_conv.inner = (void*)(arg & (~1));
23844         arg_conv.is_owned = false;
23845         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23846         uint32_t ret_conv = OutPoint_clone_ptr(&arg_conv);
23847         return ret_conv;
23848 }
23849
23850 uint32_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint32_t orig) {
23851         LDKOutPoint orig_conv;
23852         orig_conv.inner = (void*)(orig & (~1));
23853         orig_conv.is_owned = false;
23854         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23855         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
23856         uint32_t ret_ref = 0;
23857         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23858         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23860         ret_ref = (uintptr_t)ret_var.inner;
23861         if (ret_var.is_owned) {
23862                 ret_ref |= 1;
23863         }
23864         return ret_ref;
23865 }
23866
23867 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
23868         LDKOutPoint a_conv;
23869         a_conv.inner = (void*)(a & (~1));
23870         a_conv.is_owned = false;
23871         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23872         LDKOutPoint b_conv;
23873         b_conv.inner = (void*)(b & (~1));
23874         b_conv.is_owned = false;
23875         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
23876         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
23877         return ret_conv;
23878 }
23879
23880 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint32_t o) {
23881         LDKOutPoint o_conv;
23882         o_conv.inner = (void*)(o & (~1));
23883         o_conv.is_owned = false;
23884         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23885         int64_t ret_conv = OutPoint_hash(&o_conv);
23886         return ret_conv;
23887 }
23888
23889 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
23890         LDKOutPoint this_arg_conv;
23891         this_arg_conv.inner = (void*)(this_arg & (~1));
23892         this_arg_conv.is_owned = false;
23893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23894         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23895         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
23896         return ret_arr;
23897 }
23898
23899 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint32_t obj) {
23900         LDKOutPoint obj_conv;
23901         obj_conv.inner = (void*)(obj & (~1));
23902         obj_conv.is_owned = false;
23903         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23904         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
23905         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23906         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23907         CVec_u8Z_free(ret_var);
23908         return ret_arr;
23909 }
23910
23911 uint32_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
23912         LDKu8slice ser_ref;
23913         ser_ref.datalen = ser->arr_len;
23914         ser_ref.data = ser->elems;
23915         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
23916         *ret_conv = OutPoint_read(ser_ref);
23917         FREE(ser);
23918         return (uint32_t)ret_conv;
23919 }
23920
23921 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
23922         LDKDelayedPaymentOutputDescriptor this_obj_conv;
23923         this_obj_conv.inner = (void*)(this_obj & (~1));
23924         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23926         DelayedPaymentOutputDescriptor_free(this_obj_conv);
23927 }
23928
23929 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
23930         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23932         this_ptr_conv.is_owned = false;
23933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23934         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
23935         uint32_t ret_ref = 0;
23936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23939         ret_ref = (uintptr_t)ret_var.inner;
23940         if (ret_var.is_owned) {
23941                 ret_ref |= 1;
23942         }
23943         return ret_ref;
23944 }
23945
23946 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
23947         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23949         this_ptr_conv.is_owned = false;
23950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23951         LDKOutPoint val_conv;
23952         val_conv.inner = (void*)(val & (~1));
23953         val_conv.is_owned = (val & 1) || (val == 0);
23954         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23955         val_conv = OutPoint_clone(&val_conv);
23956         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
23957 }
23958
23959 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
23960         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23962         this_ptr_conv.is_owned = false;
23963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23964         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23965         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23966         return ret_arr;
23967 }
23968
23969 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
23970         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23972         this_ptr_conv.is_owned = false;
23973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23974         LDKPublicKey val_ref;
23975         CHECK(val->arr_len == 33);
23976         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23977         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
23978 }
23979
23980 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
23981         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23983         this_ptr_conv.is_owned = false;
23984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23985         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
23986         return ret_conv;
23987 }
23988
23989 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
23990         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23992         this_ptr_conv.is_owned = false;
23993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23994         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
23995 }
23996
23997 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
23998         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24000         this_ptr_conv.is_owned = false;
24001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24002         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24003         CHECK_ACCESS(val_ptr);
24004         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
24005         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
24006         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
24007 }
24008
24009 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
24010         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24012         this_ptr_conv.is_owned = false;
24013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24014         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24015         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
24016         return ret_arr;
24017 }
24018
24019 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
24020         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24022         this_ptr_conv.is_owned = false;
24023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24024         LDKPublicKey val_ref;
24025         CHECK(val->arr_len == 33);
24026         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24027         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
24028 }
24029
24030 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
24031         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24033         this_ptr_conv.is_owned = false;
24034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24035         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24036         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
24037         return ret_arr;
24038 }
24039
24040 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
24041         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24043         this_ptr_conv.is_owned = false;
24044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24045         LDKThirtyTwoBytes val_ref;
24046         CHECK(val->arr_len == 32);
24047         memcpy(val_ref.data, val->elems, 32); FREE(val);
24048         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
24049 }
24050
24051 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
24052         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24054         this_ptr_conv.is_owned = false;
24055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24056         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
24057         return ret_conv;
24058 }
24059
24060 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24061         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24063         this_ptr_conv.is_owned = false;
24064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24065         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
24066 }
24067
24068 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) {
24069         LDKOutPoint outpoint_arg_conv;
24070         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
24071         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
24072         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
24073         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
24074         LDKPublicKey per_commitment_point_arg_ref;
24075         CHECK(per_commitment_point_arg->arr_len == 33);
24076         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
24077         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
24078         CHECK_ACCESS(output_arg_ptr);
24079         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
24080         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
24081         LDKPublicKey revocation_pubkey_arg_ref;
24082         CHECK(revocation_pubkey_arg->arr_len == 33);
24083         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
24084         LDKThirtyTwoBytes channel_keys_id_arg_ref;
24085         CHECK(channel_keys_id_arg->arr_len == 32);
24086         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
24087         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);
24088         uint32_t ret_ref = 0;
24089         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24090         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24092         ret_ref = (uintptr_t)ret_var.inner;
24093         if (ret_var.is_owned) {
24094                 ret_ref |= 1;
24095         }
24096         return ret_ref;
24097 }
24098
24099 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
24100         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
24101 uint32_t ret_ref = 0;
24102 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24103 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24104 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24105 ret_ref = (uintptr_t)ret_var.inner;
24106 if (ret_var.is_owned) {
24107         ret_ref |= 1;
24108 }
24109         return ret_ref;
24110 }
24111 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
24112         LDKDelayedPaymentOutputDescriptor arg_conv;
24113         arg_conv.inner = (void*)(arg & (~1));
24114         arg_conv.is_owned = false;
24115         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24116         uint32_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
24117         return ret_conv;
24118 }
24119
24120 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
24121         LDKDelayedPaymentOutputDescriptor orig_conv;
24122         orig_conv.inner = (void*)(orig & (~1));
24123         orig_conv.is_owned = false;
24124         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24125         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
24126         uint32_t ret_ref = 0;
24127         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24128         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24130         ret_ref = (uintptr_t)ret_var.inner;
24131         if (ret_var.is_owned) {
24132                 ret_ref |= 1;
24133         }
24134         return ret_ref;
24135 }
24136
24137 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
24138         LDKDelayedPaymentOutputDescriptor obj_conv;
24139         obj_conv.inner = (void*)(obj & (~1));
24140         obj_conv.is_owned = false;
24141         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24142         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
24143         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24144         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24145         CVec_u8Z_free(ret_var);
24146         return ret_arr;
24147 }
24148
24149 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
24150         LDKu8slice ser_ref;
24151         ser_ref.datalen = ser->arr_len;
24152         ser_ref.data = ser->elems;
24153         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
24154         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
24155         FREE(ser);
24156         return (uint32_t)ret_conv;
24157 }
24158
24159 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
24160         LDKStaticPaymentOutputDescriptor this_obj_conv;
24161         this_obj_conv.inner = (void*)(this_obj & (~1));
24162         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24164         StaticPaymentOutputDescriptor_free(this_obj_conv);
24165 }
24166
24167 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
24168         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24170         this_ptr_conv.is_owned = false;
24171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24172         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
24173         uint32_t ret_ref = 0;
24174         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24175         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24177         ret_ref = (uintptr_t)ret_var.inner;
24178         if (ret_var.is_owned) {
24179                 ret_ref |= 1;
24180         }
24181         return ret_ref;
24182 }
24183
24184 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
24185         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24187         this_ptr_conv.is_owned = false;
24188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24189         LDKOutPoint val_conv;
24190         val_conv.inner = (void*)(val & (~1));
24191         val_conv.is_owned = (val & 1) || (val == 0);
24192         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24193         val_conv = OutPoint_clone(&val_conv);
24194         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
24195 }
24196
24197 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
24198         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24200         this_ptr_conv.is_owned = false;
24201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24202         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24203         CHECK_ACCESS(val_ptr);
24204         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
24205         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
24206         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
24207 }
24208
24209 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
24210         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24212         this_ptr_conv.is_owned = false;
24213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24214         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24215         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
24216         return ret_arr;
24217 }
24218
24219 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
24220         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24222         this_ptr_conv.is_owned = false;
24223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24224         LDKThirtyTwoBytes val_ref;
24225         CHECK(val->arr_len == 32);
24226         memcpy(val_ref.data, val->elems, 32); FREE(val);
24227         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
24228 }
24229
24230 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
24231         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24233         this_ptr_conv.is_owned = false;
24234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24235         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
24236         return ret_conv;
24237 }
24238
24239 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24240         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24242         this_ptr_conv.is_owned = false;
24243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24244         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
24245 }
24246
24247 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) {
24248         LDKOutPoint outpoint_arg_conv;
24249         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
24250         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
24251         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
24252         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
24253         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
24254         CHECK_ACCESS(output_arg_ptr);
24255         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
24256         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
24257         LDKThirtyTwoBytes channel_keys_id_arg_ref;
24258         CHECK(channel_keys_id_arg->arr_len == 32);
24259         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
24260         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
24261         uint32_t ret_ref = 0;
24262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24265         ret_ref = (uintptr_t)ret_var.inner;
24266         if (ret_var.is_owned) {
24267                 ret_ref |= 1;
24268         }
24269         return ret_ref;
24270 }
24271
24272 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
24273         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
24274 uint32_t ret_ref = 0;
24275 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24276 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24277 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24278 ret_ref = (uintptr_t)ret_var.inner;
24279 if (ret_var.is_owned) {
24280         ret_ref |= 1;
24281 }
24282         return ret_ref;
24283 }
24284 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
24285         LDKStaticPaymentOutputDescriptor arg_conv;
24286         arg_conv.inner = (void*)(arg & (~1));
24287         arg_conv.is_owned = false;
24288         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24289         uint32_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
24290         return ret_conv;
24291 }
24292
24293 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
24294         LDKStaticPaymentOutputDescriptor orig_conv;
24295         orig_conv.inner = (void*)(orig & (~1));
24296         orig_conv.is_owned = false;
24297         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24298         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
24299         uint32_t ret_ref = 0;
24300         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24301         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24303         ret_ref = (uintptr_t)ret_var.inner;
24304         if (ret_var.is_owned) {
24305                 ret_ref |= 1;
24306         }
24307         return ret_ref;
24308 }
24309
24310 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
24311         LDKStaticPaymentOutputDescriptor obj_conv;
24312         obj_conv.inner = (void*)(obj & (~1));
24313         obj_conv.is_owned = false;
24314         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24315         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
24316         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24317         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24318         CVec_u8Z_free(ret_var);
24319         return ret_arr;
24320 }
24321
24322 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
24323         LDKu8slice ser_ref;
24324         ser_ref.datalen = ser->arr_len;
24325         ser_ref.data = ser->elems;
24326         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
24327         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
24328         FREE(ser);
24329         return (uint32_t)ret_conv;
24330 }
24331
24332 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
24333         if ((this_ptr & 1) != 0) return;
24334         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24335         CHECK_ACCESS(this_ptr_ptr);
24336         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
24337         FREE((void*)this_ptr);
24338         SpendableOutputDescriptor_free(this_ptr_conv);
24339 }
24340
24341 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
24342         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24343         *ret_copy = SpendableOutputDescriptor_clone(arg);
24344 uint32_t ret_ref = (uintptr_t)ret_copy;
24345         return ret_ref;
24346 }
24347 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
24348         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
24349         uint32_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
24350         return ret_conv;
24351 }
24352
24353 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
24354         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
24355         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24356         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
24357         uint32_t ret_ref = (uintptr_t)ret_copy;
24358         return ret_ref;
24359 }
24360
24361 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
24362         LDKOutPoint outpoint_conv;
24363         outpoint_conv.inner = (void*)(outpoint & (~1));
24364         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
24365         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
24366         outpoint_conv = OutPoint_clone(&outpoint_conv);
24367         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
24368         CHECK_ACCESS(output_ptr);
24369         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
24370         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
24371         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24372         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
24373         uint32_t ret_ref = (uintptr_t)ret_copy;
24374         return ret_ref;
24375 }
24376
24377 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
24378         LDKDelayedPaymentOutputDescriptor a_conv;
24379         a_conv.inner = (void*)(a & (~1));
24380         a_conv.is_owned = (a & 1) || (a == 0);
24381         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24382         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
24383         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24384         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
24385         uint32_t ret_ref = (uintptr_t)ret_copy;
24386         return ret_ref;
24387 }
24388
24389 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
24390         LDKStaticPaymentOutputDescriptor a_conv;
24391         a_conv.inner = (void*)(a & (~1));
24392         a_conv.is_owned = (a & 1) || (a == 0);
24393         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24394         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
24395         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24396         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
24397         uint32_t ret_ref = (uintptr_t)ret_copy;
24398         return ret_ref;
24399 }
24400
24401 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
24402         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
24403         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
24404         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24405         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24406         CVec_u8Z_free(ret_var);
24407         return ret_arr;
24408 }
24409
24410 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
24411         LDKu8slice ser_ref;
24412         ser_ref.datalen = ser->arr_len;
24413         ser_ref.data = ser->elems;
24414         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
24415         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
24416         FREE(ser);
24417         return (uint32_t)ret_conv;
24418 }
24419
24420 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint32_t this_ptr) {
24421         if ((this_ptr & 1) != 0) return;
24422         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24423         CHECK_ACCESS(this_ptr_ptr);
24424         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
24425         FREE((void*)this_ptr);
24426         BaseSign_free(this_ptr_conv);
24427 }
24428
24429 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
24430         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
24431         *ret_ret = Sign_clone(arg);
24432         return (uint32_t)ret_ret;
24433 }
24434 uint32_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint32_t arg) {
24435         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
24436         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
24437         LDKSign* arg_conv = (LDKSign*)arg_ptr;
24438         uint32_t ret_conv = Sign_clone_ptr(arg_conv);
24439         return ret_conv;
24440 }
24441
24442 uint32_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint32_t orig) {
24443         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
24444         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
24445         LDKSign* orig_conv = (LDKSign*)orig_ptr;
24446         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
24447         *ret_ret = Sign_clone(orig_conv);
24448         return (uint32_t)ret_ret;
24449 }
24450
24451 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint32_t this_ptr) {
24452         if ((this_ptr & 1) != 0) return;
24453         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24454         CHECK_ACCESS(this_ptr_ptr);
24455         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
24456         FREE((void*)this_ptr);
24457         Sign_free(this_ptr_conv);
24458 }
24459
24460 uint32_t  __attribute__((export_name("TS_Recipient_clone"))) TS_Recipient_clone(uint32_t orig) {
24461         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
24462         uint32_t ret_conv = LDKRecipient_to_js(Recipient_clone(orig_conv));
24463         return ret_conv;
24464 }
24465
24466 uint32_t  __attribute__((export_name("TS_Recipient_node"))) TS_Recipient_node() {
24467         uint32_t ret_conv = LDKRecipient_to_js(Recipient_node());
24468         return ret_conv;
24469 }
24470
24471 uint32_t  __attribute__((export_name("TS_Recipient_phantom_node"))) TS_Recipient_phantom_node() {
24472         uint32_t ret_conv = LDKRecipient_to_js(Recipient_phantom_node());
24473         return ret_conv;
24474 }
24475
24476 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint32_t this_ptr) {
24477         if ((this_ptr & 1) != 0) return;
24478         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24479         CHECK_ACCESS(this_ptr_ptr);
24480         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
24481         FREE((void*)this_ptr);
24482         KeysInterface_free(this_ptr_conv);
24483 }
24484
24485 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint32_t this_obj) {
24486         LDKInMemorySigner this_obj_conv;
24487         this_obj_conv.inner = (void*)(this_obj & (~1));
24488         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24490         InMemorySigner_free(this_obj_conv);
24491 }
24492
24493 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
24494         LDKInMemorySigner this_ptr_conv;
24495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24496         this_ptr_conv.is_owned = false;
24497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24498         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24499         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
24500         return ret_arr;
24501 }
24502
24503 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
24504         LDKInMemorySigner this_ptr_conv;
24505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24506         this_ptr_conv.is_owned = false;
24507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24508         LDKSecretKey val_ref;
24509         CHECK(val->arr_len == 32);
24510         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
24511         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
24512 }
24513
24514 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
24515         LDKInMemorySigner this_ptr_conv;
24516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24517         this_ptr_conv.is_owned = false;
24518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24519         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24520         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
24521         return ret_arr;
24522 }
24523
24524 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
24525         LDKInMemorySigner this_ptr_conv;
24526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24527         this_ptr_conv.is_owned = false;
24528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24529         LDKSecretKey val_ref;
24530         CHECK(val->arr_len == 32);
24531         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
24532         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
24533 }
24534
24535 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
24536         LDKInMemorySigner this_ptr_conv;
24537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24538         this_ptr_conv.is_owned = false;
24539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24540         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24541         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
24542         return ret_arr;
24543 }
24544
24545 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
24546         LDKInMemorySigner this_ptr_conv;
24547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24548         this_ptr_conv.is_owned = false;
24549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24550         LDKSecretKey val_ref;
24551         CHECK(val->arr_len == 32);
24552         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
24553         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
24554 }
24555
24556 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
24557         LDKInMemorySigner this_ptr_conv;
24558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24559         this_ptr_conv.is_owned = false;
24560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24561         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24562         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
24563         return ret_arr;
24564 }
24565
24566 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) {
24567         LDKInMemorySigner this_ptr_conv;
24568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24569         this_ptr_conv.is_owned = false;
24570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24571         LDKSecretKey val_ref;
24572         CHECK(val->arr_len == 32);
24573         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
24574         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
24575 }
24576
24577 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
24578         LDKInMemorySigner this_ptr_conv;
24579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24580         this_ptr_conv.is_owned = false;
24581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24582         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24583         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
24584         return ret_arr;
24585 }
24586
24587 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
24588         LDKInMemorySigner this_ptr_conv;
24589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24590         this_ptr_conv.is_owned = false;
24591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24592         LDKSecretKey val_ref;
24593         CHECK(val->arr_len == 32);
24594         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
24595         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
24596 }
24597
24598 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
24599         LDKInMemorySigner this_ptr_conv;
24600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24601         this_ptr_conv.is_owned = false;
24602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24603         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24604         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
24605         return ret_arr;
24606 }
24607
24608 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
24609         LDKInMemorySigner this_ptr_conv;
24610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24611         this_ptr_conv.is_owned = false;
24612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24613         LDKThirtyTwoBytes val_ref;
24614         CHECK(val->arr_len == 32);
24615         memcpy(val_ref.data, val->elems, 32); FREE(val);
24616         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
24617 }
24618
24619 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
24620         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
24621 uint32_t ret_ref = 0;
24622 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24623 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24624 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24625 ret_ref = (uintptr_t)ret_var.inner;
24626 if (ret_var.is_owned) {
24627         ret_ref |= 1;
24628 }
24629         return ret_ref;
24630 }
24631 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
24632         LDKInMemorySigner arg_conv;
24633         arg_conv.inner = (void*)(arg & (~1));
24634         arg_conv.is_owned = false;
24635         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24636         uint32_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
24637         return ret_conv;
24638 }
24639
24640 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint32_t orig) {
24641         LDKInMemorySigner orig_conv;
24642         orig_conv.inner = (void*)(orig & (~1));
24643         orig_conv.is_owned = false;
24644         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24645         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
24646         uint32_t ret_ref = 0;
24647         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24648         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24650         ret_ref = (uintptr_t)ret_var.inner;
24651         if (ret_var.is_owned) {
24652                 ret_ref |= 1;
24653         }
24654         return ret_ref;
24655 }
24656
24657 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) {
24658         LDKSecretKey node_secret_ref;
24659         CHECK(node_secret->arr_len == 32);
24660         memcpy(node_secret_ref.bytes, node_secret->elems, 32); FREE(node_secret);
24661         LDKSecretKey funding_key_ref;
24662         CHECK(funding_key->arr_len == 32);
24663         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
24664         LDKSecretKey revocation_base_key_ref;
24665         CHECK(revocation_base_key->arr_len == 32);
24666         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
24667         LDKSecretKey payment_key_ref;
24668         CHECK(payment_key->arr_len == 32);
24669         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
24670         LDKSecretKey delayed_payment_base_key_ref;
24671         CHECK(delayed_payment_base_key->arr_len == 32);
24672         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
24673         LDKSecretKey htlc_base_key_ref;
24674         CHECK(htlc_base_key->arr_len == 32);
24675         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
24676         LDKThirtyTwoBytes commitment_seed_ref;
24677         CHECK(commitment_seed->arr_len == 32);
24678         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
24679         LDKThirtyTwoBytes channel_keys_id_ref;
24680         CHECK(channel_keys_id->arr_len == 32);
24681         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
24682         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);
24683         uint32_t ret_ref = 0;
24684         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24685         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24687         ret_ref = (uintptr_t)ret_var.inner;
24688         if (ret_var.is_owned) {
24689                 ret_ref |= 1;
24690         }
24691         return ret_ref;
24692 }
24693
24694 uint32_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
24695         LDKInMemorySigner this_arg_conv;
24696         this_arg_conv.inner = (void*)(this_arg & (~1));
24697         this_arg_conv.is_owned = false;
24698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24699         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
24700         uint32_t ret_ref = 0;
24701         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24702         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24704         ret_ref = (uintptr_t)ret_var.inner;
24705         if (ret_var.is_owned) {
24706                 ret_ref |= 1;
24707         }
24708         return ret_ref;
24709 }
24710
24711 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
24712         LDKInMemorySigner this_arg_conv;
24713         this_arg_conv.inner = (void*)(this_arg & (~1));
24714         this_arg_conv.is_owned = false;
24715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24716         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
24717         return ret_conv;
24718 }
24719
24720 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
24721         LDKInMemorySigner this_arg_conv;
24722         this_arg_conv.inner = (void*)(this_arg & (~1));
24723         this_arg_conv.is_owned = false;
24724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24725         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
24726         return ret_conv;
24727 }
24728
24729 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
24730         LDKInMemorySigner this_arg_conv;
24731         this_arg_conv.inner = (void*)(this_arg & (~1));
24732         this_arg_conv.is_owned = false;
24733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24734         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
24735         return ret_conv;
24736 }
24737
24738 uint32_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
24739         LDKInMemorySigner this_arg_conv;
24740         this_arg_conv.inner = (void*)(this_arg & (~1));
24741         this_arg_conv.is_owned = false;
24742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24743         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
24744         uint32_t ret_ref = 0;
24745         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24746         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24748         ret_ref = (uintptr_t)ret_var.inner;
24749         if (ret_var.is_owned) {
24750                 ret_ref |= 1;
24751         }
24752         return ret_ref;
24753 }
24754
24755 uint32_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
24756         LDKInMemorySigner this_arg_conv;
24757         this_arg_conv.inner = (void*)(this_arg & (~1));
24758         this_arg_conv.is_owned = false;
24759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24760         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
24761         uint32_t ret_ref = 0;
24762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24765         ret_ref = (uintptr_t)ret_var.inner;
24766         if (ret_var.is_owned) {
24767                 ret_ref |= 1;
24768         }
24769         return ret_ref;
24770 }
24771
24772 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
24773         LDKInMemorySigner this_arg_conv;
24774         this_arg_conv.inner = (void*)(this_arg & (~1));
24775         this_arg_conv.is_owned = false;
24776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24777         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
24778         return ret_conv;
24779 }
24780
24781 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) {
24782         LDKInMemorySigner this_arg_conv;
24783         this_arg_conv.inner = (void*)(this_arg & (~1));
24784         this_arg_conv.is_owned = false;
24785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24786         LDKTransaction spend_tx_ref;
24787         spend_tx_ref.datalen = spend_tx->arr_len;
24788         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
24789         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
24790         spend_tx_ref.data_is_owned = true;
24791         LDKStaticPaymentOutputDescriptor descriptor_conv;
24792         descriptor_conv.inner = (void*)(descriptor & (~1));
24793         descriptor_conv.is_owned = false;
24794         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
24795         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
24796         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
24797         return (uint32_t)ret_conv;
24798 }
24799
24800 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) {
24801         LDKInMemorySigner this_arg_conv;
24802         this_arg_conv.inner = (void*)(this_arg & (~1));
24803         this_arg_conv.is_owned = false;
24804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24805         LDKTransaction spend_tx_ref;
24806         spend_tx_ref.datalen = spend_tx->arr_len;
24807         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
24808         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
24809         spend_tx_ref.data_is_owned = true;
24810         LDKDelayedPaymentOutputDescriptor descriptor_conv;
24811         descriptor_conv.inner = (void*)(descriptor & (~1));
24812         descriptor_conv.is_owned = false;
24813         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
24814         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
24815         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
24816         return (uint32_t)ret_conv;
24817 }
24818
24819 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
24820         LDKInMemorySigner this_arg_conv;
24821         this_arg_conv.inner = (void*)(this_arg & (~1));
24822         this_arg_conv.is_owned = false;
24823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24824         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
24825         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
24826         return (uint32_t)ret_ret;
24827 }
24828
24829 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
24830         LDKInMemorySigner this_arg_conv;
24831         this_arg_conv.inner = (void*)(this_arg & (~1));
24832         this_arg_conv.is_owned = false;
24833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24834         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
24835         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
24836         return (uint32_t)ret_ret;
24837 }
24838
24839 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint32_t obj) {
24840         LDKInMemorySigner obj_conv;
24841         obj_conv.inner = (void*)(obj & (~1));
24842         obj_conv.is_owned = false;
24843         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24844         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
24845         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24846         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24847         CVec_u8Z_free(ret_var);
24848         return ret_arr;
24849 }
24850
24851 uint32_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser, int8_tArray arg) {
24852         LDKu8slice ser_ref;
24853         ser_ref.datalen = ser->arr_len;
24854         ser_ref.data = ser->elems;
24855         LDKSecretKey arg_ref;
24856         CHECK(arg->arr_len == 32);
24857         memcpy(arg_ref.bytes, arg->elems, 32); FREE(arg);
24858         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
24859         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
24860         FREE(ser);
24861         return (uint32_t)ret_conv;
24862 }
24863
24864 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint32_t this_obj) {
24865         LDKKeysManager this_obj_conv;
24866         this_obj_conv.inner = (void*)(this_obj & (~1));
24867         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24869         KeysManager_free(this_obj_conv);
24870 }
24871
24872 uint32_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
24873         unsigned char seed_arr[32];
24874         CHECK(seed->arr_len == 32);
24875         memcpy(seed_arr, seed->elems, 32); FREE(seed);
24876         unsigned char (*seed_ref)[32] = &seed_arr;
24877         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
24878         uint32_t ret_ref = 0;
24879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24882         ret_ref = (uintptr_t)ret_var.inner;
24883         if (ret_var.is_owned) {
24884                 ret_ref |= 1;
24885         }
24886         return ret_ref;
24887 }
24888
24889 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) {
24890         LDKKeysManager this_arg_conv;
24891         this_arg_conv.inner = (void*)(this_arg & (~1));
24892         this_arg_conv.is_owned = false;
24893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24894         unsigned char params_arr[32];
24895         CHECK(params->arr_len == 32);
24896         memcpy(params_arr, params->elems, 32); FREE(params);
24897         unsigned char (*params_ref)[32] = &params_arr;
24898         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
24899         uint32_t ret_ref = 0;
24900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24903         ret_ref = (uintptr_t)ret_var.inner;
24904         if (ret_var.is_owned) {
24905                 ret_ref |= 1;
24906         }
24907         return ret_ref;
24908 }
24909
24910 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) {
24911         LDKKeysManager this_arg_conv;
24912         this_arg_conv.inner = (void*)(this_arg & (~1));
24913         this_arg_conv.is_owned = false;
24914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24915         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
24916         descriptors_constr.datalen = descriptors->arr_len;
24917         if (descriptors_constr.datalen > 0)
24918                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
24919         else
24920                 descriptors_constr.data = NULL;
24921         uint32_t* descriptors_vals = descriptors->elems;
24922         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
24923                 uint32_t descriptors_conv_27 = descriptors_vals[b];
24924                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
24925                 CHECK_ACCESS(descriptors_conv_27_ptr);
24926                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
24927                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
24928                 descriptors_constr.data[b] = descriptors_conv_27_conv;
24929         }
24930         FREE(descriptors);
24931         LDKCVec_TxOutZ outputs_constr;
24932         outputs_constr.datalen = outputs->arr_len;
24933         if (outputs_constr.datalen > 0)
24934                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
24935         else
24936                 outputs_constr.data = NULL;
24937         uint32_t* outputs_vals = outputs->elems;
24938         for (size_t h = 0; h < outputs_constr.datalen; h++) {
24939                 uint32_t outputs_conv_7 = outputs_vals[h];
24940                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
24941                 CHECK_ACCESS(outputs_conv_7_ptr);
24942                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
24943                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
24944                 outputs_constr.data[h] = outputs_conv_7_conv;
24945         }
24946         FREE(outputs);
24947         LDKCVec_u8Z change_destination_script_ref;
24948         change_destination_script_ref.datalen = change_destination_script->arr_len;
24949         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
24950         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
24951         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
24952         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
24953         return (uint32_t)ret_conv;
24954 }
24955
24956 uint32_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
24957         LDKKeysManager this_arg_conv;
24958         this_arg_conv.inner = (void*)(this_arg & (~1));
24959         this_arg_conv.is_owned = false;
24960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24961         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
24962         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
24963         return (uint32_t)ret_ret;
24964 }
24965
24966 void  __attribute__((export_name("TS_PhantomKeysManager_free"))) TS_PhantomKeysManager_free(uint32_t this_obj) {
24967         LDKPhantomKeysManager this_obj_conv;
24968         this_obj_conv.inner = (void*)(this_obj & (~1));
24969         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24971         PhantomKeysManager_free(this_obj_conv);
24972 }
24973
24974 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_as_KeysInterface"))) TS_PhantomKeysManager_as_KeysInterface(uint32_t this_arg) {
24975         LDKPhantomKeysManager this_arg_conv;
24976         this_arg_conv.inner = (void*)(this_arg & (~1));
24977         this_arg_conv.is_owned = false;
24978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24979         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
24980         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
24981         return (uint32_t)ret_ret;
24982 }
24983
24984 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) {
24985         unsigned char seed_arr[32];
24986         CHECK(seed->arr_len == 32);
24987         memcpy(seed_arr, seed->elems, 32); FREE(seed);
24988         unsigned char (*seed_ref)[32] = &seed_arr;
24989         unsigned char cross_node_seed_arr[32];
24990         CHECK(cross_node_seed->arr_len == 32);
24991         memcpy(cross_node_seed_arr, cross_node_seed->elems, 32); FREE(cross_node_seed);
24992         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
24993         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
24994         uint32_t ret_ref = 0;
24995         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24996         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24998         ret_ref = (uintptr_t)ret_var.inner;
24999         if (ret_var.is_owned) {
25000                 ret_ref |= 1;
25001         }
25002         return ret_ref;
25003 }
25004
25005 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) {
25006         LDKPhantomKeysManager this_arg_conv;
25007         this_arg_conv.inner = (void*)(this_arg & (~1));
25008         this_arg_conv.is_owned = false;
25009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25010         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
25011         descriptors_constr.datalen = descriptors->arr_len;
25012         if (descriptors_constr.datalen > 0)
25013                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
25014         else
25015                 descriptors_constr.data = NULL;
25016         uint32_t* descriptors_vals = descriptors->elems;
25017         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
25018                 uint32_t descriptors_conv_27 = descriptors_vals[b];
25019                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
25020                 CHECK_ACCESS(descriptors_conv_27_ptr);
25021                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
25022                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
25023                 descriptors_constr.data[b] = descriptors_conv_27_conv;
25024         }
25025         FREE(descriptors);
25026         LDKCVec_TxOutZ outputs_constr;
25027         outputs_constr.datalen = outputs->arr_len;
25028         if (outputs_constr.datalen > 0)
25029                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
25030         else
25031                 outputs_constr.data = NULL;
25032         uint32_t* outputs_vals = outputs->elems;
25033         for (size_t h = 0; h < outputs_constr.datalen; h++) {
25034                 uint32_t outputs_conv_7 = outputs_vals[h];
25035                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
25036                 CHECK_ACCESS(outputs_conv_7_ptr);
25037                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
25038                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
25039                 outputs_constr.data[h] = outputs_conv_7_conv;
25040         }
25041         FREE(outputs);
25042         LDKCVec_u8Z change_destination_script_ref;
25043         change_destination_script_ref.datalen = change_destination_script->arr_len;
25044         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
25045         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
25046         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
25047         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
25048         return (uint32_t)ret_conv;
25049 }
25050
25051 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) {
25052         LDKPhantomKeysManager this_arg_conv;
25053         this_arg_conv.inner = (void*)(this_arg & (~1));
25054         this_arg_conv.is_owned = false;
25055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25056         unsigned char params_arr[32];
25057         CHECK(params->arr_len == 32);
25058         memcpy(params_arr, params->elems, 32); FREE(params);
25059         unsigned char (*params_ref)[32] = &params_arr;
25060         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
25061         uint32_t ret_ref = 0;
25062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25065         ret_ref = (uintptr_t)ret_var.inner;
25066         if (ret_var.is_owned) {
25067                 ret_ref |= 1;
25068         }
25069         return ret_ref;
25070 }
25071
25072 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint32_t this_obj) {
25073         LDKChannelManager this_obj_conv;
25074         this_obj_conv.inner = (void*)(this_obj & (~1));
25075         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25077         ChannelManager_free(this_obj_conv);
25078 }
25079
25080 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint32_t this_obj) {
25081         LDKChainParameters this_obj_conv;
25082         this_obj_conv.inner = (void*)(this_obj & (~1));
25083         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25085         ChainParameters_free(this_obj_conv);
25086 }
25087
25088 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
25089         LDKChainParameters this_ptr_conv;
25090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25091         this_ptr_conv.is_owned = false;
25092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25093         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
25094         return ret_conv;
25095 }
25096
25097 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
25098         LDKChainParameters this_ptr_conv;
25099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25100         this_ptr_conv.is_owned = false;
25101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25102         LDKNetwork val_conv = LDKNetwork_from_js(val);
25103         ChainParameters_set_network(&this_ptr_conv, val_conv);
25104 }
25105
25106 uint32_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
25107         LDKChainParameters this_ptr_conv;
25108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25109         this_ptr_conv.is_owned = false;
25110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25111         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
25112         uint32_t ret_ref = 0;
25113         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25114         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25116         ret_ref = (uintptr_t)ret_var.inner;
25117         if (ret_var.is_owned) {
25118                 ret_ref |= 1;
25119         }
25120         return ret_ref;
25121 }
25122
25123 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
25124         LDKChainParameters this_ptr_conv;
25125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25126         this_ptr_conv.is_owned = false;
25127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25128         LDKBestBlock val_conv;
25129         val_conv.inner = (void*)(val & (~1));
25130         val_conv.is_owned = (val & 1) || (val == 0);
25131         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25132         val_conv = BestBlock_clone(&val_conv);
25133         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
25134 }
25135
25136 uint32_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
25137         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
25138         LDKBestBlock best_block_arg_conv;
25139         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
25140         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
25141         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
25142         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
25143         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
25144         uint32_t ret_ref = 0;
25145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25148         ret_ref = (uintptr_t)ret_var.inner;
25149         if (ret_var.is_owned) {
25150                 ret_ref |= 1;
25151         }
25152         return ret_ref;
25153 }
25154
25155 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
25156         LDKChainParameters ret_var = ChainParameters_clone(arg);
25157 uint32_t ret_ref = 0;
25158 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25159 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25160 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25161 ret_ref = (uintptr_t)ret_var.inner;
25162 if (ret_var.is_owned) {
25163         ret_ref |= 1;
25164 }
25165         return ret_ref;
25166 }
25167 uint32_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
25168         LDKChainParameters arg_conv;
25169         arg_conv.inner = (void*)(arg & (~1));
25170         arg_conv.is_owned = false;
25171         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25172         uint32_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
25173         return ret_conv;
25174 }
25175
25176 uint32_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint32_t orig) {
25177         LDKChainParameters orig_conv;
25178         orig_conv.inner = (void*)(orig & (~1));
25179         orig_conv.is_owned = false;
25180         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25181         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
25182         uint32_t ret_ref = 0;
25183         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25184         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25186         ret_ref = (uintptr_t)ret_var.inner;
25187         if (ret_var.is_owned) {
25188                 ret_ref |= 1;
25189         }
25190         return ret_ref;
25191 }
25192
25193 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
25194         LDKCounterpartyForwardingInfo this_obj_conv;
25195         this_obj_conv.inner = (void*)(this_obj & (~1));
25196         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25198         CounterpartyForwardingInfo_free(this_obj_conv);
25199 }
25200
25201 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
25202         LDKCounterpartyForwardingInfo this_ptr_conv;
25203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25204         this_ptr_conv.is_owned = false;
25205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25206         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
25207         return ret_conv;
25208 }
25209
25210 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
25211         LDKCounterpartyForwardingInfo this_ptr_conv;
25212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25213         this_ptr_conv.is_owned = false;
25214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25215         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
25216 }
25217
25218 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
25219         LDKCounterpartyForwardingInfo this_ptr_conv;
25220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25221         this_ptr_conv.is_owned = false;
25222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25223         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
25224         return ret_conv;
25225 }
25226
25227 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
25228         LDKCounterpartyForwardingInfo this_ptr_conv;
25229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25230         this_ptr_conv.is_owned = false;
25231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25232         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
25233 }
25234
25235 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
25236         LDKCounterpartyForwardingInfo this_ptr_conv;
25237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25238         this_ptr_conv.is_owned = false;
25239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25240         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
25241         return ret_conv;
25242 }
25243
25244 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
25245         LDKCounterpartyForwardingInfo this_ptr_conv;
25246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25247         this_ptr_conv.is_owned = false;
25248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25249         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
25250 }
25251
25252 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) {
25253         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
25254         uint32_t ret_ref = 0;
25255         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25256         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25258         ret_ref = (uintptr_t)ret_var.inner;
25259         if (ret_var.is_owned) {
25260                 ret_ref |= 1;
25261         }
25262         return ret_ref;
25263 }
25264
25265 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
25266         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
25267 uint32_t ret_ref = 0;
25268 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25269 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25270 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25271 ret_ref = (uintptr_t)ret_var.inner;
25272 if (ret_var.is_owned) {
25273         ret_ref |= 1;
25274 }
25275         return ret_ref;
25276 }
25277 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
25278         LDKCounterpartyForwardingInfo arg_conv;
25279         arg_conv.inner = (void*)(arg & (~1));
25280         arg_conv.is_owned = false;
25281         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25282         uint32_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
25283         return ret_conv;
25284 }
25285
25286 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
25287         LDKCounterpartyForwardingInfo orig_conv;
25288         orig_conv.inner = (void*)(orig & (~1));
25289         orig_conv.is_owned = false;
25290         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25291         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
25292         uint32_t ret_ref = 0;
25293         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25294         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25296         ret_ref = (uintptr_t)ret_var.inner;
25297         if (ret_var.is_owned) {
25298                 ret_ref |= 1;
25299         }
25300         return ret_ref;
25301 }
25302
25303 void  __attribute__((export_name("TS_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
25304         LDKChannelCounterparty this_obj_conv;
25305         this_obj_conv.inner = (void*)(this_obj & (~1));
25306         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25308         ChannelCounterparty_free(this_obj_conv);
25309 }
25310
25311 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
25312         LDKChannelCounterparty this_ptr_conv;
25313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25314         this_ptr_conv.is_owned = false;
25315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25316         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25317         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
25318         return ret_arr;
25319 }
25320
25321 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
25322         LDKChannelCounterparty this_ptr_conv;
25323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25324         this_ptr_conv.is_owned = false;
25325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25326         LDKPublicKey val_ref;
25327         CHECK(val->arr_len == 33);
25328         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25329         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
25330 }
25331
25332 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
25333         LDKChannelCounterparty this_ptr_conv;
25334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25335         this_ptr_conv.is_owned = false;
25336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25337         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
25338         uint32_t ret_ref = 0;
25339         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25340         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25342         ret_ref = (uintptr_t)ret_var.inner;
25343         if (ret_var.is_owned) {
25344                 ret_ref |= 1;
25345         }
25346         return ret_ref;
25347 }
25348
25349 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
25350         LDKChannelCounterparty this_ptr_conv;
25351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25352         this_ptr_conv.is_owned = false;
25353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25354         LDKInitFeatures val_conv;
25355         val_conv.inner = (void*)(val & (~1));
25356         val_conv.is_owned = (val & 1) || (val == 0);
25357         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25358         val_conv = InitFeatures_clone(&val_conv);
25359         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
25360 }
25361
25362 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
25363         LDKChannelCounterparty this_ptr_conv;
25364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25365         this_ptr_conv.is_owned = false;
25366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25367         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
25368         return ret_conv;
25369 }
25370
25371 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
25372         LDKChannelCounterparty this_ptr_conv;
25373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25374         this_ptr_conv.is_owned = false;
25375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25376         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
25377 }
25378
25379 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
25380         LDKChannelCounterparty this_ptr_conv;
25381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25382         this_ptr_conv.is_owned = false;
25383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25384         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
25385         uint32_t ret_ref = 0;
25386         if ((uintptr_t)ret_var.inner > 4096) {
25387                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25388                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25390                 ret_ref = (uintptr_t)ret_var.inner;
25391                 if (ret_var.is_owned) {
25392                         ret_ref |= 1;
25393                 }
25394         }
25395         return ret_ref;
25396 }
25397
25398 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
25399         LDKChannelCounterparty this_ptr_conv;
25400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25401         this_ptr_conv.is_owned = false;
25402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25403         LDKCounterpartyForwardingInfo val_conv;
25404         val_conv.inner = (void*)(val & (~1));
25405         val_conv.is_owned = (val & 1) || (val == 0);
25406         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25407         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
25408         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
25409 }
25410
25411 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_outbound_htlc_minimum_msat"))) TS_ChannelCounterparty_get_outbound_htlc_minimum_msat(uint32_t this_ptr) {
25412         LDKChannelCounterparty this_ptr_conv;
25413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25414         this_ptr_conv.is_owned = false;
25415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25416         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25417         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
25418         uint32_t ret_ref = (uintptr_t)ret_copy;
25419         return ret_ref;
25420 }
25421
25422 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) {
25423         LDKChannelCounterparty this_ptr_conv;
25424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25425         this_ptr_conv.is_owned = false;
25426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25427         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25428         CHECK_ACCESS(val_ptr);
25429         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25430         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25431         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
25432 }
25433
25434 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_outbound_htlc_maximum_msat"))) TS_ChannelCounterparty_get_outbound_htlc_maximum_msat(uint32_t this_ptr) {
25435         LDKChannelCounterparty this_ptr_conv;
25436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25437         this_ptr_conv.is_owned = false;
25438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25439         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25440         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
25441         uint32_t ret_ref = (uintptr_t)ret_copy;
25442         return ret_ref;
25443 }
25444
25445 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) {
25446         LDKChannelCounterparty this_ptr_conv;
25447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25448         this_ptr_conv.is_owned = false;
25449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25450         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25451         CHECK_ACCESS(val_ptr);
25452         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25453         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25454         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
25455 }
25456
25457 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) {
25458         LDKPublicKey node_id_arg_ref;
25459         CHECK(node_id_arg->arr_len == 33);
25460         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
25461         LDKInitFeatures features_arg_conv;
25462         features_arg_conv.inner = (void*)(features_arg & (~1));
25463         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
25464         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
25465         features_arg_conv = InitFeatures_clone(&features_arg_conv);
25466         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
25467         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
25468         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
25469         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
25470         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
25471         void* outbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1);
25472         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
25473         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
25474         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1));
25475         void* outbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1);
25476         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
25477         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
25478         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1));
25479         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);
25480         uint32_t ret_ref = 0;
25481         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25482         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25484         ret_ref = (uintptr_t)ret_var.inner;
25485         if (ret_var.is_owned) {
25486                 ret_ref |= 1;
25487         }
25488         return ret_ref;
25489 }
25490
25491 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
25492         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
25493 uint32_t ret_ref = 0;
25494 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25495 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25496 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25497 ret_ref = (uintptr_t)ret_var.inner;
25498 if (ret_var.is_owned) {
25499         ret_ref |= 1;
25500 }
25501         return ret_ref;
25502 }
25503 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
25504         LDKChannelCounterparty arg_conv;
25505         arg_conv.inner = (void*)(arg & (~1));
25506         arg_conv.is_owned = false;
25507         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25508         uint32_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
25509         return ret_conv;
25510 }
25511
25512 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint32_t orig) {
25513         LDKChannelCounterparty orig_conv;
25514         orig_conv.inner = (void*)(orig & (~1));
25515         orig_conv.is_owned = false;
25516         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25517         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
25518         uint32_t ret_ref = 0;
25519         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25520         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25522         ret_ref = (uintptr_t)ret_var.inner;
25523         if (ret_var.is_owned) {
25524                 ret_ref |= 1;
25525         }
25526         return ret_ref;
25527 }
25528
25529 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint32_t this_obj) {
25530         LDKChannelDetails this_obj_conv;
25531         this_obj_conv.inner = (void*)(this_obj & (~1));
25532         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25534         ChannelDetails_free(this_obj_conv);
25535 }
25536
25537 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
25538         LDKChannelDetails this_ptr_conv;
25539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25540         this_ptr_conv.is_owned = false;
25541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25542         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25543         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
25544         return ret_arr;
25545 }
25546
25547 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25548         LDKChannelDetails this_ptr_conv;
25549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25550         this_ptr_conv.is_owned = false;
25551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25552         LDKThirtyTwoBytes val_ref;
25553         CHECK(val->arr_len == 32);
25554         memcpy(val_ref.data, val->elems, 32); FREE(val);
25555         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
25556 }
25557
25558 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
25559         LDKChannelDetails this_ptr_conv;
25560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25561         this_ptr_conv.is_owned = false;
25562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25563         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
25564         uint32_t ret_ref = 0;
25565         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25566         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25568         ret_ref = (uintptr_t)ret_var.inner;
25569         if (ret_var.is_owned) {
25570                 ret_ref |= 1;
25571         }
25572         return ret_ref;
25573 }
25574
25575 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
25576         LDKChannelDetails this_ptr_conv;
25577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25578         this_ptr_conv.is_owned = false;
25579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25580         LDKChannelCounterparty val_conv;
25581         val_conv.inner = (void*)(val & (~1));
25582         val_conv.is_owned = (val & 1) || (val == 0);
25583         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25584         val_conv = ChannelCounterparty_clone(&val_conv);
25585         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
25586 }
25587
25588 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
25589         LDKChannelDetails this_ptr_conv;
25590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25591         this_ptr_conv.is_owned = false;
25592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25593         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
25594         uint32_t ret_ref = 0;
25595         if ((uintptr_t)ret_var.inner > 4096) {
25596                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25597                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25599                 ret_ref = (uintptr_t)ret_var.inner;
25600                 if (ret_var.is_owned) {
25601                         ret_ref |= 1;
25602                 }
25603         }
25604         return ret_ref;
25605 }
25606
25607 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
25608         LDKChannelDetails this_ptr_conv;
25609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25610         this_ptr_conv.is_owned = false;
25611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25612         LDKOutPoint val_conv;
25613         val_conv.inner = (void*)(val & (~1));
25614         val_conv.is_owned = (val & 1) || (val == 0);
25615         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25616         val_conv = OutPoint_clone(&val_conv);
25617         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
25618 }
25619
25620 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_channel_type"))) TS_ChannelDetails_get_channel_type(uint32_t this_ptr) {
25621         LDKChannelDetails this_ptr_conv;
25622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25623         this_ptr_conv.is_owned = false;
25624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25625         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
25626         uint32_t ret_ref = 0;
25627         if ((uintptr_t)ret_var.inner > 4096) {
25628                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25629                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25631                 ret_ref = (uintptr_t)ret_var.inner;
25632                 if (ret_var.is_owned) {
25633                         ret_ref |= 1;
25634                 }
25635         }
25636         return ret_ref;
25637 }
25638
25639 void  __attribute__((export_name("TS_ChannelDetails_set_channel_type"))) TS_ChannelDetails_set_channel_type(uint32_t this_ptr, uint32_t val) {
25640         LDKChannelDetails this_ptr_conv;
25641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25642         this_ptr_conv.is_owned = false;
25643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25644         LDKChannelTypeFeatures val_conv;
25645         val_conv.inner = (void*)(val & (~1));
25646         val_conv.is_owned = (val & 1) || (val == 0);
25647         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25648         val_conv = ChannelTypeFeatures_clone(&val_conv);
25649         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
25650 }
25651
25652 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
25653         LDKChannelDetails this_ptr_conv;
25654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25655         this_ptr_conv.is_owned = false;
25656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25657         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25658         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
25659         uint32_t ret_ref = (uintptr_t)ret_copy;
25660         return ret_ref;
25661 }
25662
25663 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
25664         LDKChannelDetails this_ptr_conv;
25665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25666         this_ptr_conv.is_owned = false;
25667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25668         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25669         CHECK_ACCESS(val_ptr);
25670         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25671         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25672         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
25673 }
25674
25675 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_scid_alias"))) TS_ChannelDetails_get_outbound_scid_alias(uint32_t this_ptr) {
25676         LDKChannelDetails this_ptr_conv;
25677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25678         this_ptr_conv.is_owned = false;
25679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25680         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25681         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
25682         uint32_t ret_ref = (uintptr_t)ret_copy;
25683         return ret_ref;
25684 }
25685
25686 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_scid_alias"))) TS_ChannelDetails_set_outbound_scid_alias(uint32_t this_ptr, uint32_t val) {
25687         LDKChannelDetails this_ptr_conv;
25688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25689         this_ptr_conv.is_owned = false;
25690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25691         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25692         CHECK_ACCESS(val_ptr);
25693         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25694         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25695         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
25696 }
25697
25698 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_scid_alias"))) TS_ChannelDetails_get_inbound_scid_alias(uint32_t this_ptr) {
25699         LDKChannelDetails this_ptr_conv;
25700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25701         this_ptr_conv.is_owned = false;
25702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25703         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25704         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
25705         uint32_t ret_ref = (uintptr_t)ret_copy;
25706         return ret_ref;
25707 }
25708
25709 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_scid_alias"))) TS_ChannelDetails_set_inbound_scid_alias(uint32_t this_ptr, uint32_t val) {
25710         LDKChannelDetails this_ptr_conv;
25711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25712         this_ptr_conv.is_owned = false;
25713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25714         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25715         CHECK_ACCESS(val_ptr);
25716         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25717         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25718         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
25719 }
25720
25721 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
25722         LDKChannelDetails this_ptr_conv;
25723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25724         this_ptr_conv.is_owned = false;
25725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25726         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
25727         return ret_conv;
25728 }
25729
25730 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
25731         LDKChannelDetails this_ptr_conv;
25732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25733         this_ptr_conv.is_owned = false;
25734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25735         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
25736 }
25737
25738 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
25739         LDKChannelDetails this_ptr_conv;
25740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25741         this_ptr_conv.is_owned = false;
25742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25743         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25744         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
25745         uint32_t ret_ref = (uintptr_t)ret_copy;
25746         return ret_ref;
25747 }
25748
25749 void  __attribute__((export_name("TS_ChannelDetails_set_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
25750         LDKChannelDetails this_ptr_conv;
25751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25752         this_ptr_conv.is_owned = false;
25753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25754         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25755         CHECK_ACCESS(val_ptr);
25756         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25757         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25758         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
25759 }
25760
25761 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
25762         LDKChannelDetails this_ptr_conv;
25763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25764         this_ptr_conv.is_owned = false;
25765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25766         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
25767         return ret_conv;
25768 }
25769
25770 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
25771         LDKChannelDetails this_ptr_conv;
25772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25773         this_ptr_conv.is_owned = false;
25774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25775         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
25776 }
25777
25778 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
25779         LDKChannelDetails this_ptr_conv;
25780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25781         this_ptr_conv.is_owned = false;
25782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25783         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
25784         return ret_conv;
25785 }
25786
25787 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
25788         LDKChannelDetails this_ptr_conv;
25789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25790         this_ptr_conv.is_owned = false;
25791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25792         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
25793 }
25794
25795 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
25796         LDKChannelDetails this_ptr_conv;
25797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25798         this_ptr_conv.is_owned = false;
25799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25800         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
25801         return ret_conv;
25802 }
25803
25804 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
25805         LDKChannelDetails this_ptr_conv;
25806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25807         this_ptr_conv.is_owned = false;
25808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25809         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
25810 }
25811
25812 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) {
25813         LDKChannelDetails this_ptr_conv;
25814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25815         this_ptr_conv.is_owned = false;
25816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25817         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
25818         return ret_conv;
25819 }
25820
25821 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) {
25822         LDKChannelDetails this_ptr_conv;
25823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25824         this_ptr_conv.is_owned = false;
25825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25826         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
25827 }
25828
25829 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
25830         LDKChannelDetails this_ptr_conv;
25831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25832         this_ptr_conv.is_owned = false;
25833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25834         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
25835         return ret_conv;
25836 }
25837
25838 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
25839         LDKChannelDetails this_ptr_conv;
25840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25841         this_ptr_conv.is_owned = false;
25842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25843         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
25844 }
25845
25846 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
25847         LDKChannelDetails this_ptr_conv;
25848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25849         this_ptr_conv.is_owned = false;
25850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25851         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
25852         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
25853         uint32_t ret_ref = (uintptr_t)ret_copy;
25854         return ret_ref;
25855 }
25856
25857 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
25858         LDKChannelDetails this_ptr_conv;
25859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25860         this_ptr_conv.is_owned = false;
25861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25862         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25863         CHECK_ACCESS(val_ptr);
25864         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
25865         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
25866         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
25867 }
25868
25869 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
25870         LDKChannelDetails this_ptr_conv;
25871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25872         this_ptr_conv.is_owned = false;
25873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25874         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
25875         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
25876         uint32_t ret_ref = (uintptr_t)ret_copy;
25877         return ret_ref;
25878 }
25879
25880 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) {
25881         LDKChannelDetails this_ptr_conv;
25882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25883         this_ptr_conv.is_owned = false;
25884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25885         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25886         CHECK_ACCESS(val_ptr);
25887         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
25888         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
25889         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
25890 }
25891
25892 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
25893         LDKChannelDetails this_ptr_conv;
25894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25895         this_ptr_conv.is_owned = false;
25896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25897         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
25898         return ret_conv;
25899 }
25900
25901 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
25902         LDKChannelDetails this_ptr_conv;
25903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25904         this_ptr_conv.is_owned = false;
25905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25906         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
25907 }
25908
25909 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_channel_ready"))) TS_ChannelDetails_get_is_channel_ready(uint32_t this_ptr) {
25910         LDKChannelDetails this_ptr_conv;
25911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25912         this_ptr_conv.is_owned = false;
25913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25914         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
25915         return ret_conv;
25916 }
25917
25918 void  __attribute__((export_name("TS_ChannelDetails_set_is_channel_ready"))) TS_ChannelDetails_set_is_channel_ready(uint32_t this_ptr, jboolean val) {
25919         LDKChannelDetails this_ptr_conv;
25920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25921         this_ptr_conv.is_owned = false;
25922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25923         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
25924 }
25925
25926 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
25927         LDKChannelDetails this_ptr_conv;
25928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25929         this_ptr_conv.is_owned = false;
25930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25931         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
25932         return ret_conv;
25933 }
25934
25935 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
25936         LDKChannelDetails this_ptr_conv;
25937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25938         this_ptr_conv.is_owned = false;
25939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25940         ChannelDetails_set_is_usable(&this_ptr_conv, val);
25941 }
25942
25943 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
25944         LDKChannelDetails this_ptr_conv;
25945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25946         this_ptr_conv.is_owned = false;
25947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25948         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
25949         return ret_conv;
25950 }
25951
25952 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
25953         LDKChannelDetails this_ptr_conv;
25954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25955         this_ptr_conv.is_owned = false;
25956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25957         ChannelDetails_set_is_public(&this_ptr_conv, val);
25958 }
25959
25960 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_htlc_minimum_msat"))) TS_ChannelDetails_get_inbound_htlc_minimum_msat(uint32_t this_ptr) {
25961         LDKChannelDetails this_ptr_conv;
25962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25963         this_ptr_conv.is_owned = false;
25964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25965         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25966         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
25967         uint32_t ret_ref = (uintptr_t)ret_copy;
25968         return ret_ref;
25969 }
25970
25971 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) {
25972         LDKChannelDetails this_ptr_conv;
25973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25974         this_ptr_conv.is_owned = false;
25975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25976         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25977         CHECK_ACCESS(val_ptr);
25978         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25979         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25980         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
25981 }
25982
25983 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_htlc_maximum_msat"))) TS_ChannelDetails_get_inbound_htlc_maximum_msat(uint32_t this_ptr) {
25984         LDKChannelDetails this_ptr_conv;
25985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25986         this_ptr_conv.is_owned = false;
25987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25988         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25989         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
25990         uint32_t ret_ref = (uintptr_t)ret_copy;
25991         return ret_ref;
25992 }
25993
25994 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) {
25995         LDKChannelDetails this_ptr_conv;
25996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25997         this_ptr_conv.is_owned = false;
25998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25999         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26000         CHECK_ACCESS(val_ptr);
26001         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26002         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26003         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
26004 }
26005
26006 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_config"))) TS_ChannelDetails_get_config(uint32_t this_ptr) {
26007         LDKChannelDetails this_ptr_conv;
26008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26009         this_ptr_conv.is_owned = false;
26010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26011         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
26012         uint32_t ret_ref = 0;
26013         if ((uintptr_t)ret_var.inner > 4096) {
26014                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26015                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26017                 ret_ref = (uintptr_t)ret_var.inner;
26018                 if (ret_var.is_owned) {
26019                         ret_ref |= 1;
26020                 }
26021         }
26022         return ret_ref;
26023 }
26024
26025 void  __attribute__((export_name("TS_ChannelDetails_set_config"))) TS_ChannelDetails_set_config(uint32_t this_ptr, uint32_t val) {
26026         LDKChannelDetails this_ptr_conv;
26027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26028         this_ptr_conv.is_owned = false;
26029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26030         LDKChannelConfig val_conv;
26031         val_conv.inner = (void*)(val & (~1));
26032         val_conv.is_owned = (val & 1) || (val == 0);
26033         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26034         val_conv = ChannelConfig_clone(&val_conv);
26035         ChannelDetails_set_config(&this_ptr_conv, val_conv);
26036 }
26037
26038 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) {
26039         LDKThirtyTwoBytes channel_id_arg_ref;
26040         CHECK(channel_id_arg->arr_len == 32);
26041         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
26042         LDKChannelCounterparty counterparty_arg_conv;
26043         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
26044         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
26045         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
26046         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
26047         LDKOutPoint funding_txo_arg_conv;
26048         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
26049         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
26050         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
26051         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
26052         LDKChannelTypeFeatures channel_type_arg_conv;
26053         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
26054         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
26055         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
26056         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
26057         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
26058         CHECK_ACCESS(short_channel_id_arg_ptr);
26059         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
26060         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
26061         void* outbound_scid_alias_arg_ptr = (void*)(((uintptr_t)outbound_scid_alias_arg) & ~1);
26062         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
26063         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
26064         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_scid_alias_arg) & ~1));
26065         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
26066         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
26067         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
26068         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
26069         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
26070         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
26071         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
26072         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
26073         CHECK_ACCESS(confirmations_required_arg_ptr);
26074         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
26075         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
26076         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
26077         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
26078         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
26079         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
26080         void* inbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1);
26081         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
26082         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
26083         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1));
26084         void* inbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1);
26085         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
26086         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
26087         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1));
26088         LDKChannelConfig config_arg_conv;
26089         config_arg_conv.inner = (void*)(config_arg & (~1));
26090         config_arg_conv.is_owned = (config_arg & 1) || (config_arg == 0);
26091         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
26092         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
26093         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);
26094         uint32_t ret_ref = 0;
26095         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26096         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26098         ret_ref = (uintptr_t)ret_var.inner;
26099         if (ret_var.is_owned) {
26100                 ret_ref |= 1;
26101         }
26102         return ret_ref;
26103 }
26104
26105 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
26106         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
26107 uint32_t ret_ref = 0;
26108 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26109 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26110 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26111 ret_ref = (uintptr_t)ret_var.inner;
26112 if (ret_var.is_owned) {
26113         ret_ref |= 1;
26114 }
26115         return ret_ref;
26116 }
26117 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
26118         LDKChannelDetails arg_conv;
26119         arg_conv.inner = (void*)(arg & (~1));
26120         arg_conv.is_owned = false;
26121         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26122         uint32_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
26123         return ret_conv;
26124 }
26125
26126 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint32_t orig) {
26127         LDKChannelDetails orig_conv;
26128         orig_conv.inner = (void*)(orig & (~1));
26129         orig_conv.is_owned = false;
26130         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26131         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
26132         uint32_t ret_ref = 0;
26133         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26134         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26136         ret_ref = (uintptr_t)ret_var.inner;
26137         if (ret_var.is_owned) {
26138                 ret_ref |= 1;
26139         }
26140         return ret_ref;
26141 }
26142
26143 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_payment_scid"))) TS_ChannelDetails_get_inbound_payment_scid(uint32_t this_arg) {
26144         LDKChannelDetails this_arg_conv;
26145         this_arg_conv.inner = (void*)(this_arg & (~1));
26146         this_arg_conv.is_owned = false;
26147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26148         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26149         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
26150         uint32_t ret_ref = (uintptr_t)ret_copy;
26151         return ret_ref;
26152 }
26153
26154 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_payment_scid"))) TS_ChannelDetails_get_outbound_payment_scid(uint32_t this_arg) {
26155         LDKChannelDetails this_arg_conv;
26156         this_arg_conv.inner = (void*)(this_arg & (~1));
26157         this_arg_conv.is_owned = false;
26158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26159         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26160         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
26161         uint32_t ret_ref = (uintptr_t)ret_copy;
26162         return ret_ref;
26163 }
26164
26165 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
26166         if ((this_ptr & 1) != 0) return;
26167         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26168         CHECK_ACCESS(this_ptr_ptr);
26169         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
26170         FREE((void*)this_ptr);
26171         PaymentSendFailure_free(this_ptr_conv);
26172 }
26173
26174 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
26175         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26176         *ret_copy = PaymentSendFailure_clone(arg);
26177 uint32_t ret_ref = (uintptr_t)ret_copy;
26178         return ret_ref;
26179 }
26180 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
26181         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
26182         uint32_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
26183         return ret_conv;
26184 }
26185
26186 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint32_t orig) {
26187         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
26188         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26189         *ret_copy = PaymentSendFailure_clone(orig_conv);
26190         uint32_t ret_ref = (uintptr_t)ret_copy;
26191         return ret_ref;
26192 }
26193
26194 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
26195         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
26196         CHECK_ACCESS(a_ptr);
26197         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
26198         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
26199         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26200         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
26201         uint32_t ret_ref = (uintptr_t)ret_copy;
26202         return ret_ref;
26203 }
26204
26205 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
26206         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
26207         a_constr.datalen = a->arr_len;
26208         if (a_constr.datalen > 0)
26209                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
26210         else
26211                 a_constr.data = NULL;
26212         uint32_t* a_vals = a->elems;
26213         for (size_t w = 0; w < a_constr.datalen; w++) {
26214                 uint32_t a_conv_22 = a_vals[w];
26215                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
26216                 CHECK_ACCESS(a_conv_22_ptr);
26217                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
26218                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
26219                 a_constr.data[w] = a_conv_22_conv;
26220         }
26221         FREE(a);
26222         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26223         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
26224         uint32_t ret_ref = (uintptr_t)ret_copy;
26225         return ret_ref;
26226 }
26227
26228 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
26229         LDKCVec_APIErrorZ a_constr;
26230         a_constr.datalen = a->arr_len;
26231         if (a_constr.datalen > 0)
26232                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
26233         else
26234                 a_constr.data = NULL;
26235         uint32_t* a_vals = a->elems;
26236         for (size_t k = 0; k < a_constr.datalen; k++) {
26237                 uint32_t a_conv_10 = a_vals[k];
26238                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
26239                 CHECK_ACCESS(a_conv_10_ptr);
26240                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
26241                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
26242                 a_constr.data[k] = a_conv_10_conv;
26243         }
26244         FREE(a);
26245         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26246         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
26247         uint32_t ret_ref = (uintptr_t)ret_copy;
26248         return ret_ref;
26249 }
26250
26251 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) {
26252         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
26253         results_constr.datalen = results->arr_len;
26254         if (results_constr.datalen > 0)
26255                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
26256         else
26257                 results_constr.data = NULL;
26258         uint32_t* results_vals = results->elems;
26259         for (size_t w = 0; w < results_constr.datalen; w++) {
26260                 uint32_t results_conv_22 = results_vals[w];
26261                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
26262                 CHECK_ACCESS(results_conv_22_ptr);
26263                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
26264                 results_constr.data[w] = results_conv_22_conv;
26265         }
26266         FREE(results);
26267         LDKRouteParameters failed_paths_retry_conv;
26268         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
26269         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
26270         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
26271         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
26272         LDKThirtyTwoBytes payment_id_ref;
26273         CHECK(payment_id->arr_len == 32);
26274         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
26275         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26276         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
26277         uint32_t ret_ref = (uintptr_t)ret_copy;
26278         return ret_ref;
26279 }
26280
26281 void  __attribute__((export_name("TS_PhantomRouteHints_free"))) TS_PhantomRouteHints_free(uint32_t this_obj) {
26282         LDKPhantomRouteHints this_obj_conv;
26283         this_obj_conv.inner = (void*)(this_obj & (~1));
26284         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26286         PhantomRouteHints_free(this_obj_conv);
26287 }
26288
26289 uint32_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_channels"))) TS_PhantomRouteHints_get_channels(uint32_t this_ptr) {
26290         LDKPhantomRouteHints this_ptr_conv;
26291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26292         this_ptr_conv.is_owned = false;
26293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26294         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
26295         uint32_tArray ret_arr = NULL;
26296         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
26297         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
26298         for (size_t q = 0; q < ret_var.datalen; q++) {
26299                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
26300                 uint32_t ret_conv_16_ref = 0;
26301                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26302                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26303                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
26304                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
26305                 if (ret_conv_16_var.is_owned) {
26306                         ret_conv_16_ref |= 1;
26307                 }
26308                 ret_arr_ptr[q] = ret_conv_16_ref;
26309         }
26310         
26311         FREE(ret_var.data);
26312         return ret_arr;
26313 }
26314
26315 void  __attribute__((export_name("TS_PhantomRouteHints_set_channels"))) TS_PhantomRouteHints_set_channels(uint32_t this_ptr, uint32_tArray val) {
26316         LDKPhantomRouteHints this_ptr_conv;
26317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26318         this_ptr_conv.is_owned = false;
26319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26320         LDKCVec_ChannelDetailsZ val_constr;
26321         val_constr.datalen = val->arr_len;
26322         if (val_constr.datalen > 0)
26323                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
26324         else
26325                 val_constr.data = NULL;
26326         uint32_t* val_vals = val->elems;
26327         for (size_t q = 0; q < val_constr.datalen; q++) {
26328                 uint32_t val_conv_16 = val_vals[q];
26329                 LDKChannelDetails val_conv_16_conv;
26330                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
26331                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
26332                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
26333                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
26334                 val_constr.data[q] = val_conv_16_conv;
26335         }
26336         FREE(val);
26337         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
26338 }
26339
26340 int64_t  __attribute__((export_name("TS_PhantomRouteHints_get_phantom_scid"))) TS_PhantomRouteHints_get_phantom_scid(uint32_t this_ptr) {
26341         LDKPhantomRouteHints this_ptr_conv;
26342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26343         this_ptr_conv.is_owned = false;
26344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26345         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
26346         return ret_conv;
26347 }
26348
26349 void  __attribute__((export_name("TS_PhantomRouteHints_set_phantom_scid"))) TS_PhantomRouteHints_set_phantom_scid(uint32_t this_ptr, int64_t val) {
26350         LDKPhantomRouteHints this_ptr_conv;
26351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26352         this_ptr_conv.is_owned = false;
26353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26354         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
26355 }
26356
26357 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_real_node_pubkey"))) TS_PhantomRouteHints_get_real_node_pubkey(uint32_t this_ptr) {
26358         LDKPhantomRouteHints this_ptr_conv;
26359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26360         this_ptr_conv.is_owned = false;
26361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26362         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26363         memcpy(ret_arr->elems, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form, 33);
26364         return ret_arr;
26365 }
26366
26367 void  __attribute__((export_name("TS_PhantomRouteHints_set_real_node_pubkey"))) TS_PhantomRouteHints_set_real_node_pubkey(uint32_t this_ptr, int8_tArray val) {
26368         LDKPhantomRouteHints this_ptr_conv;
26369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26370         this_ptr_conv.is_owned = false;
26371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26372         LDKPublicKey val_ref;
26373         CHECK(val->arr_len == 33);
26374         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26375         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
26376 }
26377
26378 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) {
26379         LDKCVec_ChannelDetailsZ channels_arg_constr;
26380         channels_arg_constr.datalen = channels_arg->arr_len;
26381         if (channels_arg_constr.datalen > 0)
26382                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
26383         else
26384                 channels_arg_constr.data = NULL;
26385         uint32_t* channels_arg_vals = channels_arg->elems;
26386         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
26387                 uint32_t channels_arg_conv_16 = channels_arg_vals[q];
26388                 LDKChannelDetails channels_arg_conv_16_conv;
26389                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
26390                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
26391                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
26392                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
26393                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
26394         }
26395         FREE(channels_arg);
26396         LDKPublicKey real_node_pubkey_arg_ref;
26397         CHECK(real_node_pubkey_arg->arr_len == 33);
26398         memcpy(real_node_pubkey_arg_ref.compressed_form, real_node_pubkey_arg->elems, 33); FREE(real_node_pubkey_arg);
26399         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
26400         uint32_t ret_ref = 0;
26401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26404         ret_ref = (uintptr_t)ret_var.inner;
26405         if (ret_var.is_owned) {
26406                 ret_ref |= 1;
26407         }
26408         return ret_ref;
26409 }
26410
26411 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
26412         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
26413 uint32_t ret_ref = 0;
26414 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26415 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26416 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26417 ret_ref = (uintptr_t)ret_var.inner;
26418 if (ret_var.is_owned) {
26419         ret_ref |= 1;
26420 }
26421         return ret_ref;
26422 }
26423 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone_ptr"))) TS_PhantomRouteHints_clone_ptr(uint32_t arg) {
26424         LDKPhantomRouteHints arg_conv;
26425         arg_conv.inner = (void*)(arg & (~1));
26426         arg_conv.is_owned = false;
26427         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26428         uint32_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
26429         return ret_conv;
26430 }
26431
26432 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone"))) TS_PhantomRouteHints_clone(uint32_t orig) {
26433         LDKPhantomRouteHints orig_conv;
26434         orig_conv.inner = (void*)(orig & (~1));
26435         orig_conv.is_owned = false;
26436         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26437         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
26438         uint32_t ret_ref = 0;
26439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26442         ret_ref = (uintptr_t)ret_var.inner;
26443         if (ret_var.is_owned) {
26444                 ret_ref |= 1;
26445         }
26446         return ret_ref;
26447 }
26448
26449 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) {
26450         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
26451         CHECK_ACCESS(fee_est_ptr);
26452         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
26453         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
26454                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26455                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
26456         }
26457         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
26458         CHECK_ACCESS(chain_monitor_ptr);
26459         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
26460         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
26461                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26462                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
26463         }
26464         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
26465         CHECK_ACCESS(tx_broadcaster_ptr);
26466         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
26467         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26468                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26469                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
26470         }
26471         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26472         CHECK_ACCESS(logger_ptr);
26473         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26474         if (logger_conv.free == LDKLogger_JCalls_free) {
26475                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26476                 LDKLogger_JCalls_cloned(&logger_conv);
26477         }
26478         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
26479         CHECK_ACCESS(keys_manager_ptr);
26480         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
26481         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26482                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26483                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
26484         }
26485         LDKUserConfig config_conv;
26486         config_conv.inner = (void*)(config & (~1));
26487         config_conv.is_owned = (config & 1) || (config == 0);
26488         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
26489         config_conv = UserConfig_clone(&config_conv);
26490         LDKChainParameters params_conv;
26491         params_conv.inner = (void*)(params & (~1));
26492         params_conv.is_owned = (params & 1) || (params == 0);
26493         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
26494         params_conv = ChainParameters_clone(&params_conv);
26495         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
26496         uint32_t ret_ref = 0;
26497         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26498         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26500         ret_ref = (uintptr_t)ret_var.inner;
26501         if (ret_var.is_owned) {
26502                 ret_ref |= 1;
26503         }
26504         return ret_ref;
26505 }
26506
26507 uint32_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
26508         LDKChannelManager this_arg_conv;
26509         this_arg_conv.inner = (void*)(this_arg & (~1));
26510         this_arg_conv.is_owned = false;
26511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26512         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
26513         uint32_t ret_ref = 0;
26514         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26515         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26517         ret_ref = (uintptr_t)ret_var.inner;
26518         if (ret_var.is_owned) {
26519                 ret_ref |= 1;
26520         }
26521         return ret_ref;
26522 }
26523
26524 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) {
26525         LDKChannelManager this_arg_conv;
26526         this_arg_conv.inner = (void*)(this_arg & (~1));
26527         this_arg_conv.is_owned = false;
26528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26529         LDKPublicKey their_network_key_ref;
26530         CHECK(their_network_key->arr_len == 33);
26531         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
26532         LDKUserConfig override_config_conv;
26533         override_config_conv.inner = (void*)(override_config & (~1));
26534         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
26535         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
26536         override_config_conv = UserConfig_clone(&override_config_conv);
26537         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
26538         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
26539         return (uint32_t)ret_conv;
26540 }
26541
26542 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
26543         LDKChannelManager this_arg_conv;
26544         this_arg_conv.inner = (void*)(this_arg & (~1));
26545         this_arg_conv.is_owned = false;
26546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26547         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
26548         uint32_tArray ret_arr = NULL;
26549         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
26550         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
26551         for (size_t q = 0; q < ret_var.datalen; q++) {
26552                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
26553                 uint32_t ret_conv_16_ref = 0;
26554                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26555                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26556                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
26557                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
26558                 if (ret_conv_16_var.is_owned) {
26559                         ret_conv_16_ref |= 1;
26560                 }
26561                 ret_arr_ptr[q] = ret_conv_16_ref;
26562         }
26563         
26564         FREE(ret_var.data);
26565         return ret_arr;
26566 }
26567
26568 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
26569         LDKChannelManager this_arg_conv;
26570         this_arg_conv.inner = (void*)(this_arg & (~1));
26571         this_arg_conv.is_owned = false;
26572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26573         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
26574         uint32_tArray ret_arr = NULL;
26575         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
26576         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
26577         for (size_t q = 0; q < ret_var.datalen; q++) {
26578                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
26579                 uint32_t ret_conv_16_ref = 0;
26580                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26581                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26582                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
26583                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
26584                 if (ret_conv_16_var.is_owned) {
26585                         ret_conv_16_ref |= 1;
26586                 }
26587                 ret_arr_ptr[q] = ret_conv_16_ref;
26588         }
26589         
26590         FREE(ret_var.data);
26591         return ret_arr;
26592 }
26593
26594 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) {
26595         LDKChannelManager this_arg_conv;
26596         this_arg_conv.inner = (void*)(this_arg & (~1));
26597         this_arg_conv.is_owned = false;
26598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26599         unsigned char channel_id_arr[32];
26600         CHECK(channel_id->arr_len == 32);
26601         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
26602         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
26603         LDKPublicKey counterparty_node_id_ref;
26604         CHECK(counterparty_node_id->arr_len == 33);
26605         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26606         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26607         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
26608         return (uint32_t)ret_conv;
26609 }
26610
26611 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) {
26612         LDKChannelManager this_arg_conv;
26613         this_arg_conv.inner = (void*)(this_arg & (~1));
26614         this_arg_conv.is_owned = false;
26615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26616         unsigned char channel_id_arr[32];
26617         CHECK(channel_id->arr_len == 32);
26618         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
26619         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
26620         LDKPublicKey counterparty_node_id_ref;
26621         CHECK(counterparty_node_id->arr_len == 33);
26622         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26623         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26624         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
26625         return (uint32_t)ret_conv;
26626 }
26627
26628 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) {
26629         LDKChannelManager this_arg_conv;
26630         this_arg_conv.inner = (void*)(this_arg & (~1));
26631         this_arg_conv.is_owned = false;
26632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26633         unsigned char channel_id_arr[32];
26634         CHECK(channel_id->arr_len == 32);
26635         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
26636         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
26637         LDKPublicKey counterparty_node_id_ref;
26638         CHECK(counterparty_node_id->arr_len == 33);
26639         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26640         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26641         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
26642         return (uint32_t)ret_conv;
26643 }
26644
26645 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) {
26646         LDKChannelManager this_arg_conv;
26647         this_arg_conv.inner = (void*)(this_arg & (~1));
26648         this_arg_conv.is_owned = false;
26649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26650         unsigned char channel_id_arr[32];
26651         CHECK(channel_id->arr_len == 32);
26652         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
26653         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
26654         LDKPublicKey counterparty_node_id_ref;
26655         CHECK(counterparty_node_id->arr_len == 33);
26656         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26657         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26658         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
26659         return (uint32_t)ret_conv;
26660 }
26661
26662 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) {
26663         LDKChannelManager this_arg_conv;
26664         this_arg_conv.inner = (void*)(this_arg & (~1));
26665         this_arg_conv.is_owned = false;
26666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26667         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
26668 }
26669
26670 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) {
26671         LDKChannelManager this_arg_conv;
26672         this_arg_conv.inner = (void*)(this_arg & (~1));
26673         this_arg_conv.is_owned = false;
26674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26675         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
26676 }
26677
26678 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) {
26679         LDKChannelManager this_arg_conv;
26680         this_arg_conv.inner = (void*)(this_arg & (~1));
26681         this_arg_conv.is_owned = false;
26682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26683         LDKRoute route_conv;
26684         route_conv.inner = (void*)(route & (~1));
26685         route_conv.is_owned = false;
26686         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
26687         LDKThirtyTwoBytes payment_hash_ref;
26688         CHECK(payment_hash->arr_len == 32);
26689         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
26690         LDKThirtyTwoBytes payment_secret_ref;
26691         CHECK(payment_secret->arr_len == 32);
26692         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
26693         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
26694         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
26695         return (uint32_t)ret_conv;
26696 }
26697
26698 uint32_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
26699         LDKChannelManager this_arg_conv;
26700         this_arg_conv.inner = (void*)(this_arg & (~1));
26701         this_arg_conv.is_owned = false;
26702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26703         LDKRoute route_conv;
26704         route_conv.inner = (void*)(route & (~1));
26705         route_conv.is_owned = false;
26706         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
26707         LDKThirtyTwoBytes payment_id_ref;
26708         CHECK(payment_id->arr_len == 32);
26709         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
26710         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
26711         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
26712         return (uint32_t)ret_conv;
26713 }
26714
26715 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
26716         LDKChannelManager this_arg_conv;
26717         this_arg_conv.inner = (void*)(this_arg & (~1));
26718         this_arg_conv.is_owned = false;
26719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26720         LDKThirtyTwoBytes payment_id_ref;
26721         CHECK(payment_id->arr_len == 32);
26722         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
26723         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
26724 }
26725
26726 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) {
26727         LDKChannelManager this_arg_conv;
26728         this_arg_conv.inner = (void*)(this_arg & (~1));
26729         this_arg_conv.is_owned = false;
26730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26731         LDKRoute route_conv;
26732         route_conv.inner = (void*)(route & (~1));
26733         route_conv.is_owned = false;
26734         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
26735         LDKThirtyTwoBytes payment_preimage_ref;
26736         CHECK(payment_preimage->arr_len == 32);
26737         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
26738         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
26739         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
26740         return (uint32_t)ret_conv;
26741 }
26742
26743 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) {
26744         LDKChannelManager this_arg_conv;
26745         this_arg_conv.inner = (void*)(this_arg & (~1));
26746         this_arg_conv.is_owned = false;
26747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26748         unsigned char temporary_channel_id_arr[32];
26749         CHECK(temporary_channel_id->arr_len == 32);
26750         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
26751         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
26752         LDKPublicKey counterparty_node_id_ref;
26753         CHECK(counterparty_node_id->arr_len == 33);
26754         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26755         LDKTransaction funding_transaction_ref;
26756         funding_transaction_ref.datalen = funding_transaction->arr_len;
26757         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
26758         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
26759         funding_transaction_ref.data_is_owned = true;
26760         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26761         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
26762         return (uint32_t)ret_conv;
26763 }
26764
26765 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) {
26766         LDKChannelManager this_arg_conv;
26767         this_arg_conv.inner = (void*)(this_arg & (~1));
26768         this_arg_conv.is_owned = false;
26769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26770         LDKThreeBytes rgb_ref;
26771         CHECK(rgb->arr_len == 3);
26772         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
26773         LDKThirtyTwoBytes alias_ref;
26774         CHECK(alias->arr_len == 32);
26775         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
26776         LDKCVec_NetAddressZ addresses_constr;
26777         addresses_constr.datalen = addresses->arr_len;
26778         if (addresses_constr.datalen > 0)
26779                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
26780         else
26781                 addresses_constr.data = NULL;
26782         uint32_t* addresses_vals = addresses->elems;
26783         for (size_t m = 0; m < addresses_constr.datalen; m++) {
26784                 uint32_t addresses_conv_12 = addresses_vals[m];
26785                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
26786                 CHECK_ACCESS(addresses_conv_12_ptr);
26787                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
26788                 addresses_constr.data[m] = addresses_conv_12_conv;
26789         }
26790         FREE(addresses);
26791         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
26792 }
26793
26794 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) {
26795         LDKChannelManager this_arg_conv;
26796         this_arg_conv.inner = (void*)(this_arg & (~1));
26797         this_arg_conv.is_owned = false;
26798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26799         LDKPublicKey counterparty_node_id_ref;
26800         CHECK(counterparty_node_id->arr_len == 33);
26801         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26802         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
26803         channel_ids_constr.datalen = channel_ids->arr_len;
26804         if (channel_ids_constr.datalen > 0)
26805                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
26806         else
26807                 channel_ids_constr.data = NULL;
26808         int8_tArray* channel_ids_vals = (void*) channel_ids->elems;
26809         for (size_t m = 0; m < channel_ids_constr.datalen; m++) {
26810                 int8_tArray channel_ids_conv_12 = channel_ids_vals[m];
26811                 LDKThirtyTwoBytes channel_ids_conv_12_ref;
26812                 CHECK(channel_ids_conv_12->arr_len == 32);
26813                 memcpy(channel_ids_conv_12_ref.data, channel_ids_conv_12->elems, 32); FREE(channel_ids_conv_12);
26814                 channel_ids_constr.data[m] = channel_ids_conv_12_ref;
26815         }
26816         FREE(channel_ids);
26817         LDKChannelConfig config_conv;
26818         config_conv.inner = (void*)(config & (~1));
26819         config_conv.is_owned = false;
26820         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
26821         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26822         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
26823         return (uint32_t)ret_conv;
26824 }
26825
26826 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
26827         LDKChannelManager this_arg_conv;
26828         this_arg_conv.inner = (void*)(this_arg & (~1));
26829         this_arg_conv.is_owned = false;
26830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26831         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
26832 }
26833
26834 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
26835         LDKChannelManager this_arg_conv;
26836         this_arg_conv.inner = (void*)(this_arg & (~1));
26837         this_arg_conv.is_owned = false;
26838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26839         ChannelManager_timer_tick_occurred(&this_arg_conv);
26840 }
26841
26842 void  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
26843         LDKChannelManager this_arg_conv;
26844         this_arg_conv.inner = (void*)(this_arg & (~1));
26845         this_arg_conv.is_owned = false;
26846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26847         unsigned char payment_hash_arr[32];
26848         CHECK(payment_hash->arr_len == 32);
26849         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
26850         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
26851         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
26852 }
26853
26854 void  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
26855         LDKChannelManager this_arg_conv;
26856         this_arg_conv.inner = (void*)(this_arg & (~1));
26857         this_arg_conv.is_owned = false;
26858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26859         LDKThirtyTwoBytes payment_preimage_ref;
26860         CHECK(payment_preimage->arr_len == 32);
26861         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
26862         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
26863 }
26864
26865 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
26866         LDKChannelManager this_arg_conv;
26867         this_arg_conv.inner = (void*)(this_arg & (~1));
26868         this_arg_conv.is_owned = false;
26869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26870         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26871         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
26872         return ret_arr;
26873 }
26874
26875 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) {
26876         LDKChannelManager this_arg_conv;
26877         this_arg_conv.inner = (void*)(this_arg & (~1));
26878         this_arg_conv.is_owned = false;
26879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26880         unsigned char temporary_channel_id_arr[32];
26881         CHECK(temporary_channel_id->arr_len == 32);
26882         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
26883         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
26884         LDKPublicKey counterparty_node_id_ref;
26885         CHECK(counterparty_node_id->arr_len == 33);
26886         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26887         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26888         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
26889         return (uint32_t)ret_conv;
26890 }
26891
26892 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) {
26893         LDKChannelManager this_arg_conv;
26894         this_arg_conv.inner = (void*)(this_arg & (~1));
26895         this_arg_conv.is_owned = false;
26896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26897         unsigned char temporary_channel_id_arr[32];
26898         CHECK(temporary_channel_id->arr_len == 32);
26899         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
26900         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
26901         LDKPublicKey counterparty_node_id_ref;
26902         CHECK(counterparty_node_id->arr_len == 33);
26903         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26904         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26905         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
26906         return (uint32_t)ret_conv;
26907 }
26908
26909 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) {
26910         LDKChannelManager this_arg_conv;
26911         this_arg_conv.inner = (void*)(this_arg & (~1));
26912         this_arg_conv.is_owned = false;
26913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26914         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
26915         CHECK_ACCESS(min_value_msat_ptr);
26916         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
26917         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
26918         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
26919         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
26920         return (uint32_t)ret_conv;
26921 }
26922
26923 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) {
26924         LDKChannelManager this_arg_conv;
26925         this_arg_conv.inner = (void*)(this_arg & (~1));
26926         this_arg_conv.is_owned = false;
26927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26928         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
26929         CHECK_ACCESS(min_value_msat_ptr);
26930         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
26931         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
26932         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
26933         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
26934         return (uint32_t)ret_conv;
26935 }
26936
26937 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) {
26938         LDKChannelManager this_arg_conv;
26939         this_arg_conv.inner = (void*)(this_arg & (~1));
26940         this_arg_conv.is_owned = false;
26941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26942         LDKThirtyTwoBytes payment_hash_ref;
26943         CHECK(payment_hash->arr_len == 32);
26944         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
26945         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
26946         CHECK_ACCESS(min_value_msat_ptr);
26947         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
26948         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
26949         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
26950         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
26951         return (uint32_t)ret_conv;
26952 }
26953
26954 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) {
26955         LDKChannelManager this_arg_conv;
26956         this_arg_conv.inner = (void*)(this_arg & (~1));
26957         this_arg_conv.is_owned = false;
26958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26959         LDKThirtyTwoBytes payment_hash_ref;
26960         CHECK(payment_hash->arr_len == 32);
26961         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
26962         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
26963         CHECK_ACCESS(min_value_msat_ptr);
26964         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
26965         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
26966         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
26967         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
26968         return (uint32_t)ret_conv;
26969 }
26970
26971 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) {
26972         LDKChannelManager this_arg_conv;
26973         this_arg_conv.inner = (void*)(this_arg & (~1));
26974         this_arg_conv.is_owned = false;
26975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26976         LDKThirtyTwoBytes payment_hash_ref;
26977         CHECK(payment_hash->arr_len == 32);
26978         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
26979         LDKThirtyTwoBytes payment_secret_ref;
26980         CHECK(payment_secret->arr_len == 32);
26981         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
26982         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
26983         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
26984         return (uint32_t)ret_conv;
26985 }
26986
26987 int64_t  __attribute__((export_name("TS_ChannelManager_get_phantom_scid"))) TS_ChannelManager_get_phantom_scid(uint32_t this_arg) {
26988         LDKChannelManager this_arg_conv;
26989         this_arg_conv.inner = (void*)(this_arg & (~1));
26990         this_arg_conv.is_owned = false;
26991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26992         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
26993         return ret_conv;
26994 }
26995
26996 uint32_t  __attribute__((export_name("TS_ChannelManager_get_phantom_route_hints"))) TS_ChannelManager_get_phantom_route_hints(uint32_t this_arg) {
26997         LDKChannelManager this_arg_conv;
26998         this_arg_conv.inner = (void*)(this_arg & (~1));
26999         this_arg_conv.is_owned = false;
27000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27001         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
27002         uint32_t ret_ref = 0;
27003         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27004         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27006         ret_ref = (uintptr_t)ret_var.inner;
27007         if (ret_var.is_owned) {
27008                 ret_ref |= 1;
27009         }
27010         return ret_ref;
27011 }
27012
27013 uint32_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
27014         LDKChannelManager this_arg_conv;
27015         this_arg_conv.inner = (void*)(this_arg & (~1));
27016         this_arg_conv.is_owned = false;
27017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27018         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
27019         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
27020         return (uint32_t)ret_ret;
27021 }
27022
27023 uint32_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
27024         LDKChannelManager this_arg_conv;
27025         this_arg_conv.inner = (void*)(this_arg & (~1));
27026         this_arg_conv.is_owned = false;
27027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27028         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
27029         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
27030         return (uint32_t)ret_ret;
27031 }
27032
27033 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
27034         LDKChannelManager this_arg_conv;
27035         this_arg_conv.inner = (void*)(this_arg & (~1));
27036         this_arg_conv.is_owned = false;
27037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27038         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
27039         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
27040         return (uint32_t)ret_ret;
27041 }
27042
27043 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
27044         LDKChannelManager this_arg_conv;
27045         this_arg_conv.inner = (void*)(this_arg & (~1));
27046         this_arg_conv.is_owned = false;
27047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27048         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
27049         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
27050         return (uint32_t)ret_ret;
27051 }
27052
27053 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
27054         LDKChannelManager this_arg_conv;
27055         this_arg_conv.inner = (void*)(this_arg & (~1));
27056         this_arg_conv.is_owned = false;
27057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27058         ChannelManager_await_persistable_update(&this_arg_conv);
27059 }
27060
27061 uint32_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
27062         LDKChannelManager this_arg_conv;
27063         this_arg_conv.inner = (void*)(this_arg & (~1));
27064         this_arg_conv.is_owned = false;
27065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27066         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
27067         uint32_t ret_ref = 0;
27068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27071         ret_ref = (uintptr_t)ret_var.inner;
27072         if (ret_var.is_owned) {
27073                 ret_ref |= 1;
27074         }
27075         return ret_ref;
27076 }
27077
27078 uint32_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
27079         LDKChannelManager this_arg_conv;
27080         this_arg_conv.inner = (void*)(this_arg & (~1));
27081         this_arg_conv.is_owned = false;
27082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27083         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
27084         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
27085         return (uint32_t)ret_ret;
27086 }
27087
27088 int8_tArray  __attribute__((export_name("TS_CounterpartyForwardingInfo_write"))) TS_CounterpartyForwardingInfo_write(uint32_t obj) {
27089         LDKCounterpartyForwardingInfo obj_conv;
27090         obj_conv.inner = (void*)(obj & (~1));
27091         obj_conv.is_owned = false;
27092         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27093         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
27094         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27095         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27096         CVec_u8Z_free(ret_var);
27097         return ret_arr;
27098 }
27099
27100 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_read"))) TS_CounterpartyForwardingInfo_read(int8_tArray ser) {
27101         LDKu8slice ser_ref;
27102         ser_ref.datalen = ser->arr_len;
27103         ser_ref.data = ser->elems;
27104         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
27105         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
27106         FREE(ser);
27107         return (uint32_t)ret_conv;
27108 }
27109
27110 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_write"))) TS_ChannelCounterparty_write(uint32_t obj) {
27111         LDKChannelCounterparty obj_conv;
27112         obj_conv.inner = (void*)(obj & (~1));
27113         obj_conv.is_owned = false;
27114         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27115         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
27116         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27117         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27118         CVec_u8Z_free(ret_var);
27119         return ret_arr;
27120 }
27121
27122 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_read"))) TS_ChannelCounterparty_read(int8_tArray ser) {
27123         LDKu8slice ser_ref;
27124         ser_ref.datalen = ser->arr_len;
27125         ser_ref.data = ser->elems;
27126         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
27127         *ret_conv = ChannelCounterparty_read(ser_ref);
27128         FREE(ser);
27129         return (uint32_t)ret_conv;
27130 }
27131
27132 int8_tArray  __attribute__((export_name("TS_ChannelDetails_write"))) TS_ChannelDetails_write(uint32_t obj) {
27133         LDKChannelDetails obj_conv;
27134         obj_conv.inner = (void*)(obj & (~1));
27135         obj_conv.is_owned = false;
27136         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27137         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
27138         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27139         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27140         CVec_u8Z_free(ret_var);
27141         return ret_arr;
27142 }
27143
27144 uint32_t  __attribute__((export_name("TS_ChannelDetails_read"))) TS_ChannelDetails_read(int8_tArray ser) {
27145         LDKu8slice ser_ref;
27146         ser_ref.datalen = ser->arr_len;
27147         ser_ref.data = ser->elems;
27148         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
27149         *ret_conv = ChannelDetails_read(ser_ref);
27150         FREE(ser);
27151         return (uint32_t)ret_conv;
27152 }
27153
27154 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_write"))) TS_PhantomRouteHints_write(uint32_t obj) {
27155         LDKPhantomRouteHints obj_conv;
27156         obj_conv.inner = (void*)(obj & (~1));
27157         obj_conv.is_owned = false;
27158         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27159         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
27160         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27161         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27162         CVec_u8Z_free(ret_var);
27163         return ret_arr;
27164 }
27165
27166 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_read"))) TS_PhantomRouteHints_read(int8_tArray ser) {
27167         LDKu8slice ser_ref;
27168         ser_ref.datalen = ser->arr_len;
27169         ser_ref.data = ser->elems;
27170         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
27171         *ret_conv = PhantomRouteHints_read(ser_ref);
27172         FREE(ser);
27173         return (uint32_t)ret_conv;
27174 }
27175
27176 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint32_t obj) {
27177         LDKChannelManager obj_conv;
27178         obj_conv.inner = (void*)(obj & (~1));
27179         obj_conv.is_owned = false;
27180         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27181         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
27182         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27183         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27184         CVec_u8Z_free(ret_var);
27185         return ret_arr;
27186 }
27187
27188 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
27189         LDKChannelManagerReadArgs this_obj_conv;
27190         this_obj_conv.inner = (void*)(this_obj & (~1));
27191         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27193         ChannelManagerReadArgs_free(this_obj_conv);
27194 }
27195
27196 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
27197         LDKChannelManagerReadArgs this_ptr_conv;
27198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27199         this_ptr_conv.is_owned = false;
27200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27201         // WARNING: This object doesn't live past this scope, needs clone!
27202         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
27203         return ret_ret;
27204 }
27205
27206 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
27207         LDKChannelManagerReadArgs this_ptr_conv;
27208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27209         this_ptr_conv.is_owned = false;
27210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27211         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27212         CHECK_ACCESS(val_ptr);
27213         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
27214         if (val_conv.free == LDKKeysInterface_JCalls_free) {
27215                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27216                 LDKKeysInterface_JCalls_cloned(&val_conv);
27217         }
27218         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
27219 }
27220
27221 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
27222         LDKChannelManagerReadArgs this_ptr_conv;
27223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27224         this_ptr_conv.is_owned = false;
27225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27226         // WARNING: This object doesn't live past this scope, needs clone!
27227         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
27228         return ret_ret;
27229 }
27230
27231 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
27232         LDKChannelManagerReadArgs this_ptr_conv;
27233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27234         this_ptr_conv.is_owned = false;
27235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27236         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27237         CHECK_ACCESS(val_ptr);
27238         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
27239         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
27240                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27241                 LDKFeeEstimator_JCalls_cloned(&val_conv);
27242         }
27243         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
27244 }
27245
27246 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
27247         LDKChannelManagerReadArgs this_ptr_conv;
27248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27249         this_ptr_conv.is_owned = false;
27250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27251         // WARNING: This object doesn't live past this scope, needs clone!
27252         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
27253         return ret_ret;
27254 }
27255
27256 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
27257         LDKChannelManagerReadArgs this_ptr_conv;
27258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27259         this_ptr_conv.is_owned = false;
27260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27261         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27262         CHECK_ACCESS(val_ptr);
27263         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
27264         if (val_conv.free == LDKWatch_JCalls_free) {
27265                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27266                 LDKWatch_JCalls_cloned(&val_conv);
27267         }
27268         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
27269 }
27270
27271 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
27272         LDKChannelManagerReadArgs this_ptr_conv;
27273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27274         this_ptr_conv.is_owned = false;
27275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27276         // WARNING: This object doesn't live past this scope, needs clone!
27277         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
27278         return ret_ret;
27279 }
27280
27281 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
27282         LDKChannelManagerReadArgs this_ptr_conv;
27283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27284         this_ptr_conv.is_owned = false;
27285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27286         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27287         CHECK_ACCESS(val_ptr);
27288         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
27289         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
27290                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27291                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
27292         }
27293         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
27294 }
27295
27296 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
27297         LDKChannelManagerReadArgs this_ptr_conv;
27298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27299         this_ptr_conv.is_owned = false;
27300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27301         // WARNING: This object doesn't live past this scope, needs clone!
27302         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
27303         return ret_ret;
27304 }
27305
27306 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
27307         LDKChannelManagerReadArgs this_ptr_conv;
27308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27309         this_ptr_conv.is_owned = false;
27310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27311         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27312         CHECK_ACCESS(val_ptr);
27313         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
27314         if (val_conv.free == LDKLogger_JCalls_free) {
27315                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27316                 LDKLogger_JCalls_cloned(&val_conv);
27317         }
27318         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
27319 }
27320
27321 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
27322         LDKChannelManagerReadArgs this_ptr_conv;
27323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27324         this_ptr_conv.is_owned = false;
27325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27326         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
27327         uint32_t ret_ref = 0;
27328         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27329         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27331         ret_ref = (uintptr_t)ret_var.inner;
27332         if (ret_var.is_owned) {
27333                 ret_ref |= 1;
27334         }
27335         return ret_ref;
27336 }
27337
27338 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
27339         LDKChannelManagerReadArgs this_ptr_conv;
27340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27341         this_ptr_conv.is_owned = false;
27342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27343         LDKUserConfig val_conv;
27344         val_conv.inner = (void*)(val & (~1));
27345         val_conv.is_owned = (val & 1) || (val == 0);
27346         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27347         val_conv = UserConfig_clone(&val_conv);
27348         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
27349 }
27350
27351 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) {
27352         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
27353         CHECK_ACCESS(keys_manager_ptr);
27354         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
27355         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
27356                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27357                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
27358         }
27359         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27360         CHECK_ACCESS(fee_estimator_ptr);
27361         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27362         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27363                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27364                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27365         }
27366         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
27367         CHECK_ACCESS(chain_monitor_ptr);
27368         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
27369         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
27370                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27371                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
27372         }
27373         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
27374         CHECK_ACCESS(tx_broadcaster_ptr);
27375         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
27376         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27377                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27378                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
27379         }
27380         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27381         CHECK_ACCESS(logger_ptr);
27382         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27383         if (logger_conv.free == LDKLogger_JCalls_free) {
27384                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27385                 LDKLogger_JCalls_cloned(&logger_conv);
27386         }
27387         LDKUserConfig default_config_conv;
27388         default_config_conv.inner = (void*)(default_config & (~1));
27389         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
27390         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
27391         default_config_conv = UserConfig_clone(&default_config_conv);
27392         LDKCVec_ChannelMonitorZ channel_monitors_constr;
27393         channel_monitors_constr.datalen = channel_monitors->arr_len;
27394         if (channel_monitors_constr.datalen > 0)
27395                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
27396         else
27397                 channel_monitors_constr.data = NULL;
27398         uint32_t* channel_monitors_vals = channel_monitors->elems;
27399         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
27400                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
27401                 LDKChannelMonitor channel_monitors_conv_16_conv;
27402                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
27403                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
27404                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
27405                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
27406         }
27407         FREE(channel_monitors);
27408         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);
27409         uint32_t ret_ref = 0;
27410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27413         ret_ref = (uintptr_t)ret_var.inner;
27414         if (ret_var.is_owned) {
27415                 ret_ref |= 1;
27416         }
27417         return ret_ref;
27418 }
27419
27420 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
27421         LDKu8slice ser_ref;
27422         ser_ref.datalen = ser->arr_len;
27423         ser_ref.data = ser->elems;
27424         LDKChannelManagerReadArgs arg_conv;
27425         arg_conv.inner = (void*)(arg & (~1));
27426         arg_conv.is_owned = (arg & 1) || (arg == 0);
27427         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27428         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
27429         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
27430         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
27431         FREE(ser);
27432         return (uint32_t)ret_conv;
27433 }
27434
27435 void  __attribute__((export_name("TS_ExpandedKey_free"))) TS_ExpandedKey_free(uint32_t this_obj) {
27436         LDKExpandedKey this_obj_conv;
27437         this_obj_conv.inner = (void*)(this_obj & (~1));
27438         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27440         ExpandedKey_free(this_obj_conv);
27441 }
27442
27443 uint32_t  __attribute__((export_name("TS_ExpandedKey_new"))) TS_ExpandedKey_new(int8_tArray key_material) {
27444         unsigned char key_material_arr[32];
27445         CHECK(key_material->arr_len == 32);
27446         memcpy(key_material_arr, key_material->elems, 32); FREE(key_material);
27447         unsigned char (*key_material_ref)[32] = &key_material_arr;
27448         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
27449         uint32_t ret_ref = 0;
27450         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27451         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27452         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27453         ret_ref = (uintptr_t)ret_var.inner;
27454         if (ret_var.is_owned) {
27455                 ret_ref |= 1;
27456         }
27457         return ret_ref;
27458 }
27459
27460 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) {
27461         LDKExpandedKey keys_conv;
27462         keys_conv.inner = (void*)(keys & (~1));
27463         keys_conv.is_owned = false;
27464         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
27465         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27466         CHECK_ACCESS(min_value_msat_ptr);
27467         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27468         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27469         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
27470         if (!(keys_manager & 1)) { CHECK_ACCESS(keys_manager_ptr); }
27471         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
27472         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
27473         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
27474         return (uint32_t)ret_conv;
27475 }
27476
27477 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) {
27478         LDKExpandedKey keys_conv;
27479         keys_conv.inner = (void*)(keys & (~1));
27480         keys_conv.is_owned = false;
27481         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
27482         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27483         CHECK_ACCESS(min_value_msat_ptr);
27484         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27485         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27486         LDKThirtyTwoBytes payment_hash_ref;
27487         CHECK(payment_hash->arr_len == 32);
27488         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27489         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
27490         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
27491         return (uint32_t)ret_conv;
27492 }
27493
27494 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint32_t this_obj) {
27495         LDKDecodeError this_obj_conv;
27496         this_obj_conv.inner = (void*)(this_obj & (~1));
27497         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27499         DecodeError_free(this_obj_conv);
27500 }
27501
27502 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
27503         LDKDecodeError ret_var = DecodeError_clone(arg);
27504 uint32_t ret_ref = 0;
27505 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27506 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27507 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27508 ret_ref = (uintptr_t)ret_var.inner;
27509 if (ret_var.is_owned) {
27510         ret_ref |= 1;
27511 }
27512         return ret_ref;
27513 }
27514 uint32_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint32_t arg) {
27515         LDKDecodeError arg_conv;
27516         arg_conv.inner = (void*)(arg & (~1));
27517         arg_conv.is_owned = false;
27518         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27519         uint32_t ret_conv = DecodeError_clone_ptr(&arg_conv);
27520         return ret_conv;
27521 }
27522
27523 uint32_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint32_t orig) {
27524         LDKDecodeError orig_conv;
27525         orig_conv.inner = (void*)(orig & (~1));
27526         orig_conv.is_owned = false;
27527         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27528         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
27529         uint32_t ret_ref = 0;
27530         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27531         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27533         ret_ref = (uintptr_t)ret_var.inner;
27534         if (ret_var.is_owned) {
27535                 ret_ref |= 1;
27536         }
27537         return ret_ref;
27538 }
27539
27540 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint32_t this_obj) {
27541         LDKInit this_obj_conv;
27542         this_obj_conv.inner = (void*)(this_obj & (~1));
27543         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27545         Init_free(this_obj_conv);
27546 }
27547
27548 uint32_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint32_t this_ptr) {
27549         LDKInit this_ptr_conv;
27550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27551         this_ptr_conv.is_owned = false;
27552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27553         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
27554         uint32_t ret_ref = 0;
27555         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27556         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27558         ret_ref = (uintptr_t)ret_var.inner;
27559         if (ret_var.is_owned) {
27560                 ret_ref |= 1;
27561         }
27562         return ret_ref;
27563 }
27564
27565 void  __attribute__((export_name("TS_Init_set_features"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
27566         LDKInit this_ptr_conv;
27567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27568         this_ptr_conv.is_owned = false;
27569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27570         LDKInitFeatures val_conv;
27571         val_conv.inner = (void*)(val & (~1));
27572         val_conv.is_owned = (val & 1) || (val == 0);
27573         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27574         val_conv = InitFeatures_clone(&val_conv);
27575         Init_set_features(&this_ptr_conv, val_conv);
27576 }
27577
27578 uint32_t  __attribute__((export_name("TS_Init_get_remote_network_address"))) TS_Init_get_remote_network_address(uint32_t this_ptr) {
27579         LDKInit this_ptr_conv;
27580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27581         this_ptr_conv.is_owned = false;
27582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27583         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
27584         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
27585         uint32_t ret_ref = (uintptr_t)ret_copy;
27586         return ret_ref;
27587 }
27588
27589 void  __attribute__((export_name("TS_Init_set_remote_network_address"))) TS_Init_set_remote_network_address(uint32_t this_ptr, uint32_t val) {
27590         LDKInit this_ptr_conv;
27591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27592         this_ptr_conv.is_owned = false;
27593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27594         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27595         CHECK_ACCESS(val_ptr);
27596         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
27597         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
27598         Init_set_remote_network_address(&this_ptr_conv, val_conv);
27599 }
27600
27601 uint32_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint32_t features_arg, uint32_t remote_network_address_arg) {
27602         LDKInitFeatures features_arg_conv;
27603         features_arg_conv.inner = (void*)(features_arg & (~1));
27604         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
27605         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
27606         features_arg_conv = InitFeatures_clone(&features_arg_conv);
27607         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
27608         CHECK_ACCESS(remote_network_address_arg_ptr);
27609         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
27610         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
27611         uint32_t ret_ref = 0;
27612         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27613         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27615         ret_ref = (uintptr_t)ret_var.inner;
27616         if (ret_var.is_owned) {
27617                 ret_ref |= 1;
27618         }
27619         return ret_ref;
27620 }
27621
27622 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
27623         LDKInit ret_var = Init_clone(arg);
27624 uint32_t ret_ref = 0;
27625 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27626 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27627 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27628 ret_ref = (uintptr_t)ret_var.inner;
27629 if (ret_var.is_owned) {
27630         ret_ref |= 1;
27631 }
27632         return ret_ref;
27633 }
27634 uint32_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint32_t arg) {
27635         LDKInit arg_conv;
27636         arg_conv.inner = (void*)(arg & (~1));
27637         arg_conv.is_owned = false;
27638         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27639         uint32_t ret_conv = Init_clone_ptr(&arg_conv);
27640         return ret_conv;
27641 }
27642
27643 uint32_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint32_t orig) {
27644         LDKInit orig_conv;
27645         orig_conv.inner = (void*)(orig & (~1));
27646         orig_conv.is_owned = false;
27647         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27648         LDKInit ret_var = Init_clone(&orig_conv);
27649         uint32_t ret_ref = 0;
27650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27653         ret_ref = (uintptr_t)ret_var.inner;
27654         if (ret_var.is_owned) {
27655                 ret_ref |= 1;
27656         }
27657         return ret_ref;
27658 }
27659
27660 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint32_t this_obj) {
27661         LDKErrorMessage this_obj_conv;
27662         this_obj_conv.inner = (void*)(this_obj & (~1));
27663         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27665         ErrorMessage_free(this_obj_conv);
27666 }
27667
27668 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
27669         LDKErrorMessage this_ptr_conv;
27670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27671         this_ptr_conv.is_owned = false;
27672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27673         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27674         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
27675         return ret_arr;
27676 }
27677
27678 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27679         LDKErrorMessage this_ptr_conv;
27680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27681         this_ptr_conv.is_owned = false;
27682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27683         LDKThirtyTwoBytes val_ref;
27684         CHECK(val->arr_len == 32);
27685         memcpy(val_ref.data, val->elems, 32); FREE(val);
27686         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
27687 }
27688
27689 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
27690         LDKErrorMessage this_ptr_conv;
27691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27692         this_ptr_conv.is_owned = false;
27693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27694         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
27695         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27696         Str_free(ret_str);
27697         return ret_conv;
27698 }
27699
27700 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
27701         LDKErrorMessage this_ptr_conv;
27702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27703         this_ptr_conv.is_owned = false;
27704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27705         LDKStr val_conv = str_ref_to_owned_c(val);
27706         ErrorMessage_set_data(&this_ptr_conv, val_conv);
27707 }
27708
27709 uint32_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
27710         LDKThirtyTwoBytes channel_id_arg_ref;
27711         CHECK(channel_id_arg->arr_len == 32);
27712         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27713         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
27714         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
27715         uint32_t ret_ref = 0;
27716         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27717         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27719         ret_ref = (uintptr_t)ret_var.inner;
27720         if (ret_var.is_owned) {
27721                 ret_ref |= 1;
27722         }
27723         return ret_ref;
27724 }
27725
27726 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
27727         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
27728 uint32_t ret_ref = 0;
27729 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27730 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27731 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27732 ret_ref = (uintptr_t)ret_var.inner;
27733 if (ret_var.is_owned) {
27734         ret_ref |= 1;
27735 }
27736         return ret_ref;
27737 }
27738 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
27739         LDKErrorMessage arg_conv;
27740         arg_conv.inner = (void*)(arg & (~1));
27741         arg_conv.is_owned = false;
27742         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27743         uint32_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
27744         return ret_conv;
27745 }
27746
27747 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint32_t orig) {
27748         LDKErrorMessage orig_conv;
27749         orig_conv.inner = (void*)(orig & (~1));
27750         orig_conv.is_owned = false;
27751         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27752         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
27753         uint32_t ret_ref = 0;
27754         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27755         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27757         ret_ref = (uintptr_t)ret_var.inner;
27758         if (ret_var.is_owned) {
27759                 ret_ref |= 1;
27760         }
27761         return ret_ref;
27762 }
27763
27764 void  __attribute__((export_name("TS_WarningMessage_free"))) TS_WarningMessage_free(uint32_t this_obj) {
27765         LDKWarningMessage this_obj_conv;
27766         this_obj_conv.inner = (void*)(this_obj & (~1));
27767         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27769         WarningMessage_free(this_obj_conv);
27770 }
27771
27772 int8_tArray  __attribute__((export_name("TS_WarningMessage_get_channel_id"))) TS_WarningMessage_get_channel_id(uint32_t this_ptr) {
27773         LDKWarningMessage this_ptr_conv;
27774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27775         this_ptr_conv.is_owned = false;
27776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27777         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27778         memcpy(ret_arr->elems, *WarningMessage_get_channel_id(&this_ptr_conv), 32);
27779         return ret_arr;
27780 }
27781
27782 void  __attribute__((export_name("TS_WarningMessage_set_channel_id"))) TS_WarningMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27783         LDKWarningMessage this_ptr_conv;
27784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27785         this_ptr_conv.is_owned = false;
27786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27787         LDKThirtyTwoBytes val_ref;
27788         CHECK(val->arr_len == 32);
27789         memcpy(val_ref.data, val->elems, 32); FREE(val);
27790         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
27791 }
27792
27793 jstring  __attribute__((export_name("TS_WarningMessage_get_data"))) TS_WarningMessage_get_data(uint32_t this_ptr) {
27794         LDKWarningMessage this_ptr_conv;
27795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27796         this_ptr_conv.is_owned = false;
27797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27798         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
27799         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27800         Str_free(ret_str);
27801         return ret_conv;
27802 }
27803
27804 void  __attribute__((export_name("TS_WarningMessage_set_data"))) TS_WarningMessage_set_data(uint32_t this_ptr, jstring val) {
27805         LDKWarningMessage this_ptr_conv;
27806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27807         this_ptr_conv.is_owned = false;
27808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27809         LDKStr val_conv = str_ref_to_owned_c(val);
27810         WarningMessage_set_data(&this_ptr_conv, val_conv);
27811 }
27812
27813 uint32_t  __attribute__((export_name("TS_WarningMessage_new"))) TS_WarningMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
27814         LDKThirtyTwoBytes channel_id_arg_ref;
27815         CHECK(channel_id_arg->arr_len == 32);
27816         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27817         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
27818         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
27819         uint32_t ret_ref = 0;
27820         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27821         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27823         ret_ref = (uintptr_t)ret_var.inner;
27824         if (ret_var.is_owned) {
27825                 ret_ref |= 1;
27826         }
27827         return ret_ref;
27828 }
27829
27830 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
27831         LDKWarningMessage ret_var = WarningMessage_clone(arg);
27832 uint32_t ret_ref = 0;
27833 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27834 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27835 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27836 ret_ref = (uintptr_t)ret_var.inner;
27837 if (ret_var.is_owned) {
27838         ret_ref |= 1;
27839 }
27840         return ret_ref;
27841 }
27842 uint32_t  __attribute__((export_name("TS_WarningMessage_clone_ptr"))) TS_WarningMessage_clone_ptr(uint32_t arg) {
27843         LDKWarningMessage arg_conv;
27844         arg_conv.inner = (void*)(arg & (~1));
27845         arg_conv.is_owned = false;
27846         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27847         uint32_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
27848         return ret_conv;
27849 }
27850
27851 uint32_t  __attribute__((export_name("TS_WarningMessage_clone"))) TS_WarningMessage_clone(uint32_t orig) {
27852         LDKWarningMessage orig_conv;
27853         orig_conv.inner = (void*)(orig & (~1));
27854         orig_conv.is_owned = false;
27855         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27856         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
27857         uint32_t ret_ref = 0;
27858         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27859         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27861         ret_ref = (uintptr_t)ret_var.inner;
27862         if (ret_var.is_owned) {
27863                 ret_ref |= 1;
27864         }
27865         return ret_ref;
27866 }
27867
27868 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint32_t this_obj) {
27869         LDKPing this_obj_conv;
27870         this_obj_conv.inner = (void*)(this_obj & (~1));
27871         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27873         Ping_free(this_obj_conv);
27874 }
27875
27876 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
27877         LDKPing this_ptr_conv;
27878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27879         this_ptr_conv.is_owned = false;
27880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27881         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
27882         return ret_conv;
27883 }
27884
27885 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
27886         LDKPing this_ptr_conv;
27887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27888         this_ptr_conv.is_owned = false;
27889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27890         Ping_set_ponglen(&this_ptr_conv, val);
27891 }
27892
27893 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
27894         LDKPing this_ptr_conv;
27895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27896         this_ptr_conv.is_owned = false;
27897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27898         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
27899         return ret_conv;
27900 }
27901
27902 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
27903         LDKPing this_ptr_conv;
27904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27905         this_ptr_conv.is_owned = false;
27906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27907         Ping_set_byteslen(&this_ptr_conv, val);
27908 }
27909
27910 uint32_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
27911         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
27912         uint32_t ret_ref = 0;
27913         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27914         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27916         ret_ref = (uintptr_t)ret_var.inner;
27917         if (ret_var.is_owned) {
27918                 ret_ref |= 1;
27919         }
27920         return ret_ref;
27921 }
27922
27923 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
27924         LDKPing ret_var = Ping_clone(arg);
27925 uint32_t ret_ref = 0;
27926 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27927 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27928 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27929 ret_ref = (uintptr_t)ret_var.inner;
27930 if (ret_var.is_owned) {
27931         ret_ref |= 1;
27932 }
27933         return ret_ref;
27934 }
27935 uint32_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint32_t arg) {
27936         LDKPing arg_conv;
27937         arg_conv.inner = (void*)(arg & (~1));
27938         arg_conv.is_owned = false;
27939         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27940         uint32_t ret_conv = Ping_clone_ptr(&arg_conv);
27941         return ret_conv;
27942 }
27943
27944 uint32_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint32_t orig) {
27945         LDKPing orig_conv;
27946         orig_conv.inner = (void*)(orig & (~1));
27947         orig_conv.is_owned = false;
27948         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27949         LDKPing ret_var = Ping_clone(&orig_conv);
27950         uint32_t ret_ref = 0;
27951         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27952         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27954         ret_ref = (uintptr_t)ret_var.inner;
27955         if (ret_var.is_owned) {
27956                 ret_ref |= 1;
27957         }
27958         return ret_ref;
27959 }
27960
27961 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint32_t this_obj) {
27962         LDKPong this_obj_conv;
27963         this_obj_conv.inner = (void*)(this_obj & (~1));
27964         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27966         Pong_free(this_obj_conv);
27967 }
27968
27969 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
27970         LDKPong this_ptr_conv;
27971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27972         this_ptr_conv.is_owned = false;
27973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27974         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
27975         return ret_conv;
27976 }
27977
27978 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
27979         LDKPong this_ptr_conv;
27980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27981         this_ptr_conv.is_owned = false;
27982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27983         Pong_set_byteslen(&this_ptr_conv, val);
27984 }
27985
27986 uint32_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
27987         LDKPong ret_var = Pong_new(byteslen_arg);
27988         uint32_t ret_ref = 0;
27989         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27990         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27991         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27992         ret_ref = (uintptr_t)ret_var.inner;
27993         if (ret_var.is_owned) {
27994                 ret_ref |= 1;
27995         }
27996         return ret_ref;
27997 }
27998
27999 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
28000         LDKPong ret_var = Pong_clone(arg);
28001 uint32_t ret_ref = 0;
28002 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28003 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28004 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28005 ret_ref = (uintptr_t)ret_var.inner;
28006 if (ret_var.is_owned) {
28007         ret_ref |= 1;
28008 }
28009         return ret_ref;
28010 }
28011 uint32_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint32_t arg) {
28012         LDKPong arg_conv;
28013         arg_conv.inner = (void*)(arg & (~1));
28014         arg_conv.is_owned = false;
28015         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28016         uint32_t ret_conv = Pong_clone_ptr(&arg_conv);
28017         return ret_conv;
28018 }
28019
28020 uint32_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint32_t orig) {
28021         LDKPong orig_conv;
28022         orig_conv.inner = (void*)(orig & (~1));
28023         orig_conv.is_owned = false;
28024         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28025         LDKPong ret_var = Pong_clone(&orig_conv);
28026         uint32_t ret_ref = 0;
28027         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28028         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28030         ret_ref = (uintptr_t)ret_var.inner;
28031         if (ret_var.is_owned) {
28032                 ret_ref |= 1;
28033         }
28034         return ret_ref;
28035 }
28036
28037 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint32_t this_obj) {
28038         LDKOpenChannel this_obj_conv;
28039         this_obj_conv.inner = (void*)(this_obj & (~1));
28040         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28042         OpenChannel_free(this_obj_conv);
28043 }
28044
28045 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
28046         LDKOpenChannel this_ptr_conv;
28047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28048         this_ptr_conv.is_owned = false;
28049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28050         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28051         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
28052         return ret_arr;
28053 }
28054
28055 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
28056         LDKOpenChannel this_ptr_conv;
28057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28058         this_ptr_conv.is_owned = false;
28059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28060         LDKThirtyTwoBytes val_ref;
28061         CHECK(val->arr_len == 32);
28062         memcpy(val_ref.data, val->elems, 32); FREE(val);
28063         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
28064 }
28065
28066 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
28067         LDKOpenChannel this_ptr_conv;
28068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28069         this_ptr_conv.is_owned = false;
28070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28071         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28072         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
28073         return ret_arr;
28074 }
28075
28076 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
28077         LDKOpenChannel this_ptr_conv;
28078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28079         this_ptr_conv.is_owned = false;
28080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28081         LDKThirtyTwoBytes val_ref;
28082         CHECK(val->arr_len == 32);
28083         memcpy(val_ref.data, val->elems, 32); FREE(val);
28084         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
28085 }
28086
28087 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
28088         LDKOpenChannel this_ptr_conv;
28089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28090         this_ptr_conv.is_owned = false;
28091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28092         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
28093         return ret_conv;
28094 }
28095
28096 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
28097         LDKOpenChannel this_ptr_conv;
28098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28099         this_ptr_conv.is_owned = false;
28100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28101         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
28102 }
28103
28104 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
28105         LDKOpenChannel this_ptr_conv;
28106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28107         this_ptr_conv.is_owned = false;
28108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28109         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
28110         return ret_conv;
28111 }
28112
28113 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
28114         LDKOpenChannel this_ptr_conv;
28115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28116         this_ptr_conv.is_owned = false;
28117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28118         OpenChannel_set_push_msat(&this_ptr_conv, val);
28119 }
28120
28121 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
28122         LDKOpenChannel this_ptr_conv;
28123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28124         this_ptr_conv.is_owned = false;
28125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28126         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
28127         return ret_conv;
28128 }
28129
28130 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
28131         LDKOpenChannel this_ptr_conv;
28132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28133         this_ptr_conv.is_owned = false;
28134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28135         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
28136 }
28137
28138 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) {
28139         LDKOpenChannel this_ptr_conv;
28140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28141         this_ptr_conv.is_owned = false;
28142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28143         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
28144         return ret_conv;
28145 }
28146
28147 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) {
28148         LDKOpenChannel this_ptr_conv;
28149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28150         this_ptr_conv.is_owned = false;
28151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28152         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
28153 }
28154
28155 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
28156         LDKOpenChannel this_ptr_conv;
28157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28158         this_ptr_conv.is_owned = false;
28159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28160         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
28161         return ret_conv;
28162 }
28163
28164 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
28165         LDKOpenChannel this_ptr_conv;
28166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28167         this_ptr_conv.is_owned = false;
28168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28169         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
28170 }
28171
28172 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
28173         LDKOpenChannel this_ptr_conv;
28174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28175         this_ptr_conv.is_owned = false;
28176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28177         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
28178         return ret_conv;
28179 }
28180
28181 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
28182         LDKOpenChannel this_ptr_conv;
28183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28184         this_ptr_conv.is_owned = false;
28185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28186         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
28187 }
28188
28189 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
28190         LDKOpenChannel this_ptr_conv;
28191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28192         this_ptr_conv.is_owned = false;
28193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28194         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
28195         return ret_conv;
28196 }
28197
28198 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
28199         LDKOpenChannel this_ptr_conv;
28200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28201         this_ptr_conv.is_owned = false;
28202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28203         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
28204 }
28205
28206 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
28207         LDKOpenChannel this_ptr_conv;
28208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28209         this_ptr_conv.is_owned = false;
28210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28211         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
28212         return ret_conv;
28213 }
28214
28215 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
28216         LDKOpenChannel this_ptr_conv;
28217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28218         this_ptr_conv.is_owned = false;
28219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28220         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
28221 }
28222
28223 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
28224         LDKOpenChannel this_ptr_conv;
28225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28226         this_ptr_conv.is_owned = false;
28227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28228         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
28229         return ret_conv;
28230 }
28231
28232 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
28233         LDKOpenChannel this_ptr_conv;
28234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28235         this_ptr_conv.is_owned = false;
28236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28237         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
28238 }
28239
28240 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
28241         LDKOpenChannel this_ptr_conv;
28242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28243         this_ptr_conv.is_owned = false;
28244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28245         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28246         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
28247         return ret_arr;
28248 }
28249
28250 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
28251         LDKOpenChannel this_ptr_conv;
28252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28253         this_ptr_conv.is_owned = false;
28254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28255         LDKPublicKey val_ref;
28256         CHECK(val->arr_len == 33);
28257         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28258         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
28259 }
28260
28261 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
28262         LDKOpenChannel this_ptr_conv;
28263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28264         this_ptr_conv.is_owned = false;
28265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28266         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28267         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
28268         return ret_arr;
28269 }
28270
28271 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
28272         LDKOpenChannel this_ptr_conv;
28273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28274         this_ptr_conv.is_owned = false;
28275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28276         LDKPublicKey val_ref;
28277         CHECK(val->arr_len == 33);
28278         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28279         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
28280 }
28281
28282 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
28283         LDKOpenChannel this_ptr_conv;
28284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28285         this_ptr_conv.is_owned = false;
28286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28287         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28288         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
28289         return ret_arr;
28290 }
28291
28292 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
28293         LDKOpenChannel this_ptr_conv;
28294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28295         this_ptr_conv.is_owned = false;
28296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28297         LDKPublicKey val_ref;
28298         CHECK(val->arr_len == 33);
28299         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28300         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
28301 }
28302
28303 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
28304         LDKOpenChannel this_ptr_conv;
28305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28306         this_ptr_conv.is_owned = false;
28307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28308         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28309         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
28310         return ret_arr;
28311 }
28312
28313 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
28314         LDKOpenChannel this_ptr_conv;
28315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28316         this_ptr_conv.is_owned = false;
28317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28318         LDKPublicKey val_ref;
28319         CHECK(val->arr_len == 33);
28320         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28321         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
28322 }
28323
28324 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
28325         LDKOpenChannel this_ptr_conv;
28326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28327         this_ptr_conv.is_owned = false;
28328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28329         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28330         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
28331         return ret_arr;
28332 }
28333
28334 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
28335         LDKOpenChannel this_ptr_conv;
28336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28337         this_ptr_conv.is_owned = false;
28338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28339         LDKPublicKey val_ref;
28340         CHECK(val->arr_len == 33);
28341         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28342         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
28343 }
28344
28345 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
28346         LDKOpenChannel this_ptr_conv;
28347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28348         this_ptr_conv.is_owned = false;
28349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28350         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28351         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28352         return ret_arr;
28353 }
28354
28355 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) {
28356         LDKOpenChannel this_ptr_conv;
28357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28358         this_ptr_conv.is_owned = false;
28359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28360         LDKPublicKey val_ref;
28361         CHECK(val->arr_len == 33);
28362         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28363         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
28364 }
28365
28366 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
28367         LDKOpenChannel this_ptr_conv;
28368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28369         this_ptr_conv.is_owned = false;
28370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28371         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
28372         return ret_conv;
28373 }
28374
28375 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
28376         LDKOpenChannel this_ptr_conv;
28377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28378         this_ptr_conv.is_owned = false;
28379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28380         OpenChannel_set_channel_flags(&this_ptr_conv, val);
28381 }
28382
28383 uint32_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
28384         LDKOpenChannel this_ptr_conv;
28385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28386         this_ptr_conv.is_owned = false;
28387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28388         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
28389         uint32_t ret_ref = 0;
28390         if ((uintptr_t)ret_var.inner > 4096) {
28391                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28392                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28394                 ret_ref = (uintptr_t)ret_var.inner;
28395                 if (ret_var.is_owned) {
28396                         ret_ref |= 1;
28397                 }
28398         }
28399         return ret_ref;
28400 }
28401
28402 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
28403         LDKOpenChannel this_ptr_conv;
28404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28405         this_ptr_conv.is_owned = false;
28406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28407         LDKChannelTypeFeatures val_conv;
28408         val_conv.inner = (void*)(val & (~1));
28409         val_conv.is_owned = (val & 1) || (val == 0);
28410         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28411         val_conv = ChannelTypeFeatures_clone(&val_conv);
28412         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
28413 }
28414
28415 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
28416         LDKOpenChannel ret_var = OpenChannel_clone(arg);
28417 uint32_t ret_ref = 0;
28418 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28419 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28420 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28421 ret_ref = (uintptr_t)ret_var.inner;
28422 if (ret_var.is_owned) {
28423         ret_ref |= 1;
28424 }
28425         return ret_ref;
28426 }
28427 uint32_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
28428         LDKOpenChannel arg_conv;
28429         arg_conv.inner = (void*)(arg & (~1));
28430         arg_conv.is_owned = false;
28431         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28432         uint32_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
28433         return ret_conv;
28434 }
28435
28436 uint32_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint32_t orig) {
28437         LDKOpenChannel orig_conv;
28438         orig_conv.inner = (void*)(orig & (~1));
28439         orig_conv.is_owned = false;
28440         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28441         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
28442         uint32_t ret_ref = 0;
28443         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28444         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28446         ret_ref = (uintptr_t)ret_var.inner;
28447         if (ret_var.is_owned) {
28448                 ret_ref |= 1;
28449         }
28450         return ret_ref;
28451 }
28452
28453 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint32_t this_obj) {
28454         LDKAcceptChannel this_obj_conv;
28455         this_obj_conv.inner = (void*)(this_obj & (~1));
28456         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28458         AcceptChannel_free(this_obj_conv);
28459 }
28460
28461 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
28462         LDKAcceptChannel this_ptr_conv;
28463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28464         this_ptr_conv.is_owned = false;
28465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28466         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28467         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
28468         return ret_arr;
28469 }
28470
28471 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
28472         LDKAcceptChannel this_ptr_conv;
28473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28474         this_ptr_conv.is_owned = false;
28475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28476         LDKThirtyTwoBytes val_ref;
28477         CHECK(val->arr_len == 32);
28478         memcpy(val_ref.data, val->elems, 32); FREE(val);
28479         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
28480 }
28481
28482 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
28483         LDKAcceptChannel this_ptr_conv;
28484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28485         this_ptr_conv.is_owned = false;
28486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28487         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
28488         return ret_conv;
28489 }
28490
28491 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
28492         LDKAcceptChannel this_ptr_conv;
28493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28494         this_ptr_conv.is_owned = false;
28495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28496         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
28497 }
28498
28499 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) {
28500         LDKAcceptChannel this_ptr_conv;
28501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28502         this_ptr_conv.is_owned = false;
28503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28504         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
28505         return ret_conv;
28506 }
28507
28508 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) {
28509         LDKAcceptChannel this_ptr_conv;
28510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28511         this_ptr_conv.is_owned = false;
28512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28513         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
28514 }
28515
28516 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
28517         LDKAcceptChannel this_ptr_conv;
28518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28519         this_ptr_conv.is_owned = false;
28520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28521         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
28522         return ret_conv;
28523 }
28524
28525 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
28526         LDKAcceptChannel this_ptr_conv;
28527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28528         this_ptr_conv.is_owned = false;
28529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28530         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
28531 }
28532
28533 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
28534         LDKAcceptChannel this_ptr_conv;
28535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28536         this_ptr_conv.is_owned = false;
28537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28538         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
28539         return ret_conv;
28540 }
28541
28542 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
28543         LDKAcceptChannel this_ptr_conv;
28544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28545         this_ptr_conv.is_owned = false;
28546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28547         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
28548 }
28549
28550 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
28551         LDKAcceptChannel this_ptr_conv;
28552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28553         this_ptr_conv.is_owned = false;
28554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28555         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
28556         return ret_conv;
28557 }
28558
28559 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
28560         LDKAcceptChannel this_ptr_conv;
28561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28562         this_ptr_conv.is_owned = false;
28563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28564         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
28565 }
28566
28567 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
28568         LDKAcceptChannel this_ptr_conv;
28569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28570         this_ptr_conv.is_owned = false;
28571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28572         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
28573         return ret_conv;
28574 }
28575
28576 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
28577         LDKAcceptChannel this_ptr_conv;
28578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28579         this_ptr_conv.is_owned = false;
28580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28581         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
28582 }
28583
28584 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
28585         LDKAcceptChannel this_ptr_conv;
28586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28587         this_ptr_conv.is_owned = false;
28588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28589         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
28590         return ret_conv;
28591 }
28592
28593 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
28594         LDKAcceptChannel this_ptr_conv;
28595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28596         this_ptr_conv.is_owned = false;
28597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28598         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
28599 }
28600
28601 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
28602         LDKAcceptChannel this_ptr_conv;
28603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28604         this_ptr_conv.is_owned = false;
28605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28606         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28607         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
28608         return ret_arr;
28609 }
28610
28611 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
28612         LDKAcceptChannel this_ptr_conv;
28613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28614         this_ptr_conv.is_owned = false;
28615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28616         LDKPublicKey val_ref;
28617         CHECK(val->arr_len == 33);
28618         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28619         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
28620 }
28621
28622 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
28623         LDKAcceptChannel this_ptr_conv;
28624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28625         this_ptr_conv.is_owned = false;
28626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28627         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28628         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
28629         return ret_arr;
28630 }
28631
28632 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
28633         LDKAcceptChannel this_ptr_conv;
28634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28635         this_ptr_conv.is_owned = false;
28636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28637         LDKPublicKey val_ref;
28638         CHECK(val->arr_len == 33);
28639         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28640         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
28641 }
28642
28643 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
28644         LDKAcceptChannel this_ptr_conv;
28645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28646         this_ptr_conv.is_owned = false;
28647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28648         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28649         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
28650         return ret_arr;
28651 }
28652
28653 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
28654         LDKAcceptChannel this_ptr_conv;
28655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28656         this_ptr_conv.is_owned = false;
28657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28658         LDKPublicKey val_ref;
28659         CHECK(val->arr_len == 33);
28660         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28661         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
28662 }
28663
28664 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
28665         LDKAcceptChannel this_ptr_conv;
28666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28667         this_ptr_conv.is_owned = false;
28668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28669         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28670         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
28671         return ret_arr;
28672 }
28673
28674 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
28675         LDKAcceptChannel this_ptr_conv;
28676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28677         this_ptr_conv.is_owned = false;
28678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28679         LDKPublicKey val_ref;
28680         CHECK(val->arr_len == 33);
28681         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28682         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
28683 }
28684
28685 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
28686         LDKAcceptChannel this_ptr_conv;
28687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28688         this_ptr_conv.is_owned = false;
28689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28690         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28691         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
28692         return ret_arr;
28693 }
28694
28695 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
28696         LDKAcceptChannel this_ptr_conv;
28697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28698         this_ptr_conv.is_owned = false;
28699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28700         LDKPublicKey val_ref;
28701         CHECK(val->arr_len == 33);
28702         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28703         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
28704 }
28705
28706 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
28707         LDKAcceptChannel this_ptr_conv;
28708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28709         this_ptr_conv.is_owned = false;
28710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28711         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28712         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28713         return ret_arr;
28714 }
28715
28716 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) {
28717         LDKAcceptChannel this_ptr_conv;
28718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28719         this_ptr_conv.is_owned = false;
28720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28721         LDKPublicKey val_ref;
28722         CHECK(val->arr_len == 33);
28723         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28724         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
28725 }
28726
28727 uint32_t  __attribute__((export_name("TS_AcceptChannel_get_channel_type"))) TS_AcceptChannel_get_channel_type(uint32_t this_ptr) {
28728         LDKAcceptChannel this_ptr_conv;
28729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28730         this_ptr_conv.is_owned = false;
28731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28732         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
28733         uint32_t ret_ref = 0;
28734         if ((uintptr_t)ret_var.inner > 4096) {
28735                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28736                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28738                 ret_ref = (uintptr_t)ret_var.inner;
28739                 if (ret_var.is_owned) {
28740                         ret_ref |= 1;
28741                 }
28742         }
28743         return ret_ref;
28744 }
28745
28746 void  __attribute__((export_name("TS_AcceptChannel_set_channel_type"))) TS_AcceptChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
28747         LDKAcceptChannel this_ptr_conv;
28748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28749         this_ptr_conv.is_owned = false;
28750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28751         LDKChannelTypeFeatures val_conv;
28752         val_conv.inner = (void*)(val & (~1));
28753         val_conv.is_owned = (val & 1) || (val == 0);
28754         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28755         val_conv = ChannelTypeFeatures_clone(&val_conv);
28756         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
28757 }
28758
28759 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
28760         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
28761 uint32_t ret_ref = 0;
28762 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28763 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28764 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28765 ret_ref = (uintptr_t)ret_var.inner;
28766 if (ret_var.is_owned) {
28767         ret_ref |= 1;
28768 }
28769         return ret_ref;
28770 }
28771 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
28772         LDKAcceptChannel arg_conv;
28773         arg_conv.inner = (void*)(arg & (~1));
28774         arg_conv.is_owned = false;
28775         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28776         uint32_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
28777         return ret_conv;
28778 }
28779
28780 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint32_t orig) {
28781         LDKAcceptChannel orig_conv;
28782         orig_conv.inner = (void*)(orig & (~1));
28783         orig_conv.is_owned = false;
28784         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28785         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
28786         uint32_t ret_ref = 0;
28787         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28788         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28790         ret_ref = (uintptr_t)ret_var.inner;
28791         if (ret_var.is_owned) {
28792                 ret_ref |= 1;
28793         }
28794         return ret_ref;
28795 }
28796
28797 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint32_t this_obj) {
28798         LDKFundingCreated this_obj_conv;
28799         this_obj_conv.inner = (void*)(this_obj & (~1));
28800         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28802         FundingCreated_free(this_obj_conv);
28803 }
28804
28805 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
28806         LDKFundingCreated this_ptr_conv;
28807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28808         this_ptr_conv.is_owned = false;
28809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28810         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28811         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
28812         return ret_arr;
28813 }
28814
28815 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
28816         LDKFundingCreated this_ptr_conv;
28817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28818         this_ptr_conv.is_owned = false;
28819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28820         LDKThirtyTwoBytes val_ref;
28821         CHECK(val->arr_len == 32);
28822         memcpy(val_ref.data, val->elems, 32); FREE(val);
28823         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
28824 }
28825
28826 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
28827         LDKFundingCreated this_ptr_conv;
28828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28829         this_ptr_conv.is_owned = false;
28830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28831         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28832         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
28833         return ret_arr;
28834 }
28835
28836 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
28837         LDKFundingCreated this_ptr_conv;
28838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28839         this_ptr_conv.is_owned = false;
28840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28841         LDKThirtyTwoBytes val_ref;
28842         CHECK(val->arr_len == 32);
28843         memcpy(val_ref.data, val->elems, 32); FREE(val);
28844         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
28845 }
28846
28847 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
28848         LDKFundingCreated this_ptr_conv;
28849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28850         this_ptr_conv.is_owned = false;
28851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28852         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
28853         return ret_conv;
28854 }
28855
28856 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
28857         LDKFundingCreated this_ptr_conv;
28858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28859         this_ptr_conv.is_owned = false;
28860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28861         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
28862 }
28863
28864 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
28865         LDKFundingCreated this_ptr_conv;
28866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28867         this_ptr_conv.is_owned = false;
28868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28869         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28870         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
28871         return ret_arr;
28872 }
28873
28874 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
28875         LDKFundingCreated this_ptr_conv;
28876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28877         this_ptr_conv.is_owned = false;
28878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28879         LDKSignature val_ref;
28880         CHECK(val->arr_len == 64);
28881         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28882         FundingCreated_set_signature(&this_ptr_conv, val_ref);
28883 }
28884
28885 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) {
28886         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
28887         CHECK(temporary_channel_id_arg->arr_len == 32);
28888         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
28889         LDKThirtyTwoBytes funding_txid_arg_ref;
28890         CHECK(funding_txid_arg->arr_len == 32);
28891         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
28892         LDKSignature signature_arg_ref;
28893         CHECK(signature_arg->arr_len == 64);
28894         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
28895         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
28896         uint32_t ret_ref = 0;
28897         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28898         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28900         ret_ref = (uintptr_t)ret_var.inner;
28901         if (ret_var.is_owned) {
28902                 ret_ref |= 1;
28903         }
28904         return ret_ref;
28905 }
28906
28907 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
28908         LDKFundingCreated ret_var = FundingCreated_clone(arg);
28909 uint32_t ret_ref = 0;
28910 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28911 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28912 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28913 ret_ref = (uintptr_t)ret_var.inner;
28914 if (ret_var.is_owned) {
28915         ret_ref |= 1;
28916 }
28917         return ret_ref;
28918 }
28919 uint32_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
28920         LDKFundingCreated arg_conv;
28921         arg_conv.inner = (void*)(arg & (~1));
28922         arg_conv.is_owned = false;
28923         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28924         uint32_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
28925         return ret_conv;
28926 }
28927
28928 uint32_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint32_t orig) {
28929         LDKFundingCreated orig_conv;
28930         orig_conv.inner = (void*)(orig & (~1));
28931         orig_conv.is_owned = false;
28932         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28933         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
28934         uint32_t ret_ref = 0;
28935         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28936         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28938         ret_ref = (uintptr_t)ret_var.inner;
28939         if (ret_var.is_owned) {
28940                 ret_ref |= 1;
28941         }
28942         return ret_ref;
28943 }
28944
28945 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint32_t this_obj) {
28946         LDKFundingSigned this_obj_conv;
28947         this_obj_conv.inner = (void*)(this_obj & (~1));
28948         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28950         FundingSigned_free(this_obj_conv);
28951 }
28952
28953 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
28954         LDKFundingSigned this_ptr_conv;
28955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28956         this_ptr_conv.is_owned = false;
28957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28958         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28959         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
28960         return ret_arr;
28961 }
28962
28963 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28964         LDKFundingSigned this_ptr_conv;
28965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28966         this_ptr_conv.is_owned = false;
28967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28968         LDKThirtyTwoBytes val_ref;
28969         CHECK(val->arr_len == 32);
28970         memcpy(val_ref.data, val->elems, 32); FREE(val);
28971         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
28972 }
28973
28974 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
28975         LDKFundingSigned this_ptr_conv;
28976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28977         this_ptr_conv.is_owned = false;
28978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28979         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28980         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
28981         return ret_arr;
28982 }
28983
28984 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
28985         LDKFundingSigned this_ptr_conv;
28986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28987         this_ptr_conv.is_owned = false;
28988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28989         LDKSignature val_ref;
28990         CHECK(val->arr_len == 64);
28991         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28992         FundingSigned_set_signature(&this_ptr_conv, val_ref);
28993 }
28994
28995 uint32_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
28996         LDKThirtyTwoBytes channel_id_arg_ref;
28997         CHECK(channel_id_arg->arr_len == 32);
28998         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28999         LDKSignature signature_arg_ref;
29000         CHECK(signature_arg->arr_len == 64);
29001         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29002         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
29003         uint32_t ret_ref = 0;
29004         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29005         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29007         ret_ref = (uintptr_t)ret_var.inner;
29008         if (ret_var.is_owned) {
29009                 ret_ref |= 1;
29010         }
29011         return ret_ref;
29012 }
29013
29014 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
29015         LDKFundingSigned ret_var = FundingSigned_clone(arg);
29016 uint32_t ret_ref = 0;
29017 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29018 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29019 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29020 ret_ref = (uintptr_t)ret_var.inner;
29021 if (ret_var.is_owned) {
29022         ret_ref |= 1;
29023 }
29024         return ret_ref;
29025 }
29026 uint32_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
29027         LDKFundingSigned arg_conv;
29028         arg_conv.inner = (void*)(arg & (~1));
29029         arg_conv.is_owned = false;
29030         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29031         uint32_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
29032         return ret_conv;
29033 }
29034
29035 uint32_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint32_t orig) {
29036         LDKFundingSigned orig_conv;
29037         orig_conv.inner = (void*)(orig & (~1));
29038         orig_conv.is_owned = false;
29039         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29040         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
29041         uint32_t ret_ref = 0;
29042         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29043         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29045         ret_ref = (uintptr_t)ret_var.inner;
29046         if (ret_var.is_owned) {
29047                 ret_ref |= 1;
29048         }
29049         return ret_ref;
29050 }
29051
29052 void  __attribute__((export_name("TS_ChannelReady_free"))) TS_ChannelReady_free(uint32_t this_obj) {
29053         LDKChannelReady this_obj_conv;
29054         this_obj_conv.inner = (void*)(this_obj & (~1));
29055         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29057         ChannelReady_free(this_obj_conv);
29058 }
29059
29060 int8_tArray  __attribute__((export_name("TS_ChannelReady_get_channel_id"))) TS_ChannelReady_get_channel_id(uint32_t this_ptr) {
29061         LDKChannelReady this_ptr_conv;
29062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29063         this_ptr_conv.is_owned = false;
29064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29065         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29066         memcpy(ret_arr->elems, *ChannelReady_get_channel_id(&this_ptr_conv), 32);
29067         return ret_arr;
29068 }
29069
29070 void  __attribute__((export_name("TS_ChannelReady_set_channel_id"))) TS_ChannelReady_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29071         LDKChannelReady this_ptr_conv;
29072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29073         this_ptr_conv.is_owned = false;
29074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29075         LDKThirtyTwoBytes val_ref;
29076         CHECK(val->arr_len == 32);
29077         memcpy(val_ref.data, val->elems, 32); FREE(val);
29078         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
29079 }
29080
29081 int8_tArray  __attribute__((export_name("TS_ChannelReady_get_next_per_commitment_point"))) TS_ChannelReady_get_next_per_commitment_point(uint32_t this_ptr) {
29082         LDKChannelReady this_ptr_conv;
29083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29084         this_ptr_conv.is_owned = false;
29085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29086         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29087         memcpy(ret_arr->elems, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29088         return ret_arr;
29089 }
29090
29091 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) {
29092         LDKChannelReady this_ptr_conv;
29093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29094         this_ptr_conv.is_owned = false;
29095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29096         LDKPublicKey val_ref;
29097         CHECK(val->arr_len == 33);
29098         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29099         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
29100 }
29101
29102 uint32_t  __attribute__((export_name("TS_ChannelReady_get_short_channel_id_alias"))) TS_ChannelReady_get_short_channel_id_alias(uint32_t this_ptr) {
29103         LDKChannelReady this_ptr_conv;
29104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29105         this_ptr_conv.is_owned = false;
29106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29107         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29108         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
29109         uint32_t ret_ref = (uintptr_t)ret_copy;
29110         return ret_ref;
29111 }
29112
29113 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) {
29114         LDKChannelReady this_ptr_conv;
29115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29116         this_ptr_conv.is_owned = false;
29117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29118         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29119         CHECK_ACCESS(val_ptr);
29120         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29121         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29122         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
29123 }
29124
29125 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) {
29126         LDKThirtyTwoBytes channel_id_arg_ref;
29127         CHECK(channel_id_arg->arr_len == 32);
29128         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29129         LDKPublicKey next_per_commitment_point_arg_ref;
29130         CHECK(next_per_commitment_point_arg->arr_len == 33);
29131         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
29132         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
29133         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
29134         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
29135         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
29136         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
29137         uint32_t ret_ref = 0;
29138         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29139         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29141         ret_ref = (uintptr_t)ret_var.inner;
29142         if (ret_var.is_owned) {
29143                 ret_ref |= 1;
29144         }
29145         return ret_ref;
29146 }
29147
29148 static inline uintptr_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
29149         LDKChannelReady ret_var = ChannelReady_clone(arg);
29150 uint32_t ret_ref = 0;
29151 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29152 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29153 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29154 ret_ref = (uintptr_t)ret_var.inner;
29155 if (ret_var.is_owned) {
29156         ret_ref |= 1;
29157 }
29158         return ret_ref;
29159 }
29160 uint32_t  __attribute__((export_name("TS_ChannelReady_clone_ptr"))) TS_ChannelReady_clone_ptr(uint32_t arg) {
29161         LDKChannelReady arg_conv;
29162         arg_conv.inner = (void*)(arg & (~1));
29163         arg_conv.is_owned = false;
29164         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29165         uint32_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
29166         return ret_conv;
29167 }
29168
29169 uint32_t  __attribute__((export_name("TS_ChannelReady_clone"))) TS_ChannelReady_clone(uint32_t orig) {
29170         LDKChannelReady orig_conv;
29171         orig_conv.inner = (void*)(orig & (~1));
29172         orig_conv.is_owned = false;
29173         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29174         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
29175         uint32_t ret_ref = 0;
29176         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29177         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29179         ret_ref = (uintptr_t)ret_var.inner;
29180         if (ret_var.is_owned) {
29181                 ret_ref |= 1;
29182         }
29183         return ret_ref;
29184 }
29185
29186 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint32_t this_obj) {
29187         LDKShutdown this_obj_conv;
29188         this_obj_conv.inner = (void*)(this_obj & (~1));
29189         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29191         Shutdown_free(this_obj_conv);
29192 }
29193
29194 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
29195         LDKShutdown this_ptr_conv;
29196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29197         this_ptr_conv.is_owned = false;
29198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29199         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29200         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
29201         return ret_arr;
29202 }
29203
29204 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29205         LDKShutdown this_ptr_conv;
29206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29207         this_ptr_conv.is_owned = false;
29208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29209         LDKThirtyTwoBytes val_ref;
29210         CHECK(val->arr_len == 32);
29211         memcpy(val_ref.data, val->elems, 32); FREE(val);
29212         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
29213 }
29214
29215 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
29216         LDKShutdown this_ptr_conv;
29217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29218         this_ptr_conv.is_owned = false;
29219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29220         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
29221         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29222         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29223         return ret_arr;
29224 }
29225
29226 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
29227         LDKShutdown this_ptr_conv;
29228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29229         this_ptr_conv.is_owned = false;
29230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29231         LDKCVec_u8Z val_ref;
29232         val_ref.datalen = val->arr_len;
29233         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
29234         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
29235         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
29236 }
29237
29238 uint32_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
29239         LDKThirtyTwoBytes channel_id_arg_ref;
29240         CHECK(channel_id_arg->arr_len == 32);
29241         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29242         LDKCVec_u8Z scriptpubkey_arg_ref;
29243         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
29244         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
29245         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
29246         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
29247         uint32_t ret_ref = 0;
29248         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29249         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29251         ret_ref = (uintptr_t)ret_var.inner;
29252         if (ret_var.is_owned) {
29253                 ret_ref |= 1;
29254         }
29255         return ret_ref;
29256 }
29257
29258 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
29259         LDKShutdown ret_var = Shutdown_clone(arg);
29260 uint32_t ret_ref = 0;
29261 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29262 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29263 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29264 ret_ref = (uintptr_t)ret_var.inner;
29265 if (ret_var.is_owned) {
29266         ret_ref |= 1;
29267 }
29268         return ret_ref;
29269 }
29270 uint32_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint32_t arg) {
29271         LDKShutdown arg_conv;
29272         arg_conv.inner = (void*)(arg & (~1));
29273         arg_conv.is_owned = false;
29274         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29275         uint32_t ret_conv = Shutdown_clone_ptr(&arg_conv);
29276         return ret_conv;
29277 }
29278
29279 uint32_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint32_t orig) {
29280         LDKShutdown orig_conv;
29281         orig_conv.inner = (void*)(orig & (~1));
29282         orig_conv.is_owned = false;
29283         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29284         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
29285         uint32_t ret_ref = 0;
29286         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29287         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29289         ret_ref = (uintptr_t)ret_var.inner;
29290         if (ret_var.is_owned) {
29291                 ret_ref |= 1;
29292         }
29293         return ret_ref;
29294 }
29295
29296 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
29297         LDKClosingSignedFeeRange this_obj_conv;
29298         this_obj_conv.inner = (void*)(this_obj & (~1));
29299         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29301         ClosingSignedFeeRange_free(this_obj_conv);
29302 }
29303
29304 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
29305         LDKClosingSignedFeeRange this_ptr_conv;
29306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29307         this_ptr_conv.is_owned = false;
29308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29309         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
29310         return ret_conv;
29311 }
29312
29313 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
29314         LDKClosingSignedFeeRange this_ptr_conv;
29315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29316         this_ptr_conv.is_owned = false;
29317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29318         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
29319 }
29320
29321 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
29322         LDKClosingSignedFeeRange this_ptr_conv;
29323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29324         this_ptr_conv.is_owned = false;
29325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29326         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
29327         return ret_conv;
29328 }
29329
29330 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
29331         LDKClosingSignedFeeRange this_ptr_conv;
29332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29333         this_ptr_conv.is_owned = false;
29334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29335         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
29336 }
29337
29338 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
29339         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
29340         uint32_t ret_ref = 0;
29341         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29342         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29344         ret_ref = (uintptr_t)ret_var.inner;
29345         if (ret_var.is_owned) {
29346                 ret_ref |= 1;
29347         }
29348         return ret_ref;
29349 }
29350
29351 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
29352         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
29353 uint32_t ret_ref = 0;
29354 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29355 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29356 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29357 ret_ref = (uintptr_t)ret_var.inner;
29358 if (ret_var.is_owned) {
29359         ret_ref |= 1;
29360 }
29361         return ret_ref;
29362 }
29363 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
29364         LDKClosingSignedFeeRange arg_conv;
29365         arg_conv.inner = (void*)(arg & (~1));
29366         arg_conv.is_owned = false;
29367         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29368         uint32_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
29369         return ret_conv;
29370 }
29371
29372 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
29373         LDKClosingSignedFeeRange orig_conv;
29374         orig_conv.inner = (void*)(orig & (~1));
29375         orig_conv.is_owned = false;
29376         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29377         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
29378         uint32_t ret_ref = 0;
29379         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29380         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29381         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29382         ret_ref = (uintptr_t)ret_var.inner;
29383         if (ret_var.is_owned) {
29384                 ret_ref |= 1;
29385         }
29386         return ret_ref;
29387 }
29388
29389 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint32_t this_obj) {
29390         LDKClosingSigned this_obj_conv;
29391         this_obj_conv.inner = (void*)(this_obj & (~1));
29392         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29394         ClosingSigned_free(this_obj_conv);
29395 }
29396
29397 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
29398         LDKClosingSigned this_ptr_conv;
29399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29400         this_ptr_conv.is_owned = false;
29401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29402         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29403         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
29404         return ret_arr;
29405 }
29406
29407 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29408         LDKClosingSigned this_ptr_conv;
29409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29410         this_ptr_conv.is_owned = false;
29411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29412         LDKThirtyTwoBytes val_ref;
29413         CHECK(val->arr_len == 32);
29414         memcpy(val_ref.data, val->elems, 32); FREE(val);
29415         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
29416 }
29417
29418 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
29419         LDKClosingSigned this_ptr_conv;
29420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29421         this_ptr_conv.is_owned = false;
29422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29423         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
29424         return ret_conv;
29425 }
29426
29427 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
29428         LDKClosingSigned this_ptr_conv;
29429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29430         this_ptr_conv.is_owned = false;
29431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29432         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
29433 }
29434
29435 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
29436         LDKClosingSigned this_ptr_conv;
29437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29438         this_ptr_conv.is_owned = false;
29439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29440         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29441         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
29442         return ret_arr;
29443 }
29444
29445 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
29446         LDKClosingSigned this_ptr_conv;
29447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29448         this_ptr_conv.is_owned = false;
29449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29450         LDKSignature val_ref;
29451         CHECK(val->arr_len == 64);
29452         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29453         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
29454 }
29455
29456 uint32_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
29457         LDKClosingSigned this_ptr_conv;
29458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29459         this_ptr_conv.is_owned = false;
29460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29461         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
29462         uint32_t ret_ref = 0;
29463         if ((uintptr_t)ret_var.inner > 4096) {
29464                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29465                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29467                 ret_ref = (uintptr_t)ret_var.inner;
29468                 if (ret_var.is_owned) {
29469                         ret_ref |= 1;
29470                 }
29471         }
29472         return ret_ref;
29473 }
29474
29475 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
29476         LDKClosingSigned this_ptr_conv;
29477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29478         this_ptr_conv.is_owned = false;
29479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29480         LDKClosingSignedFeeRange val_conv;
29481         val_conv.inner = (void*)(val & (~1));
29482         val_conv.is_owned = (val & 1) || (val == 0);
29483         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29484         val_conv = ClosingSignedFeeRange_clone(&val_conv);
29485         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
29486 }
29487
29488 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) {
29489         LDKThirtyTwoBytes channel_id_arg_ref;
29490         CHECK(channel_id_arg->arr_len == 32);
29491         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29492         LDKSignature signature_arg_ref;
29493         CHECK(signature_arg->arr_len == 64);
29494         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29495         LDKClosingSignedFeeRange fee_range_arg_conv;
29496         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
29497         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
29498         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
29499         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
29500         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
29501         uint32_t ret_ref = 0;
29502         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29503         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29505         ret_ref = (uintptr_t)ret_var.inner;
29506         if (ret_var.is_owned) {
29507                 ret_ref |= 1;
29508         }
29509         return ret_ref;
29510 }
29511
29512 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
29513         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
29514 uint32_t ret_ref = 0;
29515 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29516 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29517 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29518 ret_ref = (uintptr_t)ret_var.inner;
29519 if (ret_var.is_owned) {
29520         ret_ref |= 1;
29521 }
29522         return ret_ref;
29523 }
29524 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
29525         LDKClosingSigned arg_conv;
29526         arg_conv.inner = (void*)(arg & (~1));
29527         arg_conv.is_owned = false;
29528         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29529         uint32_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
29530         return ret_conv;
29531 }
29532
29533 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint32_t orig) {
29534         LDKClosingSigned orig_conv;
29535         orig_conv.inner = (void*)(orig & (~1));
29536         orig_conv.is_owned = false;
29537         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29538         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
29539         uint32_t ret_ref = 0;
29540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29543         ret_ref = (uintptr_t)ret_var.inner;
29544         if (ret_var.is_owned) {
29545                 ret_ref |= 1;
29546         }
29547         return ret_ref;
29548 }
29549
29550 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
29551         LDKUpdateAddHTLC this_obj_conv;
29552         this_obj_conv.inner = (void*)(this_obj & (~1));
29553         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29555         UpdateAddHTLC_free(this_obj_conv);
29556 }
29557
29558 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
29559         LDKUpdateAddHTLC this_ptr_conv;
29560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29561         this_ptr_conv.is_owned = false;
29562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29563         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29564         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
29565         return ret_arr;
29566 }
29567
29568 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29569         LDKUpdateAddHTLC this_ptr_conv;
29570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29571         this_ptr_conv.is_owned = false;
29572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29573         LDKThirtyTwoBytes val_ref;
29574         CHECK(val->arr_len == 32);
29575         memcpy(val_ref.data, val->elems, 32); FREE(val);
29576         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
29577 }
29578
29579 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
29580         LDKUpdateAddHTLC this_ptr_conv;
29581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29582         this_ptr_conv.is_owned = false;
29583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29584         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
29585         return ret_conv;
29586 }
29587
29588 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
29589         LDKUpdateAddHTLC this_ptr_conv;
29590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29591         this_ptr_conv.is_owned = false;
29592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29593         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
29594 }
29595
29596 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
29597         LDKUpdateAddHTLC this_ptr_conv;
29598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29599         this_ptr_conv.is_owned = false;
29600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29601         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
29602         return ret_conv;
29603 }
29604
29605 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
29606         LDKUpdateAddHTLC this_ptr_conv;
29607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29608         this_ptr_conv.is_owned = false;
29609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29610         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
29611 }
29612
29613 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
29614         LDKUpdateAddHTLC this_ptr_conv;
29615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29616         this_ptr_conv.is_owned = false;
29617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29618         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29619         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
29620         return ret_arr;
29621 }
29622
29623 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
29624         LDKUpdateAddHTLC this_ptr_conv;
29625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29626         this_ptr_conv.is_owned = false;
29627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29628         LDKThirtyTwoBytes val_ref;
29629         CHECK(val->arr_len == 32);
29630         memcpy(val_ref.data, val->elems, 32); FREE(val);
29631         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
29632 }
29633
29634 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
29635         LDKUpdateAddHTLC this_ptr_conv;
29636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29637         this_ptr_conv.is_owned = false;
29638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29639         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
29640         return ret_conv;
29641 }
29642
29643 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
29644         LDKUpdateAddHTLC this_ptr_conv;
29645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29646         this_ptr_conv.is_owned = false;
29647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29648         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
29649 }
29650
29651 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
29652         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
29653 uint32_t ret_ref = 0;
29654 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29655 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29656 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29657 ret_ref = (uintptr_t)ret_var.inner;
29658 if (ret_var.is_owned) {
29659         ret_ref |= 1;
29660 }
29661         return ret_ref;
29662 }
29663 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
29664         LDKUpdateAddHTLC arg_conv;
29665         arg_conv.inner = (void*)(arg & (~1));
29666         arg_conv.is_owned = false;
29667         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29668         uint32_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
29669         return ret_conv;
29670 }
29671
29672 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
29673         LDKUpdateAddHTLC orig_conv;
29674         orig_conv.inner = (void*)(orig & (~1));
29675         orig_conv.is_owned = false;
29676         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29677         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
29678         uint32_t ret_ref = 0;
29679         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29680         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29682         ret_ref = (uintptr_t)ret_var.inner;
29683         if (ret_var.is_owned) {
29684                 ret_ref |= 1;
29685         }
29686         return ret_ref;
29687 }
29688
29689 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
29690         LDKUpdateFulfillHTLC this_obj_conv;
29691         this_obj_conv.inner = (void*)(this_obj & (~1));
29692         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29694         UpdateFulfillHTLC_free(this_obj_conv);
29695 }
29696
29697 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
29698         LDKUpdateFulfillHTLC this_ptr_conv;
29699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29700         this_ptr_conv.is_owned = false;
29701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29702         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29703         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
29704         return ret_arr;
29705 }
29706
29707 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29708         LDKUpdateFulfillHTLC this_ptr_conv;
29709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29710         this_ptr_conv.is_owned = false;
29711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29712         LDKThirtyTwoBytes val_ref;
29713         CHECK(val->arr_len == 32);
29714         memcpy(val_ref.data, val->elems, 32); FREE(val);
29715         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
29716 }
29717
29718 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
29719         LDKUpdateFulfillHTLC this_ptr_conv;
29720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29721         this_ptr_conv.is_owned = false;
29722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29723         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
29724         return ret_conv;
29725 }
29726
29727 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
29728         LDKUpdateFulfillHTLC this_ptr_conv;
29729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29730         this_ptr_conv.is_owned = false;
29731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29732         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
29733 }
29734
29735 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
29736         LDKUpdateFulfillHTLC this_ptr_conv;
29737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29738         this_ptr_conv.is_owned = false;
29739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29740         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29741         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
29742         return ret_arr;
29743 }
29744
29745 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
29746         LDKUpdateFulfillHTLC this_ptr_conv;
29747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29748         this_ptr_conv.is_owned = false;
29749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29750         LDKThirtyTwoBytes val_ref;
29751         CHECK(val->arr_len == 32);
29752         memcpy(val_ref.data, val->elems, 32); FREE(val);
29753         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
29754 }
29755
29756 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) {
29757         LDKThirtyTwoBytes channel_id_arg_ref;
29758         CHECK(channel_id_arg->arr_len == 32);
29759         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29760         LDKThirtyTwoBytes payment_preimage_arg_ref;
29761         CHECK(payment_preimage_arg->arr_len == 32);
29762         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
29763         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
29764         uint32_t ret_ref = 0;
29765         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29766         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29768         ret_ref = (uintptr_t)ret_var.inner;
29769         if (ret_var.is_owned) {
29770                 ret_ref |= 1;
29771         }
29772         return ret_ref;
29773 }
29774
29775 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
29776         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
29777 uint32_t ret_ref = 0;
29778 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29779 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29780 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29781 ret_ref = (uintptr_t)ret_var.inner;
29782 if (ret_var.is_owned) {
29783         ret_ref |= 1;
29784 }
29785         return ret_ref;
29786 }
29787 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
29788         LDKUpdateFulfillHTLC arg_conv;
29789         arg_conv.inner = (void*)(arg & (~1));
29790         arg_conv.is_owned = false;
29791         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29792         uint32_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
29793         return ret_conv;
29794 }
29795
29796 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
29797         LDKUpdateFulfillHTLC orig_conv;
29798         orig_conv.inner = (void*)(orig & (~1));
29799         orig_conv.is_owned = false;
29800         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29801         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
29802         uint32_t ret_ref = 0;
29803         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29804         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29806         ret_ref = (uintptr_t)ret_var.inner;
29807         if (ret_var.is_owned) {
29808                 ret_ref |= 1;
29809         }
29810         return ret_ref;
29811 }
29812
29813 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
29814         LDKUpdateFailHTLC this_obj_conv;
29815         this_obj_conv.inner = (void*)(this_obj & (~1));
29816         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29818         UpdateFailHTLC_free(this_obj_conv);
29819 }
29820
29821 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
29822         LDKUpdateFailHTLC this_ptr_conv;
29823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29824         this_ptr_conv.is_owned = false;
29825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29826         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29827         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
29828         return ret_arr;
29829 }
29830
29831 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29832         LDKUpdateFailHTLC this_ptr_conv;
29833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29834         this_ptr_conv.is_owned = false;
29835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29836         LDKThirtyTwoBytes val_ref;
29837         CHECK(val->arr_len == 32);
29838         memcpy(val_ref.data, val->elems, 32); FREE(val);
29839         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
29840 }
29841
29842 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
29843         LDKUpdateFailHTLC this_ptr_conv;
29844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29845         this_ptr_conv.is_owned = false;
29846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29847         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
29848         return ret_conv;
29849 }
29850
29851 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
29852         LDKUpdateFailHTLC this_ptr_conv;
29853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29854         this_ptr_conv.is_owned = false;
29855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29856         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
29857 }
29858
29859 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
29860         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
29861 uint32_t ret_ref = 0;
29862 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29863 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29864 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29865 ret_ref = (uintptr_t)ret_var.inner;
29866 if (ret_var.is_owned) {
29867         ret_ref |= 1;
29868 }
29869         return ret_ref;
29870 }
29871 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
29872         LDKUpdateFailHTLC arg_conv;
29873         arg_conv.inner = (void*)(arg & (~1));
29874         arg_conv.is_owned = false;
29875         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29876         uint32_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
29877         return ret_conv;
29878 }
29879
29880 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
29881         LDKUpdateFailHTLC orig_conv;
29882         orig_conv.inner = (void*)(orig & (~1));
29883         orig_conv.is_owned = false;
29884         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29885         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
29886         uint32_t ret_ref = 0;
29887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29890         ret_ref = (uintptr_t)ret_var.inner;
29891         if (ret_var.is_owned) {
29892                 ret_ref |= 1;
29893         }
29894         return ret_ref;
29895 }
29896
29897 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
29898         LDKUpdateFailMalformedHTLC this_obj_conv;
29899         this_obj_conv.inner = (void*)(this_obj & (~1));
29900         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29902         UpdateFailMalformedHTLC_free(this_obj_conv);
29903 }
29904
29905 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
29906         LDKUpdateFailMalformedHTLC this_ptr_conv;
29907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29908         this_ptr_conv.is_owned = false;
29909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29910         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29911         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
29912         return ret_arr;
29913 }
29914
29915 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29916         LDKUpdateFailMalformedHTLC this_ptr_conv;
29917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29918         this_ptr_conv.is_owned = false;
29919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29920         LDKThirtyTwoBytes val_ref;
29921         CHECK(val->arr_len == 32);
29922         memcpy(val_ref.data, val->elems, 32); FREE(val);
29923         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
29924 }
29925
29926 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
29927         LDKUpdateFailMalformedHTLC this_ptr_conv;
29928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29929         this_ptr_conv.is_owned = false;
29930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29931         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
29932         return ret_conv;
29933 }
29934
29935 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
29936         LDKUpdateFailMalformedHTLC this_ptr_conv;
29937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29938         this_ptr_conv.is_owned = false;
29939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29940         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
29941 }
29942
29943 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
29944         LDKUpdateFailMalformedHTLC this_ptr_conv;
29945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29946         this_ptr_conv.is_owned = false;
29947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29948         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
29949         return ret_conv;
29950 }
29951
29952 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
29953         LDKUpdateFailMalformedHTLC this_ptr_conv;
29954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29955         this_ptr_conv.is_owned = false;
29956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29957         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
29958 }
29959
29960 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
29961         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
29962 uint32_t ret_ref = 0;
29963 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29964 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29965 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29966 ret_ref = (uintptr_t)ret_var.inner;
29967 if (ret_var.is_owned) {
29968         ret_ref |= 1;
29969 }
29970         return ret_ref;
29971 }
29972 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
29973         LDKUpdateFailMalformedHTLC arg_conv;
29974         arg_conv.inner = (void*)(arg & (~1));
29975         arg_conv.is_owned = false;
29976         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29977         uint32_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
29978         return ret_conv;
29979 }
29980
29981 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
29982         LDKUpdateFailMalformedHTLC orig_conv;
29983         orig_conv.inner = (void*)(orig & (~1));
29984         orig_conv.is_owned = false;
29985         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29986         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
29987         uint32_t ret_ref = 0;
29988         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29989         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29991         ret_ref = (uintptr_t)ret_var.inner;
29992         if (ret_var.is_owned) {
29993                 ret_ref |= 1;
29994         }
29995         return ret_ref;
29996 }
29997
29998 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint32_t this_obj) {
29999         LDKCommitmentSigned this_obj_conv;
30000         this_obj_conv.inner = (void*)(this_obj & (~1));
30001         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30003         CommitmentSigned_free(this_obj_conv);
30004 }
30005
30006 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
30007         LDKCommitmentSigned this_ptr_conv;
30008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30009         this_ptr_conv.is_owned = false;
30010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30011         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30012         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
30013         return ret_arr;
30014 }
30015
30016 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30017         LDKCommitmentSigned this_ptr_conv;
30018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30019         this_ptr_conv.is_owned = false;
30020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30021         LDKThirtyTwoBytes val_ref;
30022         CHECK(val->arr_len == 32);
30023         memcpy(val_ref.data, val->elems, 32); FREE(val);
30024         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
30025 }
30026
30027 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
30028         LDKCommitmentSigned this_ptr_conv;
30029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30030         this_ptr_conv.is_owned = false;
30031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30032         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30033         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
30034         return ret_arr;
30035 }
30036
30037 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
30038         LDKCommitmentSigned this_ptr_conv;
30039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30040         this_ptr_conv.is_owned = false;
30041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30042         LDKSignature val_ref;
30043         CHECK(val->arr_len == 64);
30044         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30045         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
30046 }
30047
30048 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
30049         LDKCommitmentSigned this_ptr_conv;
30050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30051         this_ptr_conv.is_owned = false;
30052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30053         LDKCVec_SignatureZ val_constr;
30054         val_constr.datalen = val->arr_len;
30055         if (val_constr.datalen > 0)
30056                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30057         else
30058                 val_constr.data = NULL;
30059         int8_tArray* val_vals = (void*) val->elems;
30060         for (size_t m = 0; m < val_constr.datalen; m++) {
30061                 int8_tArray val_conv_12 = val_vals[m];
30062                 LDKSignature val_conv_12_ref;
30063                 CHECK(val_conv_12->arr_len == 64);
30064                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
30065                 val_constr.data[m] = val_conv_12_ref;
30066         }
30067         FREE(val);
30068         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
30069 }
30070
30071 uint32_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
30072         LDKThirtyTwoBytes channel_id_arg_ref;
30073         CHECK(channel_id_arg->arr_len == 32);
30074         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30075         LDKSignature signature_arg_ref;
30076         CHECK(signature_arg->arr_len == 64);
30077         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
30078         LDKCVec_SignatureZ htlc_signatures_arg_constr;
30079         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
30080         if (htlc_signatures_arg_constr.datalen > 0)
30081                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30082         else
30083                 htlc_signatures_arg_constr.data = NULL;
30084         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems;
30085         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
30086                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
30087                 LDKSignature htlc_signatures_arg_conv_12_ref;
30088                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
30089                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64); FREE(htlc_signatures_arg_conv_12);
30090                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
30091         }
30092         FREE(htlc_signatures_arg);
30093         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
30094         uint32_t ret_ref = 0;
30095         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30096         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30098         ret_ref = (uintptr_t)ret_var.inner;
30099         if (ret_var.is_owned) {
30100                 ret_ref |= 1;
30101         }
30102         return ret_ref;
30103 }
30104
30105 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
30106         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
30107 uint32_t ret_ref = 0;
30108 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30109 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30110 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30111 ret_ref = (uintptr_t)ret_var.inner;
30112 if (ret_var.is_owned) {
30113         ret_ref |= 1;
30114 }
30115         return ret_ref;
30116 }
30117 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
30118         LDKCommitmentSigned arg_conv;
30119         arg_conv.inner = (void*)(arg & (~1));
30120         arg_conv.is_owned = false;
30121         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30122         uint32_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
30123         return ret_conv;
30124 }
30125
30126 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint32_t orig) {
30127         LDKCommitmentSigned orig_conv;
30128         orig_conv.inner = (void*)(orig & (~1));
30129         orig_conv.is_owned = false;
30130         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30131         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
30132         uint32_t ret_ref = 0;
30133         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30134         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30136         ret_ref = (uintptr_t)ret_var.inner;
30137         if (ret_var.is_owned) {
30138                 ret_ref |= 1;
30139         }
30140         return ret_ref;
30141 }
30142
30143 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint32_t this_obj) {
30144         LDKRevokeAndACK this_obj_conv;
30145         this_obj_conv.inner = (void*)(this_obj & (~1));
30146         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30148         RevokeAndACK_free(this_obj_conv);
30149 }
30150
30151 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
30152         LDKRevokeAndACK this_ptr_conv;
30153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30154         this_ptr_conv.is_owned = false;
30155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30156         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30157         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
30158         return ret_arr;
30159 }
30160
30161 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30162         LDKRevokeAndACK this_ptr_conv;
30163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30164         this_ptr_conv.is_owned = false;
30165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30166         LDKThirtyTwoBytes val_ref;
30167         CHECK(val->arr_len == 32);
30168         memcpy(val_ref.data, val->elems, 32); FREE(val);
30169         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
30170 }
30171
30172 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
30173         LDKRevokeAndACK this_ptr_conv;
30174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30175         this_ptr_conv.is_owned = false;
30176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30177         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30178         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
30179         return ret_arr;
30180 }
30181
30182 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
30183         LDKRevokeAndACK this_ptr_conv;
30184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30185         this_ptr_conv.is_owned = false;
30186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30187         LDKThirtyTwoBytes val_ref;
30188         CHECK(val->arr_len == 32);
30189         memcpy(val_ref.data, val->elems, 32); FREE(val);
30190         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
30191 }
30192
30193 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
30194         LDKRevokeAndACK this_ptr_conv;
30195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30196         this_ptr_conv.is_owned = false;
30197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30198         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
30199         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
30200         return ret_arr;
30201 }
30202
30203 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) {
30204         LDKRevokeAndACK this_ptr_conv;
30205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30206         this_ptr_conv.is_owned = false;
30207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30208         LDKPublicKey val_ref;
30209         CHECK(val->arr_len == 33);
30210         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
30211         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
30212 }
30213
30214 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) {
30215         LDKThirtyTwoBytes channel_id_arg_ref;
30216         CHECK(channel_id_arg->arr_len == 32);
30217         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30218         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
30219         CHECK(per_commitment_secret_arg->arr_len == 32);
30220         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
30221         LDKPublicKey next_per_commitment_point_arg_ref;
30222         CHECK(next_per_commitment_point_arg->arr_len == 33);
30223         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
30224         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
30225         uint32_t ret_ref = 0;
30226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30229         ret_ref = (uintptr_t)ret_var.inner;
30230         if (ret_var.is_owned) {
30231                 ret_ref |= 1;
30232         }
30233         return ret_ref;
30234 }
30235
30236 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
30237         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
30238 uint32_t ret_ref = 0;
30239 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30240 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30241 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30242 ret_ref = (uintptr_t)ret_var.inner;
30243 if (ret_var.is_owned) {
30244         ret_ref |= 1;
30245 }
30246         return ret_ref;
30247 }
30248 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
30249         LDKRevokeAndACK arg_conv;
30250         arg_conv.inner = (void*)(arg & (~1));
30251         arg_conv.is_owned = false;
30252         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30253         uint32_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
30254         return ret_conv;
30255 }
30256
30257 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint32_t orig) {
30258         LDKRevokeAndACK orig_conv;
30259         orig_conv.inner = (void*)(orig & (~1));
30260         orig_conv.is_owned = false;
30261         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30262         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
30263         uint32_t ret_ref = 0;
30264         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30265         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30267         ret_ref = (uintptr_t)ret_var.inner;
30268         if (ret_var.is_owned) {
30269                 ret_ref |= 1;
30270         }
30271         return ret_ref;
30272 }
30273
30274 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint32_t this_obj) {
30275         LDKUpdateFee this_obj_conv;
30276         this_obj_conv.inner = (void*)(this_obj & (~1));
30277         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30279         UpdateFee_free(this_obj_conv);
30280 }
30281
30282 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
30283         LDKUpdateFee this_ptr_conv;
30284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30285         this_ptr_conv.is_owned = false;
30286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30287         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30288         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
30289         return ret_arr;
30290 }
30291
30292 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30293         LDKUpdateFee this_ptr_conv;
30294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30295         this_ptr_conv.is_owned = false;
30296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30297         LDKThirtyTwoBytes val_ref;
30298         CHECK(val->arr_len == 32);
30299         memcpy(val_ref.data, val->elems, 32); FREE(val);
30300         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
30301 }
30302
30303 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
30304         LDKUpdateFee this_ptr_conv;
30305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30306         this_ptr_conv.is_owned = false;
30307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30308         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
30309         return ret_conv;
30310 }
30311
30312 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
30313         LDKUpdateFee this_ptr_conv;
30314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30315         this_ptr_conv.is_owned = false;
30316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30317         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
30318 }
30319
30320 uint32_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
30321         LDKThirtyTwoBytes channel_id_arg_ref;
30322         CHECK(channel_id_arg->arr_len == 32);
30323         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30324         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
30325         uint32_t ret_ref = 0;
30326         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30327         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30329         ret_ref = (uintptr_t)ret_var.inner;
30330         if (ret_var.is_owned) {
30331                 ret_ref |= 1;
30332         }
30333         return ret_ref;
30334 }
30335
30336 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
30337         LDKUpdateFee ret_var = UpdateFee_clone(arg);
30338 uint32_t ret_ref = 0;
30339 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30340 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30341 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30342 ret_ref = (uintptr_t)ret_var.inner;
30343 if (ret_var.is_owned) {
30344         ret_ref |= 1;
30345 }
30346         return ret_ref;
30347 }
30348 uint32_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
30349         LDKUpdateFee arg_conv;
30350         arg_conv.inner = (void*)(arg & (~1));
30351         arg_conv.is_owned = false;
30352         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30353         uint32_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
30354         return ret_conv;
30355 }
30356
30357 uint32_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint32_t orig) {
30358         LDKUpdateFee orig_conv;
30359         orig_conv.inner = (void*)(orig & (~1));
30360         orig_conv.is_owned = false;
30361         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30362         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
30363         uint32_t ret_ref = 0;
30364         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30365         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30367         ret_ref = (uintptr_t)ret_var.inner;
30368         if (ret_var.is_owned) {
30369                 ret_ref |= 1;
30370         }
30371         return ret_ref;
30372 }
30373
30374 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint32_t this_obj) {
30375         LDKDataLossProtect this_obj_conv;
30376         this_obj_conv.inner = (void*)(this_obj & (~1));
30377         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30379         DataLossProtect_free(this_obj_conv);
30380 }
30381
30382 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) {
30383         LDKDataLossProtect this_ptr_conv;
30384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30385         this_ptr_conv.is_owned = false;
30386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30387         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30388         memcpy(ret_arr->elems, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
30389         return ret_arr;
30390 }
30391
30392 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) {
30393         LDKDataLossProtect this_ptr_conv;
30394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30395         this_ptr_conv.is_owned = false;
30396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30397         LDKThirtyTwoBytes val_ref;
30398         CHECK(val->arr_len == 32);
30399         memcpy(val_ref.data, val->elems, 32); FREE(val);
30400         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
30401 }
30402
30403 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) {
30404         LDKDataLossProtect this_ptr_conv;
30405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30406         this_ptr_conv.is_owned = false;
30407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30408         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
30409         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
30410         return ret_arr;
30411 }
30412
30413 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) {
30414         LDKDataLossProtect this_ptr_conv;
30415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30416         this_ptr_conv.is_owned = false;
30417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30418         LDKPublicKey val_ref;
30419         CHECK(val->arr_len == 33);
30420         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
30421         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
30422 }
30423
30424 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) {
30425         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
30426         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
30427         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
30428         LDKPublicKey my_current_per_commitment_point_arg_ref;
30429         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
30430         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);
30431         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
30432         uint32_t ret_ref = 0;
30433         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30434         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30436         ret_ref = (uintptr_t)ret_var.inner;
30437         if (ret_var.is_owned) {
30438                 ret_ref |= 1;
30439         }
30440         return ret_ref;
30441 }
30442
30443 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
30444         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
30445 uint32_t ret_ref = 0;
30446 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30447 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30448 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30449 ret_ref = (uintptr_t)ret_var.inner;
30450 if (ret_var.is_owned) {
30451         ret_ref |= 1;
30452 }
30453         return ret_ref;
30454 }
30455 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
30456         LDKDataLossProtect arg_conv;
30457         arg_conv.inner = (void*)(arg & (~1));
30458         arg_conv.is_owned = false;
30459         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30460         uint32_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
30461         return ret_conv;
30462 }
30463
30464 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint32_t orig) {
30465         LDKDataLossProtect orig_conv;
30466         orig_conv.inner = (void*)(orig & (~1));
30467         orig_conv.is_owned = false;
30468         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30469         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
30470         uint32_t ret_ref = 0;
30471         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30472         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30474         ret_ref = (uintptr_t)ret_var.inner;
30475         if (ret_var.is_owned) {
30476                 ret_ref |= 1;
30477         }
30478         return ret_ref;
30479 }
30480
30481 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint32_t this_obj) {
30482         LDKChannelReestablish this_obj_conv;
30483         this_obj_conv.inner = (void*)(this_obj & (~1));
30484         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30486         ChannelReestablish_free(this_obj_conv);
30487 }
30488
30489 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
30490         LDKChannelReestablish this_ptr_conv;
30491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30492         this_ptr_conv.is_owned = false;
30493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30494         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30495         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
30496         return ret_arr;
30497 }
30498
30499 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30500         LDKChannelReestablish this_ptr_conv;
30501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30502         this_ptr_conv.is_owned = false;
30503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30504         LDKThirtyTwoBytes val_ref;
30505         CHECK(val->arr_len == 32);
30506         memcpy(val_ref.data, val->elems, 32); FREE(val);
30507         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
30508 }
30509
30510 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
30511         LDKChannelReestablish this_ptr_conv;
30512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30513         this_ptr_conv.is_owned = false;
30514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30515         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
30516         return ret_conv;
30517 }
30518
30519 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) {
30520         LDKChannelReestablish this_ptr_conv;
30521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30522         this_ptr_conv.is_owned = false;
30523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30524         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
30525 }
30526
30527 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
30528         LDKChannelReestablish this_ptr_conv;
30529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30530         this_ptr_conv.is_owned = false;
30531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30532         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
30533         return ret_conv;
30534 }
30535
30536 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) {
30537         LDKChannelReestablish this_ptr_conv;
30538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30539         this_ptr_conv.is_owned = false;
30540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30541         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
30542 }
30543
30544 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
30545         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
30546 uint32_t ret_ref = 0;
30547 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30548 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30549 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30550 ret_ref = (uintptr_t)ret_var.inner;
30551 if (ret_var.is_owned) {
30552         ret_ref |= 1;
30553 }
30554         return ret_ref;
30555 }
30556 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
30557         LDKChannelReestablish arg_conv;
30558         arg_conv.inner = (void*)(arg & (~1));
30559         arg_conv.is_owned = false;
30560         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30561         uint32_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
30562         return ret_conv;
30563 }
30564
30565 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint32_t orig) {
30566         LDKChannelReestablish orig_conv;
30567         orig_conv.inner = (void*)(orig & (~1));
30568         orig_conv.is_owned = false;
30569         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30570         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
30571         uint32_t ret_ref = 0;
30572         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30573         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30575         ret_ref = (uintptr_t)ret_var.inner;
30576         if (ret_var.is_owned) {
30577                 ret_ref |= 1;
30578         }
30579         return ret_ref;
30580 }
30581
30582 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
30583         LDKAnnouncementSignatures this_obj_conv;
30584         this_obj_conv.inner = (void*)(this_obj & (~1));
30585         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30587         AnnouncementSignatures_free(this_obj_conv);
30588 }
30589
30590 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
30591         LDKAnnouncementSignatures this_ptr_conv;
30592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30593         this_ptr_conv.is_owned = false;
30594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30595         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30596         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
30597         return ret_arr;
30598 }
30599
30600 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30601         LDKAnnouncementSignatures this_ptr_conv;
30602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30603         this_ptr_conv.is_owned = false;
30604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30605         LDKThirtyTwoBytes val_ref;
30606         CHECK(val->arr_len == 32);
30607         memcpy(val_ref.data, val->elems, 32); FREE(val);
30608         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
30609 }
30610
30611 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
30612         LDKAnnouncementSignatures this_ptr_conv;
30613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30614         this_ptr_conv.is_owned = false;
30615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30616         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
30617         return ret_conv;
30618 }
30619
30620 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
30621         LDKAnnouncementSignatures this_ptr_conv;
30622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30623         this_ptr_conv.is_owned = false;
30624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30625         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
30626 }
30627
30628 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
30629         LDKAnnouncementSignatures this_ptr_conv;
30630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30631         this_ptr_conv.is_owned = false;
30632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30633         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30634         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
30635         return ret_arr;
30636 }
30637
30638 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
30639         LDKAnnouncementSignatures this_ptr_conv;
30640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30641         this_ptr_conv.is_owned = false;
30642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30643         LDKSignature val_ref;
30644         CHECK(val->arr_len == 64);
30645         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30646         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
30647 }
30648
30649 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
30650         LDKAnnouncementSignatures this_ptr_conv;
30651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30652         this_ptr_conv.is_owned = false;
30653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30654         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30655         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
30656         return ret_arr;
30657 }
30658
30659 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
30660         LDKAnnouncementSignatures this_ptr_conv;
30661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30662         this_ptr_conv.is_owned = false;
30663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30664         LDKSignature val_ref;
30665         CHECK(val->arr_len == 64);
30666         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30667         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
30668 }
30669
30670 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) {
30671         LDKThirtyTwoBytes channel_id_arg_ref;
30672         CHECK(channel_id_arg->arr_len == 32);
30673         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30674         LDKSignature node_signature_arg_ref;
30675         CHECK(node_signature_arg->arr_len == 64);
30676         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
30677         LDKSignature bitcoin_signature_arg_ref;
30678         CHECK(bitcoin_signature_arg->arr_len == 64);
30679         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
30680         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
30681         uint32_t ret_ref = 0;
30682         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30683         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30685         ret_ref = (uintptr_t)ret_var.inner;
30686         if (ret_var.is_owned) {
30687                 ret_ref |= 1;
30688         }
30689         return ret_ref;
30690 }
30691
30692 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
30693         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
30694 uint32_t ret_ref = 0;
30695 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30696 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30697 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30698 ret_ref = (uintptr_t)ret_var.inner;
30699 if (ret_var.is_owned) {
30700         ret_ref |= 1;
30701 }
30702         return ret_ref;
30703 }
30704 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
30705         LDKAnnouncementSignatures arg_conv;
30706         arg_conv.inner = (void*)(arg & (~1));
30707         arg_conv.is_owned = false;
30708         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30709         uint32_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
30710         return ret_conv;
30711 }
30712
30713 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
30714         LDKAnnouncementSignatures orig_conv;
30715         orig_conv.inner = (void*)(orig & (~1));
30716         orig_conv.is_owned = false;
30717         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30718         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
30719         uint32_t ret_ref = 0;
30720         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30721         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30722         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30723         ret_ref = (uintptr_t)ret_var.inner;
30724         if (ret_var.is_owned) {
30725                 ret_ref |= 1;
30726         }
30727         return ret_ref;
30728 }
30729
30730 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint32_t this_ptr) {
30731         if ((this_ptr & 1) != 0) return;
30732         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
30733         CHECK_ACCESS(this_ptr_ptr);
30734         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
30735         FREE((void*)this_ptr);
30736         NetAddress_free(this_ptr_conv);
30737 }
30738
30739 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
30740         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30741         *ret_copy = NetAddress_clone(arg);
30742 uint32_t ret_ref = (uintptr_t)ret_copy;
30743         return ret_ref;
30744 }
30745 uint32_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint32_t arg) {
30746         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
30747         uint32_t ret_conv = NetAddress_clone_ptr(arg_conv);
30748         return ret_conv;
30749 }
30750
30751 uint32_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint32_t orig) {
30752         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
30753         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30754         *ret_copy = NetAddress_clone(orig_conv);
30755         uint32_t ret_ref = (uintptr_t)ret_copy;
30756         return ret_ref;
30757 }
30758
30759 uint32_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
30760         LDKFourBytes addr_ref;
30761         CHECK(addr->arr_len == 4);
30762         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
30763         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30764         *ret_copy = NetAddress_ipv4(addr_ref, port);
30765         uint32_t ret_ref = (uintptr_t)ret_copy;
30766         return ret_ref;
30767 }
30768
30769 uint32_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
30770         LDKSixteenBytes addr_ref;
30771         CHECK(addr->arr_len == 16);
30772         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
30773         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30774         *ret_copy = NetAddress_ipv6(addr_ref, port);
30775         uint32_t ret_ref = (uintptr_t)ret_copy;
30776         return ret_ref;
30777 }
30778
30779 uint32_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
30780         LDKTwelveBytes a_ref;
30781         CHECK(a->arr_len == 12);
30782         memcpy(a_ref.data, a->elems, 12); FREE(a);
30783         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30784         *ret_copy = NetAddress_onion_v2(a_ref);
30785         uint32_t ret_ref = (uintptr_t)ret_copy;
30786         return ret_ref;
30787 }
30788
30789 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) {
30790         LDKThirtyTwoBytes ed25519_pubkey_ref;
30791         CHECK(ed25519_pubkey->arr_len == 32);
30792         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
30793         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30794         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
30795         uint32_t ret_ref = (uintptr_t)ret_copy;
30796         return ret_ref;
30797 }
30798
30799 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint32_t obj) {
30800         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
30801         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
30802         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30803         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30804         CVec_u8Z_free(ret_var);
30805         return ret_arr;
30806 }
30807
30808 uint32_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
30809         LDKu8slice ser_ref;
30810         ser_ref.datalen = ser->arr_len;
30811         ser_ref.data = ser->elems;
30812         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
30813         *ret_conv = NetAddress_read(ser_ref);
30814         FREE(ser);
30815         return (uint32_t)ret_conv;
30816 }
30817
30818 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
30819         LDKUnsignedNodeAnnouncement this_obj_conv;
30820         this_obj_conv.inner = (void*)(this_obj & (~1));
30821         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30823         UnsignedNodeAnnouncement_free(this_obj_conv);
30824 }
30825
30826 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
30827         LDKUnsignedNodeAnnouncement this_ptr_conv;
30828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30829         this_ptr_conv.is_owned = false;
30830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30831         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
30832         uint32_t ret_ref = 0;
30833         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30834         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30836         ret_ref = (uintptr_t)ret_var.inner;
30837         if (ret_var.is_owned) {
30838                 ret_ref |= 1;
30839         }
30840         return ret_ref;
30841 }
30842
30843 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
30844         LDKUnsignedNodeAnnouncement this_ptr_conv;
30845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30846         this_ptr_conv.is_owned = false;
30847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30848         LDKNodeFeatures val_conv;
30849         val_conv.inner = (void*)(val & (~1));
30850         val_conv.is_owned = (val & 1) || (val == 0);
30851         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30852         val_conv = NodeFeatures_clone(&val_conv);
30853         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
30854 }
30855
30856 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
30857         LDKUnsignedNodeAnnouncement this_ptr_conv;
30858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30859         this_ptr_conv.is_owned = false;
30860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30861         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
30862         return ret_conv;
30863 }
30864
30865 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
30866         LDKUnsignedNodeAnnouncement this_ptr_conv;
30867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30868         this_ptr_conv.is_owned = false;
30869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30870         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
30871 }
30872
30873 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
30874         LDKUnsignedNodeAnnouncement this_ptr_conv;
30875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30876         this_ptr_conv.is_owned = false;
30877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30878         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
30879         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
30880         return ret_arr;
30881 }
30882
30883 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
30884         LDKUnsignedNodeAnnouncement this_ptr_conv;
30885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30886         this_ptr_conv.is_owned = false;
30887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30888         LDKPublicKey val_ref;
30889         CHECK(val->arr_len == 33);
30890         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
30891         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
30892 }
30893
30894 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
30895         LDKUnsignedNodeAnnouncement this_ptr_conv;
30896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30897         this_ptr_conv.is_owned = false;
30898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30899         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
30900         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
30901         return ret_arr;
30902 }
30903
30904 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
30905         LDKUnsignedNodeAnnouncement this_ptr_conv;
30906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30907         this_ptr_conv.is_owned = false;
30908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30909         LDKThreeBytes val_ref;
30910         CHECK(val->arr_len == 3);
30911         memcpy(val_ref.data, val->elems, 3); FREE(val);
30912         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
30913 }
30914
30915 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
30916         LDKUnsignedNodeAnnouncement this_ptr_conv;
30917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30918         this_ptr_conv.is_owned = false;
30919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30920         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30921         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
30922         return ret_arr;
30923 }
30924
30925 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
30926         LDKUnsignedNodeAnnouncement this_ptr_conv;
30927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30928         this_ptr_conv.is_owned = false;
30929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30930         LDKThirtyTwoBytes val_ref;
30931         CHECK(val->arr_len == 32);
30932         memcpy(val_ref.data, val->elems, 32); FREE(val);
30933         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
30934 }
30935
30936 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
30937         LDKUnsignedNodeAnnouncement this_ptr_conv;
30938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30939         this_ptr_conv.is_owned = false;
30940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30941         LDKCVec_NetAddressZ val_constr;
30942         val_constr.datalen = val->arr_len;
30943         if (val_constr.datalen > 0)
30944                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
30945         else
30946                 val_constr.data = NULL;
30947         uint32_t* val_vals = val->elems;
30948         for (size_t m = 0; m < val_constr.datalen; m++) {
30949                 uint32_t val_conv_12 = val_vals[m];
30950                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
30951                 CHECK_ACCESS(val_conv_12_ptr);
30952                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
30953                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
30954                 val_constr.data[m] = val_conv_12_conv;
30955         }
30956         FREE(val);
30957         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
30958 }
30959
30960 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
30961         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
30962 uint32_t ret_ref = 0;
30963 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30964 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30965 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30966 ret_ref = (uintptr_t)ret_var.inner;
30967 if (ret_var.is_owned) {
30968         ret_ref |= 1;
30969 }
30970         return ret_ref;
30971 }
30972 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
30973         LDKUnsignedNodeAnnouncement arg_conv;
30974         arg_conv.inner = (void*)(arg & (~1));
30975         arg_conv.is_owned = false;
30976         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30977         uint32_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
30978         return ret_conv;
30979 }
30980
30981 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
30982         LDKUnsignedNodeAnnouncement orig_conv;
30983         orig_conv.inner = (void*)(orig & (~1));
30984         orig_conv.is_owned = false;
30985         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30986         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
30987         uint32_t ret_ref = 0;
30988         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30989         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30991         ret_ref = (uintptr_t)ret_var.inner;
30992         if (ret_var.is_owned) {
30993                 ret_ref |= 1;
30994         }
30995         return ret_ref;
30996 }
30997
30998 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
30999         LDKNodeAnnouncement this_obj_conv;
31000         this_obj_conv.inner = (void*)(this_obj & (~1));
31001         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31003         NodeAnnouncement_free(this_obj_conv);
31004 }
31005
31006 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
31007         LDKNodeAnnouncement this_ptr_conv;
31008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31009         this_ptr_conv.is_owned = false;
31010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31011         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31012         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
31013         return ret_arr;
31014 }
31015
31016 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
31017         LDKNodeAnnouncement this_ptr_conv;
31018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31019         this_ptr_conv.is_owned = false;
31020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31021         LDKSignature val_ref;
31022         CHECK(val->arr_len == 64);
31023         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31024         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
31025 }
31026
31027 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
31028         LDKNodeAnnouncement this_ptr_conv;
31029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31030         this_ptr_conv.is_owned = false;
31031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31032         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
31033         uint32_t ret_ref = 0;
31034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31037         ret_ref = (uintptr_t)ret_var.inner;
31038         if (ret_var.is_owned) {
31039                 ret_ref |= 1;
31040         }
31041         return ret_ref;
31042 }
31043
31044 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
31045         LDKNodeAnnouncement this_ptr_conv;
31046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31047         this_ptr_conv.is_owned = false;
31048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31049         LDKUnsignedNodeAnnouncement val_conv;
31050         val_conv.inner = (void*)(val & (~1));
31051         val_conv.is_owned = (val & 1) || (val == 0);
31052         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31053         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
31054         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
31055 }
31056
31057 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
31058         LDKSignature signature_arg_ref;
31059         CHECK(signature_arg->arr_len == 64);
31060         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
31061         LDKUnsignedNodeAnnouncement contents_arg_conv;
31062         contents_arg_conv.inner = (void*)(contents_arg & (~1));
31063         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
31064         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
31065         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
31066         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
31067         uint32_t ret_ref = 0;
31068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31071         ret_ref = (uintptr_t)ret_var.inner;
31072         if (ret_var.is_owned) {
31073                 ret_ref |= 1;
31074         }
31075         return ret_ref;
31076 }
31077
31078 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
31079         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
31080 uint32_t ret_ref = 0;
31081 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31082 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31083 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31084 ret_ref = (uintptr_t)ret_var.inner;
31085 if (ret_var.is_owned) {
31086         ret_ref |= 1;
31087 }
31088         return ret_ref;
31089 }
31090 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
31091         LDKNodeAnnouncement arg_conv;
31092         arg_conv.inner = (void*)(arg & (~1));
31093         arg_conv.is_owned = false;
31094         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31095         uint32_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
31096         return ret_conv;
31097 }
31098
31099 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint32_t orig) {
31100         LDKNodeAnnouncement orig_conv;
31101         orig_conv.inner = (void*)(orig & (~1));
31102         orig_conv.is_owned = false;
31103         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31104         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
31105         uint32_t ret_ref = 0;
31106         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31107         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31109         ret_ref = (uintptr_t)ret_var.inner;
31110         if (ret_var.is_owned) {
31111                 ret_ref |= 1;
31112         }
31113         return ret_ref;
31114 }
31115
31116 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
31117         LDKUnsignedChannelAnnouncement this_obj_conv;
31118         this_obj_conv.inner = (void*)(this_obj & (~1));
31119         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31121         UnsignedChannelAnnouncement_free(this_obj_conv);
31122 }
31123
31124 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
31125         LDKUnsignedChannelAnnouncement this_ptr_conv;
31126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31127         this_ptr_conv.is_owned = false;
31128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31129         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
31130         uint32_t ret_ref = 0;
31131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31134         ret_ref = (uintptr_t)ret_var.inner;
31135         if (ret_var.is_owned) {
31136                 ret_ref |= 1;
31137         }
31138         return ret_ref;
31139 }
31140
31141 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
31142         LDKUnsignedChannelAnnouncement this_ptr_conv;
31143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31144         this_ptr_conv.is_owned = false;
31145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31146         LDKChannelFeatures val_conv;
31147         val_conv.inner = (void*)(val & (~1));
31148         val_conv.is_owned = (val & 1) || (val == 0);
31149         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31150         val_conv = ChannelFeatures_clone(&val_conv);
31151         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
31152 }
31153
31154 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
31155         LDKUnsignedChannelAnnouncement this_ptr_conv;
31156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31157         this_ptr_conv.is_owned = false;
31158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31159         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31160         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
31161         return ret_arr;
31162 }
31163
31164 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31165         LDKUnsignedChannelAnnouncement this_ptr_conv;
31166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31167         this_ptr_conv.is_owned = false;
31168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31169         LDKThirtyTwoBytes val_ref;
31170         CHECK(val->arr_len == 32);
31171         memcpy(val_ref.data, val->elems, 32); FREE(val);
31172         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
31173 }
31174
31175 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
31176         LDKUnsignedChannelAnnouncement this_ptr_conv;
31177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31178         this_ptr_conv.is_owned = false;
31179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31180         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
31181         return ret_conv;
31182 }
31183
31184 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
31185         LDKUnsignedChannelAnnouncement this_ptr_conv;
31186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31187         this_ptr_conv.is_owned = false;
31188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31189         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
31190 }
31191
31192 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
31193         LDKUnsignedChannelAnnouncement this_ptr_conv;
31194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31195         this_ptr_conv.is_owned = false;
31196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31197         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31198         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
31199         return ret_arr;
31200 }
31201
31202 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
31203         LDKUnsignedChannelAnnouncement this_ptr_conv;
31204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31205         this_ptr_conv.is_owned = false;
31206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31207         LDKPublicKey val_ref;
31208         CHECK(val->arr_len == 33);
31209         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31210         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
31211 }
31212
31213 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
31214         LDKUnsignedChannelAnnouncement this_ptr_conv;
31215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31216         this_ptr_conv.is_owned = false;
31217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31218         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31219         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
31220         return ret_arr;
31221 }
31222
31223 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
31224         LDKUnsignedChannelAnnouncement this_ptr_conv;
31225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31226         this_ptr_conv.is_owned = false;
31227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31228         LDKPublicKey val_ref;
31229         CHECK(val->arr_len == 33);
31230         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31231         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
31232 }
31233
31234 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
31235         LDKUnsignedChannelAnnouncement this_ptr_conv;
31236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31237         this_ptr_conv.is_owned = false;
31238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31239         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31240         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
31241         return ret_arr;
31242 }
31243
31244 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
31245         LDKUnsignedChannelAnnouncement this_ptr_conv;
31246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31247         this_ptr_conv.is_owned = false;
31248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31249         LDKPublicKey val_ref;
31250         CHECK(val->arr_len == 33);
31251         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31252         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
31253 }
31254
31255 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
31256         LDKUnsignedChannelAnnouncement this_ptr_conv;
31257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31258         this_ptr_conv.is_owned = false;
31259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31260         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31261         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
31262         return ret_arr;
31263 }
31264
31265 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
31266         LDKUnsignedChannelAnnouncement this_ptr_conv;
31267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31268         this_ptr_conv.is_owned = false;
31269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31270         LDKPublicKey val_ref;
31271         CHECK(val->arr_len == 33);
31272         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31273         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
31274 }
31275
31276 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
31277         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
31278 uint32_t ret_ref = 0;
31279 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31280 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31281 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31282 ret_ref = (uintptr_t)ret_var.inner;
31283 if (ret_var.is_owned) {
31284         ret_ref |= 1;
31285 }
31286         return ret_ref;
31287 }
31288 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
31289         LDKUnsignedChannelAnnouncement arg_conv;
31290         arg_conv.inner = (void*)(arg & (~1));
31291         arg_conv.is_owned = false;
31292         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31293         uint32_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
31294         return ret_conv;
31295 }
31296
31297 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
31298         LDKUnsignedChannelAnnouncement orig_conv;
31299         orig_conv.inner = (void*)(orig & (~1));
31300         orig_conv.is_owned = false;
31301         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31302         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
31303         uint32_t ret_ref = 0;
31304         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31305         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31307         ret_ref = (uintptr_t)ret_var.inner;
31308         if (ret_var.is_owned) {
31309                 ret_ref |= 1;
31310         }
31311         return ret_ref;
31312 }
31313
31314 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
31315         LDKChannelAnnouncement this_obj_conv;
31316         this_obj_conv.inner = (void*)(this_obj & (~1));
31317         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31319         ChannelAnnouncement_free(this_obj_conv);
31320 }
31321
31322 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
31323         LDKChannelAnnouncement this_ptr_conv;
31324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31325         this_ptr_conv.is_owned = false;
31326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31327         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31328         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
31329         return ret_arr;
31330 }
31331
31332 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
31333         LDKChannelAnnouncement this_ptr_conv;
31334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31335         this_ptr_conv.is_owned = false;
31336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31337         LDKSignature val_ref;
31338         CHECK(val->arr_len == 64);
31339         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31340         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
31341 }
31342
31343 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
31344         LDKChannelAnnouncement this_ptr_conv;
31345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31346         this_ptr_conv.is_owned = false;
31347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31348         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31349         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
31350         return ret_arr;
31351 }
31352
31353 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
31354         LDKChannelAnnouncement this_ptr_conv;
31355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31356         this_ptr_conv.is_owned = false;
31357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31358         LDKSignature val_ref;
31359         CHECK(val->arr_len == 64);
31360         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31361         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
31362 }
31363
31364 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
31365         LDKChannelAnnouncement this_ptr_conv;
31366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31367         this_ptr_conv.is_owned = false;
31368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31369         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31370         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
31371         return ret_arr;
31372 }
31373
31374 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
31375         LDKChannelAnnouncement this_ptr_conv;
31376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31377         this_ptr_conv.is_owned = false;
31378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31379         LDKSignature val_ref;
31380         CHECK(val->arr_len == 64);
31381         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31382         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
31383 }
31384
31385 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
31386         LDKChannelAnnouncement this_ptr_conv;
31387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31388         this_ptr_conv.is_owned = false;
31389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31390         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31391         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
31392         return ret_arr;
31393 }
31394
31395 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
31396         LDKChannelAnnouncement this_ptr_conv;
31397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31398         this_ptr_conv.is_owned = false;
31399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31400         LDKSignature val_ref;
31401         CHECK(val->arr_len == 64);
31402         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31403         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
31404 }
31405
31406 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
31407         LDKChannelAnnouncement this_ptr_conv;
31408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31409         this_ptr_conv.is_owned = false;
31410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31411         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
31412         uint32_t ret_ref = 0;
31413         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31414         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31416         ret_ref = (uintptr_t)ret_var.inner;
31417         if (ret_var.is_owned) {
31418                 ret_ref |= 1;
31419         }
31420         return ret_ref;
31421 }
31422
31423 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
31424         LDKChannelAnnouncement this_ptr_conv;
31425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31426         this_ptr_conv.is_owned = false;
31427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31428         LDKUnsignedChannelAnnouncement val_conv;
31429         val_conv.inner = (void*)(val & (~1));
31430         val_conv.is_owned = (val & 1) || (val == 0);
31431         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31432         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
31433         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
31434 }
31435
31436 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) {
31437         LDKSignature node_signature_1_arg_ref;
31438         CHECK(node_signature_1_arg->arr_len == 64);
31439         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
31440         LDKSignature node_signature_2_arg_ref;
31441         CHECK(node_signature_2_arg->arr_len == 64);
31442         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
31443         LDKSignature bitcoin_signature_1_arg_ref;
31444         CHECK(bitcoin_signature_1_arg->arr_len == 64);
31445         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
31446         LDKSignature bitcoin_signature_2_arg_ref;
31447         CHECK(bitcoin_signature_2_arg->arr_len == 64);
31448         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
31449         LDKUnsignedChannelAnnouncement contents_arg_conv;
31450         contents_arg_conv.inner = (void*)(contents_arg & (~1));
31451         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
31452         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
31453         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
31454         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);
31455         uint32_t ret_ref = 0;
31456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31459         ret_ref = (uintptr_t)ret_var.inner;
31460         if (ret_var.is_owned) {
31461                 ret_ref |= 1;
31462         }
31463         return ret_ref;
31464 }
31465
31466 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
31467         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
31468 uint32_t ret_ref = 0;
31469 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31470 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31471 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31472 ret_ref = (uintptr_t)ret_var.inner;
31473 if (ret_var.is_owned) {
31474         ret_ref |= 1;
31475 }
31476         return ret_ref;
31477 }
31478 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
31479         LDKChannelAnnouncement arg_conv;
31480         arg_conv.inner = (void*)(arg & (~1));
31481         arg_conv.is_owned = false;
31482         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31483         uint32_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
31484         return ret_conv;
31485 }
31486
31487 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
31488         LDKChannelAnnouncement orig_conv;
31489         orig_conv.inner = (void*)(orig & (~1));
31490         orig_conv.is_owned = false;
31491         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31492         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
31493         uint32_t ret_ref = 0;
31494         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31495         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31497         ret_ref = (uintptr_t)ret_var.inner;
31498         if (ret_var.is_owned) {
31499                 ret_ref |= 1;
31500         }
31501         return ret_ref;
31502 }
31503
31504 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
31505         LDKUnsignedChannelUpdate this_obj_conv;
31506         this_obj_conv.inner = (void*)(this_obj & (~1));
31507         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31509         UnsignedChannelUpdate_free(this_obj_conv);
31510 }
31511
31512 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
31513         LDKUnsignedChannelUpdate this_ptr_conv;
31514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31515         this_ptr_conv.is_owned = false;
31516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31517         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31518         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
31519         return ret_arr;
31520 }
31521
31522 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31523         LDKUnsignedChannelUpdate this_ptr_conv;
31524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31525         this_ptr_conv.is_owned = false;
31526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31527         LDKThirtyTwoBytes val_ref;
31528         CHECK(val->arr_len == 32);
31529         memcpy(val_ref.data, val->elems, 32); FREE(val);
31530         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
31531 }
31532
31533 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
31534         LDKUnsignedChannelUpdate this_ptr_conv;
31535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31536         this_ptr_conv.is_owned = false;
31537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31538         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
31539         return ret_conv;
31540 }
31541
31542 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
31543         LDKUnsignedChannelUpdate this_ptr_conv;
31544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31545         this_ptr_conv.is_owned = false;
31546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31547         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
31548 }
31549
31550 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
31551         LDKUnsignedChannelUpdate this_ptr_conv;
31552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31553         this_ptr_conv.is_owned = false;
31554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31555         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
31556         return ret_conv;
31557 }
31558
31559 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
31560         LDKUnsignedChannelUpdate this_ptr_conv;
31561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31562         this_ptr_conv.is_owned = false;
31563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31564         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
31565 }
31566
31567 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
31568         LDKUnsignedChannelUpdate this_ptr_conv;
31569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31570         this_ptr_conv.is_owned = false;
31571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31572         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
31573         return ret_conv;
31574 }
31575
31576 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
31577         LDKUnsignedChannelUpdate this_ptr_conv;
31578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31579         this_ptr_conv.is_owned = false;
31580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31581         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
31582 }
31583
31584 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
31585         LDKUnsignedChannelUpdate this_ptr_conv;
31586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31587         this_ptr_conv.is_owned = false;
31588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31589         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
31590         return ret_conv;
31591 }
31592
31593 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
31594         LDKUnsignedChannelUpdate this_ptr_conv;
31595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31596         this_ptr_conv.is_owned = false;
31597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31598         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
31599 }
31600
31601 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
31602         LDKUnsignedChannelUpdate this_ptr_conv;
31603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31604         this_ptr_conv.is_owned = false;
31605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31606         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
31607         return ret_conv;
31608 }
31609
31610 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
31611         LDKUnsignedChannelUpdate this_ptr_conv;
31612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31613         this_ptr_conv.is_owned = false;
31614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31615         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
31616 }
31617
31618 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
31619         LDKUnsignedChannelUpdate this_ptr_conv;
31620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31621         this_ptr_conv.is_owned = false;
31622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31623         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
31624         return ret_conv;
31625 }
31626
31627 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
31628         LDKUnsignedChannelUpdate this_ptr_conv;
31629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31630         this_ptr_conv.is_owned = false;
31631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31632         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
31633 }
31634
31635 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
31636         LDKUnsignedChannelUpdate this_ptr_conv;
31637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31638         this_ptr_conv.is_owned = false;
31639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31640         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
31641         return ret_conv;
31642 }
31643
31644 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
31645         LDKUnsignedChannelUpdate this_ptr_conv;
31646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31647         this_ptr_conv.is_owned = false;
31648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31649         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
31650 }
31651
31652 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_excess_data"))) TS_UnsignedChannelUpdate_set_excess_data(uint32_t this_ptr, int8_tArray val) {
31653         LDKUnsignedChannelUpdate this_ptr_conv;
31654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31655         this_ptr_conv.is_owned = false;
31656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31657         LDKCVec_u8Z val_ref;
31658         val_ref.datalen = val->arr_len;
31659         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
31660         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
31661         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
31662 }
31663
31664 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
31665         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
31666 uint32_t ret_ref = 0;
31667 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31668 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31669 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31670 ret_ref = (uintptr_t)ret_var.inner;
31671 if (ret_var.is_owned) {
31672         ret_ref |= 1;
31673 }
31674         return ret_ref;
31675 }
31676 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
31677         LDKUnsignedChannelUpdate arg_conv;
31678         arg_conv.inner = (void*)(arg & (~1));
31679         arg_conv.is_owned = false;
31680         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31681         uint32_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
31682         return ret_conv;
31683 }
31684
31685 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
31686         LDKUnsignedChannelUpdate orig_conv;
31687         orig_conv.inner = (void*)(orig & (~1));
31688         orig_conv.is_owned = false;
31689         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31690         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
31691         uint32_t ret_ref = 0;
31692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31695         ret_ref = (uintptr_t)ret_var.inner;
31696         if (ret_var.is_owned) {
31697                 ret_ref |= 1;
31698         }
31699         return ret_ref;
31700 }
31701
31702 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint32_t this_obj) {
31703         LDKChannelUpdate this_obj_conv;
31704         this_obj_conv.inner = (void*)(this_obj & (~1));
31705         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31707         ChannelUpdate_free(this_obj_conv);
31708 }
31709
31710 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
31711         LDKChannelUpdate this_ptr_conv;
31712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31713         this_ptr_conv.is_owned = false;
31714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31715         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31716         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
31717         return ret_arr;
31718 }
31719
31720 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
31721         LDKChannelUpdate this_ptr_conv;
31722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31723         this_ptr_conv.is_owned = false;
31724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31725         LDKSignature val_ref;
31726         CHECK(val->arr_len == 64);
31727         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31728         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
31729 }
31730
31731 uint32_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
31732         LDKChannelUpdate this_ptr_conv;
31733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31734         this_ptr_conv.is_owned = false;
31735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31736         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
31737         uint32_t ret_ref = 0;
31738         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31739         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31741         ret_ref = (uintptr_t)ret_var.inner;
31742         if (ret_var.is_owned) {
31743                 ret_ref |= 1;
31744         }
31745         return ret_ref;
31746 }
31747
31748 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
31749         LDKChannelUpdate this_ptr_conv;
31750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31751         this_ptr_conv.is_owned = false;
31752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31753         LDKUnsignedChannelUpdate val_conv;
31754         val_conv.inner = (void*)(val & (~1));
31755         val_conv.is_owned = (val & 1) || (val == 0);
31756         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31757         val_conv = UnsignedChannelUpdate_clone(&val_conv);
31758         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
31759 }
31760
31761 uint32_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
31762         LDKSignature signature_arg_ref;
31763         CHECK(signature_arg->arr_len == 64);
31764         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
31765         LDKUnsignedChannelUpdate contents_arg_conv;
31766         contents_arg_conv.inner = (void*)(contents_arg & (~1));
31767         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
31768         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
31769         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
31770         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
31771         uint32_t ret_ref = 0;
31772         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31773         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31775         ret_ref = (uintptr_t)ret_var.inner;
31776         if (ret_var.is_owned) {
31777                 ret_ref |= 1;
31778         }
31779         return ret_ref;
31780 }
31781
31782 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
31783         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
31784 uint32_t ret_ref = 0;
31785 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31786 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31787 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31788 ret_ref = (uintptr_t)ret_var.inner;
31789 if (ret_var.is_owned) {
31790         ret_ref |= 1;
31791 }
31792         return ret_ref;
31793 }
31794 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
31795         LDKChannelUpdate arg_conv;
31796         arg_conv.inner = (void*)(arg & (~1));
31797         arg_conv.is_owned = false;
31798         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31799         uint32_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
31800         return ret_conv;
31801 }
31802
31803 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint32_t orig) {
31804         LDKChannelUpdate orig_conv;
31805         orig_conv.inner = (void*)(orig & (~1));
31806         orig_conv.is_owned = false;
31807         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31808         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
31809         uint32_t ret_ref = 0;
31810         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31811         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31813         ret_ref = (uintptr_t)ret_var.inner;
31814         if (ret_var.is_owned) {
31815                 ret_ref |= 1;
31816         }
31817         return ret_ref;
31818 }
31819
31820 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint32_t this_obj) {
31821         LDKQueryChannelRange this_obj_conv;
31822         this_obj_conv.inner = (void*)(this_obj & (~1));
31823         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31825         QueryChannelRange_free(this_obj_conv);
31826 }
31827
31828 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
31829         LDKQueryChannelRange this_ptr_conv;
31830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31831         this_ptr_conv.is_owned = false;
31832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31833         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31834         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
31835         return ret_arr;
31836 }
31837
31838 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31839         LDKQueryChannelRange this_ptr_conv;
31840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31841         this_ptr_conv.is_owned = false;
31842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31843         LDKThirtyTwoBytes val_ref;
31844         CHECK(val->arr_len == 32);
31845         memcpy(val_ref.data, val->elems, 32); FREE(val);
31846         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
31847 }
31848
31849 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
31850         LDKQueryChannelRange this_ptr_conv;
31851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31852         this_ptr_conv.is_owned = false;
31853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31854         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
31855         return ret_conv;
31856 }
31857
31858 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
31859         LDKQueryChannelRange this_ptr_conv;
31860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31861         this_ptr_conv.is_owned = false;
31862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31863         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
31864 }
31865
31866 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
31867         LDKQueryChannelRange this_ptr_conv;
31868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31869         this_ptr_conv.is_owned = false;
31870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31871         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
31872         return ret_conv;
31873 }
31874
31875 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
31876         LDKQueryChannelRange this_ptr_conv;
31877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31878         this_ptr_conv.is_owned = false;
31879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31880         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
31881 }
31882
31883 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) {
31884         LDKThirtyTwoBytes chain_hash_arg_ref;
31885         CHECK(chain_hash_arg->arr_len == 32);
31886         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
31887         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
31888         uint32_t ret_ref = 0;
31889         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31890         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31892         ret_ref = (uintptr_t)ret_var.inner;
31893         if (ret_var.is_owned) {
31894                 ret_ref |= 1;
31895         }
31896         return ret_ref;
31897 }
31898
31899 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
31900         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
31901 uint32_t ret_ref = 0;
31902 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31903 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31904 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31905 ret_ref = (uintptr_t)ret_var.inner;
31906 if (ret_var.is_owned) {
31907         ret_ref |= 1;
31908 }
31909         return ret_ref;
31910 }
31911 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
31912         LDKQueryChannelRange arg_conv;
31913         arg_conv.inner = (void*)(arg & (~1));
31914         arg_conv.is_owned = false;
31915         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31916         uint32_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
31917         return ret_conv;
31918 }
31919
31920 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint32_t orig) {
31921         LDKQueryChannelRange orig_conv;
31922         orig_conv.inner = (void*)(orig & (~1));
31923         orig_conv.is_owned = false;
31924         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31925         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
31926         uint32_t ret_ref = 0;
31927         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31928         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31930         ret_ref = (uintptr_t)ret_var.inner;
31931         if (ret_var.is_owned) {
31932                 ret_ref |= 1;
31933         }
31934         return ret_ref;
31935 }
31936
31937 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
31938         LDKReplyChannelRange this_obj_conv;
31939         this_obj_conv.inner = (void*)(this_obj & (~1));
31940         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31942         ReplyChannelRange_free(this_obj_conv);
31943 }
31944
31945 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
31946         LDKReplyChannelRange this_ptr_conv;
31947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31948         this_ptr_conv.is_owned = false;
31949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31950         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31951         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
31952         return ret_arr;
31953 }
31954
31955 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31956         LDKReplyChannelRange this_ptr_conv;
31957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31958         this_ptr_conv.is_owned = false;
31959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31960         LDKThirtyTwoBytes val_ref;
31961         CHECK(val->arr_len == 32);
31962         memcpy(val_ref.data, val->elems, 32); FREE(val);
31963         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
31964 }
31965
31966 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
31967         LDKReplyChannelRange this_ptr_conv;
31968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31969         this_ptr_conv.is_owned = false;
31970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31971         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
31972         return ret_conv;
31973 }
31974
31975 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
31976         LDKReplyChannelRange this_ptr_conv;
31977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31978         this_ptr_conv.is_owned = false;
31979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31980         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
31981 }
31982
31983 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
31984         LDKReplyChannelRange this_ptr_conv;
31985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31986         this_ptr_conv.is_owned = false;
31987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31988         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
31989         return ret_conv;
31990 }
31991
31992 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
31993         LDKReplyChannelRange this_ptr_conv;
31994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31995         this_ptr_conv.is_owned = false;
31996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31997         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
31998 }
31999
32000 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
32001         LDKReplyChannelRange this_ptr_conv;
32002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32003         this_ptr_conv.is_owned = false;
32004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32005         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
32006         return ret_conv;
32007 }
32008
32009 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
32010         LDKReplyChannelRange this_ptr_conv;
32011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32012         this_ptr_conv.is_owned = false;
32013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32014         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
32015 }
32016
32017 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
32018         LDKReplyChannelRange this_ptr_conv;
32019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32020         this_ptr_conv.is_owned = false;
32021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32022         LDKCVec_u64Z val_constr;
32023         val_constr.datalen = val->arr_len;
32024         if (val_constr.datalen > 0)
32025                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32026         else
32027                 val_constr.data = NULL;
32028         int64_t* val_vals = val->elems;
32029         for (size_t i = 0; i < val_constr.datalen; i++) {
32030                 int64_t val_conv_8 = val_vals[i];
32031                 val_constr.data[i] = val_conv_8;
32032         }
32033         FREE(val);
32034         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
32035 }
32036
32037 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) {
32038         LDKThirtyTwoBytes chain_hash_arg_ref;
32039         CHECK(chain_hash_arg->arr_len == 32);
32040         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32041         LDKCVec_u64Z short_channel_ids_arg_constr;
32042         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
32043         if (short_channel_ids_arg_constr.datalen > 0)
32044                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32045         else
32046                 short_channel_ids_arg_constr.data = NULL;
32047         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
32048         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
32049                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
32050                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
32051         }
32052         FREE(short_channel_ids_arg);
32053         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
32054         uint32_t ret_ref = 0;
32055         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32056         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32058         ret_ref = (uintptr_t)ret_var.inner;
32059         if (ret_var.is_owned) {
32060                 ret_ref |= 1;
32061         }
32062         return ret_ref;
32063 }
32064
32065 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
32066         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
32067 uint32_t ret_ref = 0;
32068 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32069 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32070 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32071 ret_ref = (uintptr_t)ret_var.inner;
32072 if (ret_var.is_owned) {
32073         ret_ref |= 1;
32074 }
32075         return ret_ref;
32076 }
32077 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
32078         LDKReplyChannelRange arg_conv;
32079         arg_conv.inner = (void*)(arg & (~1));
32080         arg_conv.is_owned = false;
32081         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32082         uint32_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
32083         return ret_conv;
32084 }
32085
32086 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint32_t orig) {
32087         LDKReplyChannelRange orig_conv;
32088         orig_conv.inner = (void*)(orig & (~1));
32089         orig_conv.is_owned = false;
32090         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32091         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
32092         uint32_t ret_ref = 0;
32093         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32094         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32096         ret_ref = (uintptr_t)ret_var.inner;
32097         if (ret_var.is_owned) {
32098                 ret_ref |= 1;
32099         }
32100         return ret_ref;
32101 }
32102
32103 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
32104         LDKQueryShortChannelIds this_obj_conv;
32105         this_obj_conv.inner = (void*)(this_obj & (~1));
32106         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32108         QueryShortChannelIds_free(this_obj_conv);
32109 }
32110
32111 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
32112         LDKQueryShortChannelIds this_ptr_conv;
32113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32114         this_ptr_conv.is_owned = false;
32115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32116         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32117         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
32118         return ret_arr;
32119 }
32120
32121 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32122         LDKQueryShortChannelIds this_ptr_conv;
32123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32124         this_ptr_conv.is_owned = false;
32125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32126         LDKThirtyTwoBytes val_ref;
32127         CHECK(val->arr_len == 32);
32128         memcpy(val_ref.data, val->elems, 32); FREE(val);
32129         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
32130 }
32131
32132 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
32133         LDKQueryShortChannelIds this_ptr_conv;
32134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32135         this_ptr_conv.is_owned = false;
32136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32137         LDKCVec_u64Z val_constr;
32138         val_constr.datalen = val->arr_len;
32139         if (val_constr.datalen > 0)
32140                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32141         else
32142                 val_constr.data = NULL;
32143         int64_t* val_vals = val->elems;
32144         for (size_t i = 0; i < val_constr.datalen; i++) {
32145                 int64_t val_conv_8 = val_vals[i];
32146                 val_constr.data[i] = val_conv_8;
32147         }
32148         FREE(val);
32149         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
32150 }
32151
32152 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
32153         LDKThirtyTwoBytes chain_hash_arg_ref;
32154         CHECK(chain_hash_arg->arr_len == 32);
32155         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32156         LDKCVec_u64Z short_channel_ids_arg_constr;
32157         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
32158         if (short_channel_ids_arg_constr.datalen > 0)
32159                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32160         else
32161                 short_channel_ids_arg_constr.data = NULL;
32162         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
32163         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
32164                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
32165                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
32166         }
32167         FREE(short_channel_ids_arg);
32168         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
32169         uint32_t ret_ref = 0;
32170         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32171         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32173         ret_ref = (uintptr_t)ret_var.inner;
32174         if (ret_var.is_owned) {
32175                 ret_ref |= 1;
32176         }
32177         return ret_ref;
32178 }
32179
32180 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
32181         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
32182 uint32_t ret_ref = 0;
32183 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32184 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32185 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32186 ret_ref = (uintptr_t)ret_var.inner;
32187 if (ret_var.is_owned) {
32188         ret_ref |= 1;
32189 }
32190         return ret_ref;
32191 }
32192 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
32193         LDKQueryShortChannelIds arg_conv;
32194         arg_conv.inner = (void*)(arg & (~1));
32195         arg_conv.is_owned = false;
32196         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32197         uint32_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
32198         return ret_conv;
32199 }
32200
32201 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
32202         LDKQueryShortChannelIds orig_conv;
32203         orig_conv.inner = (void*)(orig & (~1));
32204         orig_conv.is_owned = false;
32205         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32206         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
32207         uint32_t ret_ref = 0;
32208         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32209         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32211         ret_ref = (uintptr_t)ret_var.inner;
32212         if (ret_var.is_owned) {
32213                 ret_ref |= 1;
32214         }
32215         return ret_ref;
32216 }
32217
32218 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
32219         LDKReplyShortChannelIdsEnd this_obj_conv;
32220         this_obj_conv.inner = (void*)(this_obj & (~1));
32221         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32223         ReplyShortChannelIdsEnd_free(this_obj_conv);
32224 }
32225
32226 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
32227         LDKReplyShortChannelIdsEnd this_ptr_conv;
32228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32229         this_ptr_conv.is_owned = false;
32230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32231         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32232         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
32233         return ret_arr;
32234 }
32235
32236 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32237         LDKReplyShortChannelIdsEnd this_ptr_conv;
32238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32239         this_ptr_conv.is_owned = false;
32240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32241         LDKThirtyTwoBytes val_ref;
32242         CHECK(val->arr_len == 32);
32243         memcpy(val_ref.data, val->elems, 32); FREE(val);
32244         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
32245 }
32246
32247 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
32248         LDKReplyShortChannelIdsEnd this_ptr_conv;
32249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32250         this_ptr_conv.is_owned = false;
32251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32252         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
32253         return ret_conv;
32254 }
32255
32256 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
32257         LDKReplyShortChannelIdsEnd this_ptr_conv;
32258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32259         this_ptr_conv.is_owned = false;
32260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32261         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
32262 }
32263
32264 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
32265         LDKThirtyTwoBytes chain_hash_arg_ref;
32266         CHECK(chain_hash_arg->arr_len == 32);
32267         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32268         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
32269         uint32_t ret_ref = 0;
32270         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32271         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32272         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32273         ret_ref = (uintptr_t)ret_var.inner;
32274         if (ret_var.is_owned) {
32275                 ret_ref |= 1;
32276         }
32277         return ret_ref;
32278 }
32279
32280 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
32281         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
32282 uint32_t ret_ref = 0;
32283 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32284 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32285 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32286 ret_ref = (uintptr_t)ret_var.inner;
32287 if (ret_var.is_owned) {
32288         ret_ref |= 1;
32289 }
32290         return ret_ref;
32291 }
32292 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
32293         LDKReplyShortChannelIdsEnd arg_conv;
32294         arg_conv.inner = (void*)(arg & (~1));
32295         arg_conv.is_owned = false;
32296         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32297         uint32_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
32298         return ret_conv;
32299 }
32300
32301 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
32302         LDKReplyShortChannelIdsEnd orig_conv;
32303         orig_conv.inner = (void*)(orig & (~1));
32304         orig_conv.is_owned = false;
32305         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32306         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
32307         uint32_t ret_ref = 0;
32308         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32309         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32311         ret_ref = (uintptr_t)ret_var.inner;
32312         if (ret_var.is_owned) {
32313                 ret_ref |= 1;
32314         }
32315         return ret_ref;
32316 }
32317
32318 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
32319         LDKGossipTimestampFilter this_obj_conv;
32320         this_obj_conv.inner = (void*)(this_obj & (~1));
32321         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32323         GossipTimestampFilter_free(this_obj_conv);
32324 }
32325
32326 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
32327         LDKGossipTimestampFilter this_ptr_conv;
32328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32329         this_ptr_conv.is_owned = false;
32330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32331         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32332         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
32333         return ret_arr;
32334 }
32335
32336 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32337         LDKGossipTimestampFilter this_ptr_conv;
32338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32339         this_ptr_conv.is_owned = false;
32340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32341         LDKThirtyTwoBytes val_ref;
32342         CHECK(val->arr_len == 32);
32343         memcpy(val_ref.data, val->elems, 32); FREE(val);
32344         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
32345 }
32346
32347 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
32348         LDKGossipTimestampFilter this_ptr_conv;
32349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32350         this_ptr_conv.is_owned = false;
32351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32352         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
32353         return ret_conv;
32354 }
32355
32356 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
32357         LDKGossipTimestampFilter this_ptr_conv;
32358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32359         this_ptr_conv.is_owned = false;
32360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32361         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
32362 }
32363
32364 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
32365         LDKGossipTimestampFilter this_ptr_conv;
32366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32367         this_ptr_conv.is_owned = false;
32368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32369         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
32370         return ret_conv;
32371 }
32372
32373 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
32374         LDKGossipTimestampFilter this_ptr_conv;
32375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32376         this_ptr_conv.is_owned = false;
32377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32378         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
32379 }
32380
32381 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) {
32382         LDKThirtyTwoBytes chain_hash_arg_ref;
32383         CHECK(chain_hash_arg->arr_len == 32);
32384         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32385         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
32386         uint32_t ret_ref = 0;
32387         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32388         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32390         ret_ref = (uintptr_t)ret_var.inner;
32391         if (ret_var.is_owned) {
32392                 ret_ref |= 1;
32393         }
32394         return ret_ref;
32395 }
32396
32397 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
32398         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
32399 uint32_t ret_ref = 0;
32400 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32401 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32402 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32403 ret_ref = (uintptr_t)ret_var.inner;
32404 if (ret_var.is_owned) {
32405         ret_ref |= 1;
32406 }
32407         return ret_ref;
32408 }
32409 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
32410         LDKGossipTimestampFilter arg_conv;
32411         arg_conv.inner = (void*)(arg & (~1));
32412         arg_conv.is_owned = false;
32413         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32414         uint32_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
32415         return ret_conv;
32416 }
32417
32418 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
32419         LDKGossipTimestampFilter orig_conv;
32420         orig_conv.inner = (void*)(orig & (~1));
32421         orig_conv.is_owned = false;
32422         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32423         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
32424         uint32_t ret_ref = 0;
32425         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32426         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32428         ret_ref = (uintptr_t)ret_var.inner;
32429         if (ret_var.is_owned) {
32430                 ret_ref |= 1;
32431         }
32432         return ret_ref;
32433 }
32434
32435 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint32_t this_ptr) {
32436         if ((this_ptr & 1) != 0) return;
32437         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32438         CHECK_ACCESS(this_ptr_ptr);
32439         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
32440         FREE((void*)this_ptr);
32441         ErrorAction_free(this_ptr_conv);
32442 }
32443
32444 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
32445         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32446         *ret_copy = ErrorAction_clone(arg);
32447 uint32_t ret_ref = (uintptr_t)ret_copy;
32448         return ret_ref;
32449 }
32450 uint32_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
32451         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
32452         uint32_t ret_conv = ErrorAction_clone_ptr(arg_conv);
32453         return ret_conv;
32454 }
32455
32456 uint32_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint32_t orig) {
32457         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
32458         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32459         *ret_copy = ErrorAction_clone(orig_conv);
32460         uint32_t ret_ref = (uintptr_t)ret_copy;
32461         return ret_ref;
32462 }
32463
32464 uint32_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
32465         LDKErrorMessage msg_conv;
32466         msg_conv.inner = (void*)(msg & (~1));
32467         msg_conv.is_owned = (msg & 1) || (msg == 0);
32468         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32469         msg_conv = ErrorMessage_clone(&msg_conv);
32470         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32471         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
32472         uint32_t ret_ref = (uintptr_t)ret_copy;
32473         return ret_ref;
32474 }
32475
32476 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
32477         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32478         *ret_copy = ErrorAction_ignore_error();
32479         uint32_t ret_ref = (uintptr_t)ret_copy;
32480         return ret_ref;
32481 }
32482
32483 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
32484         LDKLevel a_conv = LDKLevel_from_js(a);
32485         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32486         *ret_copy = ErrorAction_ignore_and_log(a_conv);
32487         uint32_t ret_ref = (uintptr_t)ret_copy;
32488         return ret_ref;
32489 }
32490
32491 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
32492         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32493         *ret_copy = ErrorAction_ignore_duplicate_gossip();
32494         uint32_t ret_ref = (uintptr_t)ret_copy;
32495         return ret_ref;
32496 }
32497
32498 uint32_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint32_t msg) {
32499         LDKErrorMessage msg_conv;
32500         msg_conv.inner = (void*)(msg & (~1));
32501         msg_conv.is_owned = (msg & 1) || (msg == 0);
32502         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32503         msg_conv = ErrorMessage_clone(&msg_conv);
32504         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32505         *ret_copy = ErrorAction_send_error_message(msg_conv);
32506         uint32_t ret_ref = (uintptr_t)ret_copy;
32507         return ret_ref;
32508 }
32509
32510 uint32_t  __attribute__((export_name("TS_ErrorAction_send_warning_message"))) TS_ErrorAction_send_warning_message(uint32_t msg, uint32_t log_level) {
32511         LDKWarningMessage msg_conv;
32512         msg_conv.inner = (void*)(msg & (~1));
32513         msg_conv.is_owned = (msg & 1) || (msg == 0);
32514         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32515         msg_conv = WarningMessage_clone(&msg_conv);
32516         LDKLevel log_level_conv = LDKLevel_from_js(log_level);
32517         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32518         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
32519         uint32_t ret_ref = (uintptr_t)ret_copy;
32520         return ret_ref;
32521 }
32522
32523 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint32_t this_obj) {
32524         LDKLightningError this_obj_conv;
32525         this_obj_conv.inner = (void*)(this_obj & (~1));
32526         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32528         LightningError_free(this_obj_conv);
32529 }
32530
32531 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint32_t this_ptr) {
32532         LDKLightningError this_ptr_conv;
32533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32534         this_ptr_conv.is_owned = false;
32535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32536         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
32537         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
32538         Str_free(ret_str);
32539         return ret_conv;
32540 }
32541
32542 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
32543         LDKLightningError this_ptr_conv;
32544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32545         this_ptr_conv.is_owned = false;
32546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32547         LDKStr val_conv = str_ref_to_owned_c(val);
32548         LightningError_set_err(&this_ptr_conv, val_conv);
32549 }
32550
32551 uint32_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint32_t this_ptr) {
32552         LDKLightningError this_ptr_conv;
32553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32554         this_ptr_conv.is_owned = false;
32555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32556         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32557         *ret_copy = LightningError_get_action(&this_ptr_conv);
32558         uint32_t ret_ref = (uintptr_t)ret_copy;
32559         return ret_ref;
32560 }
32561
32562 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
32563         LDKLightningError this_ptr_conv;
32564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32565         this_ptr_conv.is_owned = false;
32566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32567         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32568         CHECK_ACCESS(val_ptr);
32569         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
32570         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
32571         LightningError_set_action(&this_ptr_conv, val_conv);
32572 }
32573
32574 uint32_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
32575         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
32576         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
32577         CHECK_ACCESS(action_arg_ptr);
32578         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
32579         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
32580         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
32581         uint32_t ret_ref = 0;
32582         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32583         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32585         ret_ref = (uintptr_t)ret_var.inner;
32586         if (ret_var.is_owned) {
32587                 ret_ref |= 1;
32588         }
32589         return ret_ref;
32590 }
32591
32592 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
32593         LDKLightningError ret_var = LightningError_clone(arg);
32594 uint32_t ret_ref = 0;
32595 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32596 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32597 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32598 ret_ref = (uintptr_t)ret_var.inner;
32599 if (ret_var.is_owned) {
32600         ret_ref |= 1;
32601 }
32602         return ret_ref;
32603 }
32604 uint32_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint32_t arg) {
32605         LDKLightningError arg_conv;
32606         arg_conv.inner = (void*)(arg & (~1));
32607         arg_conv.is_owned = false;
32608         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32609         uint32_t ret_conv = LightningError_clone_ptr(&arg_conv);
32610         return ret_conv;
32611 }
32612
32613 uint32_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint32_t orig) {
32614         LDKLightningError orig_conv;
32615         orig_conv.inner = (void*)(orig & (~1));
32616         orig_conv.is_owned = false;
32617         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32618         LDKLightningError ret_var = LightningError_clone(&orig_conv);
32619         uint32_t ret_ref = 0;
32620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32623         ret_ref = (uintptr_t)ret_var.inner;
32624         if (ret_var.is_owned) {
32625                 ret_ref |= 1;
32626         }
32627         return ret_ref;
32628 }
32629
32630 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
32631         LDKCommitmentUpdate this_obj_conv;
32632         this_obj_conv.inner = (void*)(this_obj & (~1));
32633         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32635         CommitmentUpdate_free(this_obj_conv);
32636 }
32637
32638 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
32639         LDKCommitmentUpdate this_ptr_conv;
32640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32641         this_ptr_conv.is_owned = false;
32642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32643         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
32644         uint32_tArray ret_arr = NULL;
32645         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
32646         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
32647         for (size_t p = 0; p < ret_var.datalen; p++) {
32648                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
32649                 uint32_t ret_conv_15_ref = 0;
32650                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32651                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32652                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
32653                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
32654                 if (ret_conv_15_var.is_owned) {
32655                         ret_conv_15_ref |= 1;
32656                 }
32657                 ret_arr_ptr[p] = ret_conv_15_ref;
32658         }
32659         
32660         FREE(ret_var.data);
32661         return ret_arr;
32662 }
32663
32664 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
32665         LDKCommitmentUpdate this_ptr_conv;
32666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32667         this_ptr_conv.is_owned = false;
32668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32669         LDKCVec_UpdateAddHTLCZ val_constr;
32670         val_constr.datalen = val->arr_len;
32671         if (val_constr.datalen > 0)
32672                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
32673         else
32674                 val_constr.data = NULL;
32675         uint32_t* val_vals = val->elems;
32676         for (size_t p = 0; p < val_constr.datalen; p++) {
32677                 uint32_t val_conv_15 = val_vals[p];
32678                 LDKUpdateAddHTLC val_conv_15_conv;
32679                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
32680                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
32681                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
32682                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
32683                 val_constr.data[p] = val_conv_15_conv;
32684         }
32685         FREE(val);
32686         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
32687 }
32688
32689 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
32690         LDKCommitmentUpdate this_ptr_conv;
32691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32692         this_ptr_conv.is_owned = false;
32693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32694         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
32695         uint32_tArray ret_arr = NULL;
32696         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
32697         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
32698         for (size_t t = 0; t < ret_var.datalen; t++) {
32699                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
32700                 uint32_t ret_conv_19_ref = 0;
32701                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32702                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32703                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
32704                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
32705                 if (ret_conv_19_var.is_owned) {
32706                         ret_conv_19_ref |= 1;
32707                 }
32708                 ret_arr_ptr[t] = ret_conv_19_ref;
32709         }
32710         
32711         FREE(ret_var.data);
32712         return ret_arr;
32713 }
32714
32715 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
32716         LDKCommitmentUpdate this_ptr_conv;
32717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32718         this_ptr_conv.is_owned = false;
32719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32720         LDKCVec_UpdateFulfillHTLCZ val_constr;
32721         val_constr.datalen = val->arr_len;
32722         if (val_constr.datalen > 0)
32723                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
32724         else
32725                 val_constr.data = NULL;
32726         uint32_t* val_vals = val->elems;
32727         for (size_t t = 0; t < val_constr.datalen; t++) {
32728                 uint32_t val_conv_19 = val_vals[t];
32729                 LDKUpdateFulfillHTLC val_conv_19_conv;
32730                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
32731                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
32732                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
32733                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
32734                 val_constr.data[t] = val_conv_19_conv;
32735         }
32736         FREE(val);
32737         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
32738 }
32739
32740 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
32741         LDKCommitmentUpdate this_ptr_conv;
32742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32743         this_ptr_conv.is_owned = false;
32744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32745         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
32746         uint32_tArray ret_arr = NULL;
32747         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
32748         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
32749         for (size_t q = 0; q < ret_var.datalen; q++) {
32750                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
32751                 uint32_t ret_conv_16_ref = 0;
32752                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32753                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32754                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
32755                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
32756                 if (ret_conv_16_var.is_owned) {
32757                         ret_conv_16_ref |= 1;
32758                 }
32759                 ret_arr_ptr[q] = ret_conv_16_ref;
32760         }
32761         
32762         FREE(ret_var.data);
32763         return ret_arr;
32764 }
32765
32766 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
32767         LDKCommitmentUpdate this_ptr_conv;
32768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32769         this_ptr_conv.is_owned = false;
32770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32771         LDKCVec_UpdateFailHTLCZ val_constr;
32772         val_constr.datalen = val->arr_len;
32773         if (val_constr.datalen > 0)
32774                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
32775         else
32776                 val_constr.data = NULL;
32777         uint32_t* val_vals = val->elems;
32778         for (size_t q = 0; q < val_constr.datalen; q++) {
32779                 uint32_t val_conv_16 = val_vals[q];
32780                 LDKUpdateFailHTLC val_conv_16_conv;
32781                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
32782                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
32783                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
32784                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
32785                 val_constr.data[q] = val_conv_16_conv;
32786         }
32787         FREE(val);
32788         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
32789 }
32790
32791 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
32792         LDKCommitmentUpdate this_ptr_conv;
32793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32794         this_ptr_conv.is_owned = false;
32795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32796         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
32797         uint32_tArray ret_arr = NULL;
32798         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
32799         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
32800         for (size_t z = 0; z < ret_var.datalen; z++) {
32801                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
32802                 uint32_t ret_conv_25_ref = 0;
32803                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32804                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32805                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
32806                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
32807                 if (ret_conv_25_var.is_owned) {
32808                         ret_conv_25_ref |= 1;
32809                 }
32810                 ret_arr_ptr[z] = ret_conv_25_ref;
32811         }
32812         
32813         FREE(ret_var.data);
32814         return ret_arr;
32815 }
32816
32817 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) {
32818         LDKCommitmentUpdate this_ptr_conv;
32819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32820         this_ptr_conv.is_owned = false;
32821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32822         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
32823         val_constr.datalen = val->arr_len;
32824         if (val_constr.datalen > 0)
32825                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
32826         else
32827                 val_constr.data = NULL;
32828         uint32_t* val_vals = val->elems;
32829         for (size_t z = 0; z < val_constr.datalen; z++) {
32830                 uint32_t val_conv_25 = val_vals[z];
32831                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
32832                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
32833                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
32834                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
32835                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
32836                 val_constr.data[z] = val_conv_25_conv;
32837         }
32838         FREE(val);
32839         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
32840 }
32841
32842 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
32843         LDKCommitmentUpdate this_ptr_conv;
32844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32845         this_ptr_conv.is_owned = false;
32846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32847         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
32848         uint32_t ret_ref = 0;
32849         if ((uintptr_t)ret_var.inner > 4096) {
32850                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32851                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32853                 ret_ref = (uintptr_t)ret_var.inner;
32854                 if (ret_var.is_owned) {
32855                         ret_ref |= 1;
32856                 }
32857         }
32858         return ret_ref;
32859 }
32860
32861 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
32862         LDKCommitmentUpdate this_ptr_conv;
32863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32864         this_ptr_conv.is_owned = false;
32865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32866         LDKUpdateFee val_conv;
32867         val_conv.inner = (void*)(val & (~1));
32868         val_conv.is_owned = (val & 1) || (val == 0);
32869         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32870         val_conv = UpdateFee_clone(&val_conv);
32871         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
32872 }
32873
32874 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
32875         LDKCommitmentUpdate this_ptr_conv;
32876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32877         this_ptr_conv.is_owned = false;
32878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32879         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
32880         uint32_t ret_ref = 0;
32881         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32882         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32884         ret_ref = (uintptr_t)ret_var.inner;
32885         if (ret_var.is_owned) {
32886                 ret_ref |= 1;
32887         }
32888         return ret_ref;
32889 }
32890
32891 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
32892         LDKCommitmentUpdate this_ptr_conv;
32893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32894         this_ptr_conv.is_owned = false;
32895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32896         LDKCommitmentSigned val_conv;
32897         val_conv.inner = (void*)(val & (~1));
32898         val_conv.is_owned = (val & 1) || (val == 0);
32899         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32900         val_conv = CommitmentSigned_clone(&val_conv);
32901         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
32902 }
32903
32904 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) {
32905         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
32906         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
32907         if (update_add_htlcs_arg_constr.datalen > 0)
32908                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
32909         else
32910                 update_add_htlcs_arg_constr.data = NULL;
32911         uint32_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems;
32912         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
32913                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
32914                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
32915                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
32916                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
32917                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
32918                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
32919                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
32920         }
32921         FREE(update_add_htlcs_arg);
32922         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
32923         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
32924         if (update_fulfill_htlcs_arg_constr.datalen > 0)
32925                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
32926         else
32927                 update_fulfill_htlcs_arg_constr.data = NULL;
32928         uint32_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems;
32929         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
32930                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
32931                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
32932                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
32933                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
32934                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
32935                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
32936                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
32937         }
32938         FREE(update_fulfill_htlcs_arg);
32939         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
32940         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
32941         if (update_fail_htlcs_arg_constr.datalen > 0)
32942                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
32943         else
32944                 update_fail_htlcs_arg_constr.data = NULL;
32945         uint32_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems;
32946         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
32947                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
32948                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
32949                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
32950                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
32951                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
32952                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
32953                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
32954         }
32955         FREE(update_fail_htlcs_arg);
32956         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
32957         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
32958         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
32959                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
32960         else
32961                 update_fail_malformed_htlcs_arg_constr.data = NULL;
32962         uint32_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems;
32963         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
32964                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
32965                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
32966                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
32967                 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);
32968                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
32969                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
32970                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
32971         }
32972         FREE(update_fail_malformed_htlcs_arg);
32973         LDKUpdateFee update_fee_arg_conv;
32974         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
32975         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
32976         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
32977         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
32978         LDKCommitmentSigned commitment_signed_arg_conv;
32979         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
32980         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
32981         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
32982         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
32983         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);
32984         uint32_t ret_ref = 0;
32985         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32986         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32988         ret_ref = (uintptr_t)ret_var.inner;
32989         if (ret_var.is_owned) {
32990                 ret_ref |= 1;
32991         }
32992         return ret_ref;
32993 }
32994
32995 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
32996         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
32997 uint32_t ret_ref = 0;
32998 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32999 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33000 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33001 ret_ref = (uintptr_t)ret_var.inner;
33002 if (ret_var.is_owned) {
33003         ret_ref |= 1;
33004 }
33005         return ret_ref;
33006 }
33007 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
33008         LDKCommitmentUpdate arg_conv;
33009         arg_conv.inner = (void*)(arg & (~1));
33010         arg_conv.is_owned = false;
33011         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33012         uint32_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
33013         return ret_conv;
33014 }
33015
33016 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint32_t orig) {
33017         LDKCommitmentUpdate orig_conv;
33018         orig_conv.inner = (void*)(orig & (~1));
33019         orig_conv.is_owned = false;
33020         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33021         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
33022         uint32_t ret_ref = 0;
33023         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33024         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33026         ret_ref = (uintptr_t)ret_var.inner;
33027         if (ret_var.is_owned) {
33028                 ret_ref |= 1;
33029         }
33030         return ret_ref;
33031 }
33032
33033 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
33034         if ((this_ptr & 1) != 0) return;
33035         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33036         CHECK_ACCESS(this_ptr_ptr);
33037         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
33038         FREE((void*)this_ptr);
33039         ChannelMessageHandler_free(this_ptr_conv);
33040 }
33041
33042 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
33043         if ((this_ptr & 1) != 0) return;
33044         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33045         CHECK_ACCESS(this_ptr_ptr);
33046         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
33047         FREE((void*)this_ptr);
33048         RoutingMessageHandler_free(this_ptr_conv);
33049 }
33050
33051 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint32_t obj) {
33052         LDKAcceptChannel obj_conv;
33053         obj_conv.inner = (void*)(obj & (~1));
33054         obj_conv.is_owned = false;
33055         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33056         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
33057         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33058         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33059         CVec_u8Z_free(ret_var);
33060         return ret_arr;
33061 }
33062
33063 uint32_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
33064         LDKu8slice ser_ref;
33065         ser_ref.datalen = ser->arr_len;
33066         ser_ref.data = ser->elems;
33067         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
33068         *ret_conv = AcceptChannel_read(ser_ref);
33069         FREE(ser);
33070         return (uint32_t)ret_conv;
33071 }
33072
33073 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint32_t obj) {
33074         LDKAnnouncementSignatures obj_conv;
33075         obj_conv.inner = (void*)(obj & (~1));
33076         obj_conv.is_owned = false;
33077         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33078         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
33079         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33080         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33081         CVec_u8Z_free(ret_var);
33082         return ret_arr;
33083 }
33084
33085 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
33086         LDKu8slice ser_ref;
33087         ser_ref.datalen = ser->arr_len;
33088         ser_ref.data = ser->elems;
33089         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
33090         *ret_conv = AnnouncementSignatures_read(ser_ref);
33091         FREE(ser);
33092         return (uint32_t)ret_conv;
33093 }
33094
33095 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint32_t obj) {
33096         LDKChannelReestablish obj_conv;
33097         obj_conv.inner = (void*)(obj & (~1));
33098         obj_conv.is_owned = false;
33099         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33100         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
33101         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33102         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33103         CVec_u8Z_free(ret_var);
33104         return ret_arr;
33105 }
33106
33107 uint32_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
33108         LDKu8slice ser_ref;
33109         ser_ref.datalen = ser->arr_len;
33110         ser_ref.data = ser->elems;
33111         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
33112         *ret_conv = ChannelReestablish_read(ser_ref);
33113         FREE(ser);
33114         return (uint32_t)ret_conv;
33115 }
33116
33117 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint32_t obj) {
33118         LDKClosingSigned obj_conv;
33119         obj_conv.inner = (void*)(obj & (~1));
33120         obj_conv.is_owned = false;
33121         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33122         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
33123         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33124         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33125         CVec_u8Z_free(ret_var);
33126         return ret_arr;
33127 }
33128
33129 uint32_t  __attribute__((export_name("TS_ClosingSigned_read"))) TS_ClosingSigned_read(int8_tArray ser) {
33130         LDKu8slice ser_ref;
33131         ser_ref.datalen = ser->arr_len;
33132         ser_ref.data = ser->elems;
33133         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
33134         *ret_conv = ClosingSigned_read(ser_ref);
33135         FREE(ser);
33136         return (uint32_t)ret_conv;
33137 }
33138
33139 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
33140         LDKClosingSignedFeeRange obj_conv;
33141         obj_conv.inner = (void*)(obj & (~1));
33142         obj_conv.is_owned = false;
33143         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33144         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
33145         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33146         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33147         CVec_u8Z_free(ret_var);
33148         return ret_arr;
33149 }
33150
33151 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
33152         LDKu8slice ser_ref;
33153         ser_ref.datalen = ser->arr_len;
33154         ser_ref.data = ser->elems;
33155         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
33156         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
33157         FREE(ser);
33158         return (uint32_t)ret_conv;
33159 }
33160
33161 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint32_t obj) {
33162         LDKCommitmentSigned obj_conv;
33163         obj_conv.inner = (void*)(obj & (~1));
33164         obj_conv.is_owned = false;
33165         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33166         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
33167         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33168         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33169         CVec_u8Z_free(ret_var);
33170         return ret_arr;
33171 }
33172
33173 uint32_t  __attribute__((export_name("TS_CommitmentSigned_read"))) TS_CommitmentSigned_read(int8_tArray ser) {
33174         LDKu8slice ser_ref;
33175         ser_ref.datalen = ser->arr_len;
33176         ser_ref.data = ser->elems;
33177         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
33178         *ret_conv = CommitmentSigned_read(ser_ref);
33179         FREE(ser);
33180         return (uint32_t)ret_conv;
33181 }
33182
33183 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint32_t obj) {
33184         LDKFundingCreated obj_conv;
33185         obj_conv.inner = (void*)(obj & (~1));
33186         obj_conv.is_owned = false;
33187         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33188         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
33189         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33190         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33191         CVec_u8Z_free(ret_var);
33192         return ret_arr;
33193 }
33194
33195 uint32_t  __attribute__((export_name("TS_FundingCreated_read"))) TS_FundingCreated_read(int8_tArray ser) {
33196         LDKu8slice ser_ref;
33197         ser_ref.datalen = ser->arr_len;
33198         ser_ref.data = ser->elems;
33199         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
33200         *ret_conv = FundingCreated_read(ser_ref);
33201         FREE(ser);
33202         return (uint32_t)ret_conv;
33203 }
33204
33205 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint32_t obj) {
33206         LDKFundingSigned obj_conv;
33207         obj_conv.inner = (void*)(obj & (~1));
33208         obj_conv.is_owned = false;
33209         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33210         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
33211         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33212         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33213         CVec_u8Z_free(ret_var);
33214         return ret_arr;
33215 }
33216
33217 uint32_t  __attribute__((export_name("TS_FundingSigned_read"))) TS_FundingSigned_read(int8_tArray ser) {
33218         LDKu8slice ser_ref;
33219         ser_ref.datalen = ser->arr_len;
33220         ser_ref.data = ser->elems;
33221         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
33222         *ret_conv = FundingSigned_read(ser_ref);
33223         FREE(ser);
33224         return (uint32_t)ret_conv;
33225 }
33226
33227 int8_tArray  __attribute__((export_name("TS_ChannelReady_write"))) TS_ChannelReady_write(uint32_t obj) {
33228         LDKChannelReady obj_conv;
33229         obj_conv.inner = (void*)(obj & (~1));
33230         obj_conv.is_owned = false;
33231         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33232         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
33233         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33234         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33235         CVec_u8Z_free(ret_var);
33236         return ret_arr;
33237 }
33238
33239 uint32_t  __attribute__((export_name("TS_ChannelReady_read"))) TS_ChannelReady_read(int8_tArray ser) {
33240         LDKu8slice ser_ref;
33241         ser_ref.datalen = ser->arr_len;
33242         ser_ref.data = ser->elems;
33243         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
33244         *ret_conv = ChannelReady_read(ser_ref);
33245         FREE(ser);
33246         return (uint32_t)ret_conv;
33247 }
33248
33249 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint32_t obj) {
33250         LDKInit obj_conv;
33251         obj_conv.inner = (void*)(obj & (~1));
33252         obj_conv.is_owned = false;
33253         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33254         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
33255         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33256         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33257         CVec_u8Z_free(ret_var);
33258         return ret_arr;
33259 }
33260
33261 uint32_t  __attribute__((export_name("TS_Init_read"))) TS_Init_read(int8_tArray ser) {
33262         LDKu8slice ser_ref;
33263         ser_ref.datalen = ser->arr_len;
33264         ser_ref.data = ser->elems;
33265         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
33266         *ret_conv = Init_read(ser_ref);
33267         FREE(ser);
33268         return (uint32_t)ret_conv;
33269 }
33270
33271 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint32_t obj) {
33272         LDKOpenChannel obj_conv;
33273         obj_conv.inner = (void*)(obj & (~1));
33274         obj_conv.is_owned = false;
33275         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33276         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
33277         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33278         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33279         CVec_u8Z_free(ret_var);
33280         return ret_arr;
33281 }
33282
33283 uint32_t  __attribute__((export_name("TS_OpenChannel_read"))) TS_OpenChannel_read(int8_tArray ser) {
33284         LDKu8slice ser_ref;
33285         ser_ref.datalen = ser->arr_len;
33286         ser_ref.data = ser->elems;
33287         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
33288         *ret_conv = OpenChannel_read(ser_ref);
33289         FREE(ser);
33290         return (uint32_t)ret_conv;
33291 }
33292
33293 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint32_t obj) {
33294         LDKRevokeAndACK obj_conv;
33295         obj_conv.inner = (void*)(obj & (~1));
33296         obj_conv.is_owned = false;
33297         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33298         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
33299         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33300         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33301         CVec_u8Z_free(ret_var);
33302         return ret_arr;
33303 }
33304
33305 uint32_t  __attribute__((export_name("TS_RevokeAndACK_read"))) TS_RevokeAndACK_read(int8_tArray ser) {
33306         LDKu8slice ser_ref;
33307         ser_ref.datalen = ser->arr_len;
33308         ser_ref.data = ser->elems;
33309         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
33310         *ret_conv = RevokeAndACK_read(ser_ref);
33311         FREE(ser);
33312         return (uint32_t)ret_conv;
33313 }
33314
33315 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint32_t obj) {
33316         LDKShutdown obj_conv;
33317         obj_conv.inner = (void*)(obj & (~1));
33318         obj_conv.is_owned = false;
33319         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33320         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
33321         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33322         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33323         CVec_u8Z_free(ret_var);
33324         return ret_arr;
33325 }
33326
33327 uint32_t  __attribute__((export_name("TS_Shutdown_read"))) TS_Shutdown_read(int8_tArray ser) {
33328         LDKu8slice ser_ref;
33329         ser_ref.datalen = ser->arr_len;
33330         ser_ref.data = ser->elems;
33331         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
33332         *ret_conv = Shutdown_read(ser_ref);
33333         FREE(ser);
33334         return (uint32_t)ret_conv;
33335 }
33336
33337 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint32_t obj) {
33338         LDKUpdateFailHTLC obj_conv;
33339         obj_conv.inner = (void*)(obj & (~1));
33340         obj_conv.is_owned = false;
33341         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33342         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
33343         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33344         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33345         CVec_u8Z_free(ret_var);
33346         return ret_arr;
33347 }
33348
33349 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
33350         LDKu8slice ser_ref;
33351         ser_ref.datalen = ser->arr_len;
33352         ser_ref.data = ser->elems;
33353         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
33354         *ret_conv = UpdateFailHTLC_read(ser_ref);
33355         FREE(ser);
33356         return (uint32_t)ret_conv;
33357 }
33358
33359 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
33360         LDKUpdateFailMalformedHTLC obj_conv;
33361         obj_conv.inner = (void*)(obj & (~1));
33362         obj_conv.is_owned = false;
33363         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33364         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
33365         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33366         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33367         CVec_u8Z_free(ret_var);
33368         return ret_arr;
33369 }
33370
33371 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
33372         LDKu8slice ser_ref;
33373         ser_ref.datalen = ser->arr_len;
33374         ser_ref.data = ser->elems;
33375         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
33376         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
33377         FREE(ser);
33378         return (uint32_t)ret_conv;
33379 }
33380
33381 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint32_t obj) {
33382         LDKUpdateFee obj_conv;
33383         obj_conv.inner = (void*)(obj & (~1));
33384         obj_conv.is_owned = false;
33385         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33386         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
33387         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33388         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33389         CVec_u8Z_free(ret_var);
33390         return ret_arr;
33391 }
33392
33393 uint32_t  __attribute__((export_name("TS_UpdateFee_read"))) TS_UpdateFee_read(int8_tArray ser) {
33394         LDKu8slice ser_ref;
33395         ser_ref.datalen = ser->arr_len;
33396         ser_ref.data = ser->elems;
33397         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
33398         *ret_conv = UpdateFee_read(ser_ref);
33399         FREE(ser);
33400         return (uint32_t)ret_conv;
33401 }
33402
33403 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
33404         LDKUpdateFulfillHTLC obj_conv;
33405         obj_conv.inner = (void*)(obj & (~1));
33406         obj_conv.is_owned = false;
33407         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33408         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
33409         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33410         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33411         CVec_u8Z_free(ret_var);
33412         return ret_arr;
33413 }
33414
33415 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
33416         LDKu8slice ser_ref;
33417         ser_ref.datalen = ser->arr_len;
33418         ser_ref.data = ser->elems;
33419         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
33420         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
33421         FREE(ser);
33422         return (uint32_t)ret_conv;
33423 }
33424
33425 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint32_t obj) {
33426         LDKUpdateAddHTLC obj_conv;
33427         obj_conv.inner = (void*)(obj & (~1));
33428         obj_conv.is_owned = false;
33429         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33430         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
33431         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33432         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33433         CVec_u8Z_free(ret_var);
33434         return ret_arr;
33435 }
33436
33437 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
33438         LDKu8slice ser_ref;
33439         ser_ref.datalen = ser->arr_len;
33440         ser_ref.data = ser->elems;
33441         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
33442         *ret_conv = UpdateAddHTLC_read(ser_ref);
33443         FREE(ser);
33444         return (uint32_t)ret_conv;
33445 }
33446
33447 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint32_t obj) {
33448         LDKPing obj_conv;
33449         obj_conv.inner = (void*)(obj & (~1));
33450         obj_conv.is_owned = false;
33451         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33452         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
33453         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33454         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33455         CVec_u8Z_free(ret_var);
33456         return ret_arr;
33457 }
33458
33459 uint32_t  __attribute__((export_name("TS_Ping_read"))) TS_Ping_read(int8_tArray ser) {
33460         LDKu8slice ser_ref;
33461         ser_ref.datalen = ser->arr_len;
33462         ser_ref.data = ser->elems;
33463         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
33464         *ret_conv = Ping_read(ser_ref);
33465         FREE(ser);
33466         return (uint32_t)ret_conv;
33467 }
33468
33469 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint32_t obj) {
33470         LDKPong obj_conv;
33471         obj_conv.inner = (void*)(obj & (~1));
33472         obj_conv.is_owned = false;
33473         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33474         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
33475         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33476         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33477         CVec_u8Z_free(ret_var);
33478         return ret_arr;
33479 }
33480
33481 uint32_t  __attribute__((export_name("TS_Pong_read"))) TS_Pong_read(int8_tArray ser) {
33482         LDKu8slice ser_ref;
33483         ser_ref.datalen = ser->arr_len;
33484         ser_ref.data = ser->elems;
33485         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
33486         *ret_conv = Pong_read(ser_ref);
33487         FREE(ser);
33488         return (uint32_t)ret_conv;
33489 }
33490
33491 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
33492         LDKUnsignedChannelAnnouncement obj_conv;
33493         obj_conv.inner = (void*)(obj & (~1));
33494         obj_conv.is_owned = false;
33495         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33496         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
33497         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33498         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33499         CVec_u8Z_free(ret_var);
33500         return ret_arr;
33501 }
33502
33503 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
33504         LDKu8slice ser_ref;
33505         ser_ref.datalen = ser->arr_len;
33506         ser_ref.data = ser->elems;
33507         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
33508         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
33509         FREE(ser);
33510         return (uint32_t)ret_conv;
33511 }
33512
33513 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint32_t obj) {
33514         LDKChannelAnnouncement obj_conv;
33515         obj_conv.inner = (void*)(obj & (~1));
33516         obj_conv.is_owned = false;
33517         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33518         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
33519         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33520         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33521         CVec_u8Z_free(ret_var);
33522         return ret_arr;
33523 }
33524
33525 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
33526         LDKu8slice ser_ref;
33527         ser_ref.datalen = ser->arr_len;
33528         ser_ref.data = ser->elems;
33529         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
33530         *ret_conv = ChannelAnnouncement_read(ser_ref);
33531         FREE(ser);
33532         return (uint32_t)ret_conv;
33533 }
33534
33535 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
33536         LDKUnsignedChannelUpdate obj_conv;
33537         obj_conv.inner = (void*)(obj & (~1));
33538         obj_conv.is_owned = false;
33539         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33540         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
33541         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33542         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33543         CVec_u8Z_free(ret_var);
33544         return ret_arr;
33545 }
33546
33547 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
33548         LDKu8slice ser_ref;
33549         ser_ref.datalen = ser->arr_len;
33550         ser_ref.data = ser->elems;
33551         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
33552         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
33553         FREE(ser);
33554         return (uint32_t)ret_conv;
33555 }
33556
33557 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint32_t obj) {
33558         LDKChannelUpdate obj_conv;
33559         obj_conv.inner = (void*)(obj & (~1));
33560         obj_conv.is_owned = false;
33561         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33562         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
33563         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33564         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33565         CVec_u8Z_free(ret_var);
33566         return ret_arr;
33567 }
33568
33569 uint32_t  __attribute__((export_name("TS_ChannelUpdate_read"))) TS_ChannelUpdate_read(int8_tArray ser) {
33570         LDKu8slice ser_ref;
33571         ser_ref.datalen = ser->arr_len;
33572         ser_ref.data = ser->elems;
33573         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
33574         *ret_conv = ChannelUpdate_read(ser_ref);
33575         FREE(ser);
33576         return (uint32_t)ret_conv;
33577 }
33578
33579 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint32_t obj) {
33580         LDKErrorMessage obj_conv;
33581         obj_conv.inner = (void*)(obj & (~1));
33582         obj_conv.is_owned = false;
33583         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33584         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
33585         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33586         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33587         CVec_u8Z_free(ret_var);
33588         return ret_arr;
33589 }
33590
33591 uint32_t  __attribute__((export_name("TS_ErrorMessage_read"))) TS_ErrorMessage_read(int8_tArray ser) {
33592         LDKu8slice ser_ref;
33593         ser_ref.datalen = ser->arr_len;
33594         ser_ref.data = ser->elems;
33595         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
33596         *ret_conv = ErrorMessage_read(ser_ref);
33597         FREE(ser);
33598         return (uint32_t)ret_conv;
33599 }
33600
33601 int8_tArray  __attribute__((export_name("TS_WarningMessage_write"))) TS_WarningMessage_write(uint32_t obj) {
33602         LDKWarningMessage obj_conv;
33603         obj_conv.inner = (void*)(obj & (~1));
33604         obj_conv.is_owned = false;
33605         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33606         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
33607         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33608         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33609         CVec_u8Z_free(ret_var);
33610         return ret_arr;
33611 }
33612
33613 uint32_t  __attribute__((export_name("TS_WarningMessage_read"))) TS_WarningMessage_read(int8_tArray ser) {
33614         LDKu8slice ser_ref;
33615         ser_ref.datalen = ser->arr_len;
33616         ser_ref.data = ser->elems;
33617         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
33618         *ret_conv = WarningMessage_read(ser_ref);
33619         FREE(ser);
33620         return (uint32_t)ret_conv;
33621 }
33622
33623 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
33624         LDKUnsignedNodeAnnouncement obj_conv;
33625         obj_conv.inner = (void*)(obj & (~1));
33626         obj_conv.is_owned = false;
33627         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33628         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
33629         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33630         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33631         CVec_u8Z_free(ret_var);
33632         return ret_arr;
33633 }
33634
33635 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
33636         LDKu8slice ser_ref;
33637         ser_ref.datalen = ser->arr_len;
33638         ser_ref.data = ser->elems;
33639         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
33640         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
33641         FREE(ser);
33642         return (uint32_t)ret_conv;
33643 }
33644
33645 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint32_t obj) {
33646         LDKNodeAnnouncement obj_conv;
33647         obj_conv.inner = (void*)(obj & (~1));
33648         obj_conv.is_owned = false;
33649         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33650         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
33651         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33652         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33653         CVec_u8Z_free(ret_var);
33654         return ret_arr;
33655 }
33656
33657 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_read"))) TS_NodeAnnouncement_read(int8_tArray ser) {
33658         LDKu8slice ser_ref;
33659         ser_ref.datalen = ser->arr_len;
33660         ser_ref.data = ser->elems;
33661         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
33662         *ret_conv = NodeAnnouncement_read(ser_ref);
33663         FREE(ser);
33664         return (uint32_t)ret_conv;
33665 }
33666
33667 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
33668         LDKu8slice ser_ref;
33669         ser_ref.datalen = ser->arr_len;
33670         ser_ref.data = ser->elems;
33671         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
33672         *ret_conv = QueryShortChannelIds_read(ser_ref);
33673         FREE(ser);
33674         return (uint32_t)ret_conv;
33675 }
33676
33677 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint32_t obj) {
33678         LDKQueryShortChannelIds obj_conv;
33679         obj_conv.inner = (void*)(obj & (~1));
33680         obj_conv.is_owned = false;
33681         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33682         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
33683         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33684         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33685         CVec_u8Z_free(ret_var);
33686         return ret_arr;
33687 }
33688
33689 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
33690         LDKReplyShortChannelIdsEnd obj_conv;
33691         obj_conv.inner = (void*)(obj & (~1));
33692         obj_conv.is_owned = false;
33693         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33694         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
33695         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33696         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33697         CVec_u8Z_free(ret_var);
33698         return ret_arr;
33699 }
33700
33701 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
33702         LDKu8slice ser_ref;
33703         ser_ref.datalen = ser->arr_len;
33704         ser_ref.data = ser->elems;
33705         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
33706         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
33707         FREE(ser);
33708         return (uint32_t)ret_conv;
33709 }
33710
33711 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
33712         LDKQueryChannelRange this_arg_conv;
33713         this_arg_conv.inner = (void*)(this_arg & (~1));
33714         this_arg_conv.is_owned = false;
33715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33716         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
33717         return ret_conv;
33718 }
33719
33720 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint32_t obj) {
33721         LDKQueryChannelRange obj_conv;
33722         obj_conv.inner = (void*)(obj & (~1));
33723         obj_conv.is_owned = false;
33724         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33725         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
33726         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33727         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33728         CVec_u8Z_free(ret_var);
33729         return ret_arr;
33730 }
33731
33732 uint32_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_read(int8_tArray ser) {
33733         LDKu8slice ser_ref;
33734         ser_ref.datalen = ser->arr_len;
33735         ser_ref.data = ser->elems;
33736         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
33737         *ret_conv = QueryChannelRange_read(ser_ref);
33738         FREE(ser);
33739         return (uint32_t)ret_conv;
33740 }
33741
33742 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
33743         LDKu8slice ser_ref;
33744         ser_ref.datalen = ser->arr_len;
33745         ser_ref.data = ser->elems;
33746         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
33747         *ret_conv = ReplyChannelRange_read(ser_ref);
33748         FREE(ser);
33749         return (uint32_t)ret_conv;
33750 }
33751
33752 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint32_t obj) {
33753         LDKReplyChannelRange obj_conv;
33754         obj_conv.inner = (void*)(obj & (~1));
33755         obj_conv.is_owned = false;
33756         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33757         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
33758         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33759         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33760         CVec_u8Z_free(ret_var);
33761         return ret_arr;
33762 }
33763
33764 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint32_t obj) {
33765         LDKGossipTimestampFilter obj_conv;
33766         obj_conv.inner = (void*)(obj & (~1));
33767         obj_conv.is_owned = false;
33768         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33769         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
33770         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33771         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33772         CVec_u8Z_free(ret_var);
33773         return ret_arr;
33774 }
33775
33776 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
33777         LDKu8slice ser_ref;
33778         ser_ref.datalen = ser->arr_len;
33779         ser_ref.data = ser->elems;
33780         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
33781         *ret_conv = GossipTimestampFilter_read(ser_ref);
33782         FREE(ser);
33783         return (uint32_t)ret_conv;
33784 }
33785
33786 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
33787         if ((this_ptr & 1) != 0) return;
33788         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33789         CHECK_ACCESS(this_ptr_ptr);
33790         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
33791         FREE((void*)this_ptr);
33792         CustomMessageHandler_free(this_ptr_conv);
33793 }
33794
33795 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
33796         LDKIgnoringMessageHandler this_obj_conv;
33797         this_obj_conv.inner = (void*)(this_obj & (~1));
33798         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33800         IgnoringMessageHandler_free(this_obj_conv);
33801 }
33802
33803 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
33804         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
33805         uint32_t ret_ref = 0;
33806         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33807         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33809         ret_ref = (uintptr_t)ret_var.inner;
33810         if (ret_var.is_owned) {
33811                 ret_ref |= 1;
33812         }
33813         return ret_ref;
33814 }
33815
33816 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
33817         LDKIgnoringMessageHandler this_arg_conv;
33818         this_arg_conv.inner = (void*)(this_arg & (~1));
33819         this_arg_conv.is_owned = false;
33820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33821         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
33822         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
33823         return (uint32_t)ret_ret;
33824 }
33825
33826 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
33827         LDKIgnoringMessageHandler this_arg_conv;
33828         this_arg_conv.inner = (void*)(this_arg & (~1));
33829         this_arg_conv.is_owned = false;
33830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33831         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
33832         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
33833         return (uint32_t)ret_ret;
33834 }
33835
33836 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
33837         LDKIgnoringMessageHandler this_arg_conv;
33838         this_arg_conv.inner = (void*)(this_arg & (~1));
33839         this_arg_conv.is_owned = false;
33840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33841         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
33842         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
33843         return (uint32_t)ret_ret;
33844 }
33845
33846 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
33847         LDKIgnoringMessageHandler this_arg_conv;
33848         this_arg_conv.inner = (void*)(this_arg & (~1));
33849         this_arg_conv.is_owned = false;
33850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33851         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
33852         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
33853         return (uint32_t)ret_ret;
33854 }
33855
33856 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
33857         LDKErroringMessageHandler this_obj_conv;
33858         this_obj_conv.inner = (void*)(this_obj & (~1));
33859         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33861         ErroringMessageHandler_free(this_obj_conv);
33862 }
33863
33864 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
33865         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
33866         uint32_t ret_ref = 0;
33867         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33868         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33870         ret_ref = (uintptr_t)ret_var.inner;
33871         if (ret_var.is_owned) {
33872                 ret_ref |= 1;
33873         }
33874         return ret_ref;
33875 }
33876
33877 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
33878         LDKErroringMessageHandler this_arg_conv;
33879         this_arg_conv.inner = (void*)(this_arg & (~1));
33880         this_arg_conv.is_owned = false;
33881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33882         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
33883         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
33884         return (uint32_t)ret_ret;
33885 }
33886
33887 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
33888         LDKErroringMessageHandler this_arg_conv;
33889         this_arg_conv.inner = (void*)(this_arg & (~1));
33890         this_arg_conv.is_owned = false;
33891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33892         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
33893         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
33894         return (uint32_t)ret_ret;
33895 }
33896
33897 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint32_t this_obj) {
33898         LDKMessageHandler this_obj_conv;
33899         this_obj_conv.inner = (void*)(this_obj & (~1));
33900         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33902         MessageHandler_free(this_obj_conv);
33903 }
33904
33905 uint32_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
33906         LDKMessageHandler this_ptr_conv;
33907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33908         this_ptr_conv.is_owned = false;
33909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33910         // WARNING: This object doesn't live past this scope, needs clone!
33911         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
33912         return ret_ret;
33913 }
33914
33915 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
33916         LDKMessageHandler this_ptr_conv;
33917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33918         this_ptr_conv.is_owned = false;
33919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33920         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33921         CHECK_ACCESS(val_ptr);
33922         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
33923         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
33924                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33925                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
33926         }
33927         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
33928 }
33929
33930 uint32_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
33931         LDKMessageHandler this_ptr_conv;
33932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33933         this_ptr_conv.is_owned = false;
33934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33935         // WARNING: This object doesn't live past this scope, needs clone!
33936         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
33937         return ret_ret;
33938 }
33939
33940 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
33941         LDKMessageHandler this_ptr_conv;
33942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33943         this_ptr_conv.is_owned = false;
33944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33945         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33946         CHECK_ACCESS(val_ptr);
33947         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
33948         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
33949                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33950                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
33951         }
33952         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
33953 }
33954
33955 uint32_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
33956         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
33957         CHECK_ACCESS(chan_handler_arg_ptr);
33958         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
33959         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
33960                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33961                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
33962         }
33963         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
33964         CHECK_ACCESS(route_handler_arg_ptr);
33965         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
33966         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
33967                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33968                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
33969         }
33970         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
33971         uint32_t ret_ref = 0;
33972         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33973         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33975         ret_ref = (uintptr_t)ret_var.inner;
33976         if (ret_var.is_owned) {
33977                 ret_ref |= 1;
33978         }
33979         return ret_ref;
33980 }
33981
33982 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
33983         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
33984         *ret_ret = SocketDescriptor_clone(arg);
33985         return (uint32_t)ret_ret;
33986 }
33987 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
33988         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
33989         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
33990         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
33991         uint32_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
33992         return ret_conv;
33993 }
33994
33995 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint32_t orig) {
33996         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
33997         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
33998         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
33999         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
34000         *ret_ret = SocketDescriptor_clone(orig_conv);
34001         return (uint32_t)ret_ret;
34002 }
34003
34004 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
34005         if ((this_ptr & 1) != 0) return;
34006         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34007         CHECK_ACCESS(this_ptr_ptr);
34008         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
34009         FREE((void*)this_ptr);
34010         SocketDescriptor_free(this_ptr_conv);
34011 }
34012
34013 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint32_t this_obj) {
34014         LDKPeerHandleError this_obj_conv;
34015         this_obj_conv.inner = (void*)(this_obj & (~1));
34016         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34018         PeerHandleError_free(this_obj_conv);
34019 }
34020
34021 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
34022         LDKPeerHandleError this_ptr_conv;
34023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34024         this_ptr_conv.is_owned = false;
34025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34026         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
34027         return ret_conv;
34028 }
34029
34030 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
34031         LDKPeerHandleError this_ptr_conv;
34032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34033         this_ptr_conv.is_owned = false;
34034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34035         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
34036 }
34037
34038 uint32_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
34039         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
34040         uint32_t ret_ref = 0;
34041         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34042         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34044         ret_ref = (uintptr_t)ret_var.inner;
34045         if (ret_var.is_owned) {
34046                 ret_ref |= 1;
34047         }
34048         return ret_ref;
34049 }
34050
34051 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
34052         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
34053 uint32_t ret_ref = 0;
34054 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34055 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34056 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34057 ret_ref = (uintptr_t)ret_var.inner;
34058 if (ret_var.is_owned) {
34059         ret_ref |= 1;
34060 }
34061         return ret_ref;
34062 }
34063 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
34064         LDKPeerHandleError arg_conv;
34065         arg_conv.inner = (void*)(arg & (~1));
34066         arg_conv.is_owned = false;
34067         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34068         uint32_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
34069         return ret_conv;
34070 }
34071
34072 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint32_t orig) {
34073         LDKPeerHandleError orig_conv;
34074         orig_conv.inner = (void*)(orig & (~1));
34075         orig_conv.is_owned = false;
34076         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34077         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
34078         uint32_t ret_ref = 0;
34079         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34080         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34082         ret_ref = (uintptr_t)ret_var.inner;
34083         if (ret_var.is_owned) {
34084                 ret_ref |= 1;
34085         }
34086         return ret_ref;
34087 }
34088
34089 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint32_t this_obj) {
34090         LDKPeerManager this_obj_conv;
34091         this_obj_conv.inner = (void*)(this_obj & (~1));
34092         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34094         PeerManager_free(this_obj_conv);
34095 }
34096
34097 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) {
34098         LDKMessageHandler message_handler_conv;
34099         message_handler_conv.inner = (void*)(message_handler & (~1));
34100         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
34101         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
34102         // WARNING: we need a move here but no clone is available for LDKMessageHandler
34103         LDKSecretKey our_node_secret_ref;
34104         CHECK(our_node_secret->arr_len == 32);
34105         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32); FREE(our_node_secret);
34106         unsigned char ephemeral_random_data_arr[32];
34107         CHECK(ephemeral_random_data->arr_len == 32);
34108         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
34109         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
34110         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
34111         CHECK_ACCESS(logger_ptr);
34112         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34113         if (logger_conv.free == LDKLogger_JCalls_free) {
34114                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34115                 LDKLogger_JCalls_cloned(&logger_conv);
34116         }
34117         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
34118         CHECK_ACCESS(custom_message_handler_ptr);
34119         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
34120         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
34121                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34122                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
34123         }
34124         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
34125         uint32_t ret_ref = 0;
34126         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34127         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34128         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34129         ret_ref = (uintptr_t)ret_var.inner;
34130         if (ret_var.is_owned) {
34131                 ret_ref |= 1;
34132         }
34133         return ret_ref;
34134 }
34135
34136 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
34137         LDKPeerManager this_arg_conv;
34138         this_arg_conv.inner = (void*)(this_arg & (~1));
34139         this_arg_conv.is_owned = false;
34140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34141         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
34142         ptrArray ret_arr = NULL;
34143         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
34144         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
34145         for (size_t m = 0; m < ret_var.datalen; m++) {
34146                 int8_tArray ret_conv_12_arr = init_int8_tArray(33, __LINE__);
34147                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
34148                 ret_arr_ptr[m] = ret_conv_12_arr;
34149         }
34150         
34151         FREE(ret_var.data);
34152         return ret_arr;
34153 }
34154
34155 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) {
34156         LDKPeerManager this_arg_conv;
34157         this_arg_conv.inner = (void*)(this_arg & (~1));
34158         this_arg_conv.is_owned = false;
34159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34160         LDKPublicKey their_node_id_ref;
34161         CHECK(their_node_id->arr_len == 33);
34162         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
34163         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34164         CHECK_ACCESS(descriptor_ptr);
34165         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
34166         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
34167                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34168                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
34169         }
34170         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
34171         CHECK_ACCESS(remote_network_address_ptr);
34172         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
34173         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
34174         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
34175         return (uint32_t)ret_conv;
34176 }
34177
34178 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) {
34179         LDKPeerManager this_arg_conv;
34180         this_arg_conv.inner = (void*)(this_arg & (~1));
34181         this_arg_conv.is_owned = false;
34182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34183         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34184         CHECK_ACCESS(descriptor_ptr);
34185         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
34186         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
34187                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34188                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
34189         }
34190         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
34191         CHECK_ACCESS(remote_network_address_ptr);
34192         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
34193         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
34194         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
34195         return (uint32_t)ret_conv;
34196 }
34197
34198 uint32_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
34199         LDKPeerManager this_arg_conv;
34200         this_arg_conv.inner = (void*)(this_arg & (~1));
34201         this_arg_conv.is_owned = false;
34202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34203         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34204         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
34205         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
34206         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
34207         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
34208         return (uint32_t)ret_conv;
34209 }
34210
34211 uint32_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
34212         LDKPeerManager this_arg_conv;
34213         this_arg_conv.inner = (void*)(this_arg & (~1));
34214         this_arg_conv.is_owned = false;
34215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34216         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
34217         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
34218         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
34219         LDKu8slice data_ref;
34220         data_ref.datalen = data->arr_len;
34221         data_ref.data = data->elems;
34222         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
34223         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
34224         FREE(data);
34225         return (uint32_t)ret_conv;
34226 }
34227
34228 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint32_t this_arg) {
34229         LDKPeerManager this_arg_conv;
34230         this_arg_conv.inner = (void*)(this_arg & (~1));
34231         this_arg_conv.is_owned = false;
34232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34233         PeerManager_process_events(&this_arg_conv);
34234 }
34235
34236 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
34237         LDKPeerManager this_arg_conv;
34238         this_arg_conv.inner = (void*)(this_arg & (~1));
34239         this_arg_conv.is_owned = false;
34240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34241         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34242         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
34243         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
34244         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
34245 }
34246
34247 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) {
34248         LDKPeerManager this_arg_conv;
34249         this_arg_conv.inner = (void*)(this_arg & (~1));
34250         this_arg_conv.is_owned = false;
34251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34252         LDKPublicKey node_id_ref;
34253         CHECK(node_id->arr_len == 33);
34254         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
34255         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
34256 }
34257
34258 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
34259         LDKPeerManager this_arg_conv;
34260         this_arg_conv.inner = (void*)(this_arg & (~1));
34261         this_arg_conv.is_owned = false;
34262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34263         PeerManager_disconnect_all_peers(&this_arg_conv);
34264 }
34265
34266 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
34267         LDKPeerManager this_arg_conv;
34268         this_arg_conv.inner = (void*)(this_arg & (~1));
34269         this_arg_conv.is_owned = false;
34270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34271         PeerManager_timer_tick_occurred(&this_arg_conv);
34272 }
34273
34274 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
34275         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
34276         return ret_conv;
34277 }
34278
34279 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
34280         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
34281         return ret_conv;
34282 }
34283
34284 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
34285         unsigned char commitment_seed_arr[32];
34286         CHECK(commitment_seed->arr_len == 32);
34287         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
34288         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
34289         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34290         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
34291         return ret_arr;
34292 }
34293
34294 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) {
34295         LDKCVec_u8Z to_holder_script_ref;
34296         to_holder_script_ref.datalen = to_holder_script->arr_len;
34297         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
34298         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
34299         LDKCVec_u8Z to_counterparty_script_ref;
34300         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
34301         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
34302         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
34303         LDKOutPoint funding_outpoint_conv;
34304         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34305         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34306         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34307         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34308         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);
34309         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34310         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34311         Transaction_free(ret_var);
34312         return ret_arr;
34313 }
34314
34315 void  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_free"))) TS_CounterpartyCommitmentSecrets_free(uint32_t this_obj) {
34316         LDKCounterpartyCommitmentSecrets this_obj_conv;
34317         this_obj_conv.inner = (void*)(this_obj & (~1));
34318         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34320         CounterpartyCommitmentSecrets_free(this_obj_conv);
34321 }
34322
34323 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
34324         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
34325 uint32_t ret_ref = 0;
34326 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34327 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34328 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34329 ret_ref = (uintptr_t)ret_var.inner;
34330 if (ret_var.is_owned) {
34331         ret_ref |= 1;
34332 }
34333         return ret_ref;
34334 }
34335 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone_ptr"))) TS_CounterpartyCommitmentSecrets_clone_ptr(uint32_t arg) {
34336         LDKCounterpartyCommitmentSecrets arg_conv;
34337         arg_conv.inner = (void*)(arg & (~1));
34338         arg_conv.is_owned = false;
34339         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34340         uint32_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
34341         return ret_conv;
34342 }
34343
34344 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone"))) TS_CounterpartyCommitmentSecrets_clone(uint32_t orig) {
34345         LDKCounterpartyCommitmentSecrets orig_conv;
34346         orig_conv.inner = (void*)(orig & (~1));
34347         orig_conv.is_owned = false;
34348         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34349         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
34350         uint32_t ret_ref = 0;
34351         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34352         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34354         ret_ref = (uintptr_t)ret_var.inner;
34355         if (ret_var.is_owned) {
34356                 ret_ref |= 1;
34357         }
34358         return ret_ref;
34359 }
34360
34361 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_new"))) TS_CounterpartyCommitmentSecrets_new() {
34362         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
34363         uint32_t ret_ref = 0;
34364         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34365         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34367         ret_ref = (uintptr_t)ret_var.inner;
34368         if (ret_var.is_owned) {
34369                 ret_ref |= 1;
34370         }
34371         return ret_ref;
34372 }
34373
34374 int64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_min_seen_secret"))) TS_CounterpartyCommitmentSecrets_get_min_seen_secret(uint32_t this_arg) {
34375         LDKCounterpartyCommitmentSecrets this_arg_conv;
34376         this_arg_conv.inner = (void*)(this_arg & (~1));
34377         this_arg_conv.is_owned = false;
34378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34379         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
34380         return ret_conv;
34381 }
34382
34383 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_provide_secret"))) TS_CounterpartyCommitmentSecrets_provide_secret(uint32_t this_arg, int64_t idx, int8_tArray secret) {
34384         LDKCounterpartyCommitmentSecrets this_arg_conv;
34385         this_arg_conv.inner = (void*)(this_arg & (~1));
34386         this_arg_conv.is_owned = false;
34387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34388         LDKThirtyTwoBytes secret_ref;
34389         CHECK(secret->arr_len == 32);
34390         memcpy(secret_ref.data, secret->elems, 32); FREE(secret);
34391         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
34392         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
34393         return (uint32_t)ret_conv;
34394 }
34395
34396 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_secret"))) TS_CounterpartyCommitmentSecrets_get_secret(uint32_t this_arg, int64_t idx) {
34397         LDKCounterpartyCommitmentSecrets this_arg_conv;
34398         this_arg_conv.inner = (void*)(this_arg & (~1));
34399         this_arg_conv.is_owned = false;
34400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34401         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34402         memcpy(ret_arr->elems, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data, 32);
34403         return ret_arr;
34404 }
34405
34406 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_write"))) TS_CounterpartyCommitmentSecrets_write(uint32_t obj) {
34407         LDKCounterpartyCommitmentSecrets obj_conv;
34408         obj_conv.inner = (void*)(obj & (~1));
34409         obj_conv.is_owned = false;
34410         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34411         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
34412         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34413         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34414         CVec_u8Z_free(ret_var);
34415         return ret_arr;
34416 }
34417
34418 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_read"))) TS_CounterpartyCommitmentSecrets_read(int8_tArray ser) {
34419         LDKu8slice ser_ref;
34420         ser_ref.datalen = ser->arr_len;
34421         ser_ref.data = ser->elems;
34422         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
34423         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
34424         FREE(ser);
34425         return (uint32_t)ret_conv;
34426 }
34427
34428 uint32_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
34429         LDKPublicKey per_commitment_point_ref;
34430         CHECK(per_commitment_point->arr_len == 33);
34431         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
34432         unsigned char base_secret_arr[32];
34433         CHECK(base_secret->arr_len == 32);
34434         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
34435         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
34436         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
34437         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
34438         return (uint32_t)ret_conv;
34439 }
34440
34441 uint32_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
34442         LDKPublicKey per_commitment_point_ref;
34443         CHECK(per_commitment_point->arr_len == 33);
34444         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
34445         LDKPublicKey base_point_ref;
34446         CHECK(base_point->arr_len == 33);
34447         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
34448         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
34449         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
34450         return (uint32_t)ret_conv;
34451 }
34452
34453 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) {
34454         unsigned char per_commitment_secret_arr[32];
34455         CHECK(per_commitment_secret->arr_len == 32);
34456         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
34457         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
34458         unsigned char countersignatory_revocation_base_secret_arr[32];
34459         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
34460         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
34461         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
34462         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
34463         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
34464         return (uint32_t)ret_conv;
34465 }
34466
34467 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) {
34468         LDKPublicKey per_commitment_point_ref;
34469         CHECK(per_commitment_point->arr_len == 33);
34470         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
34471         LDKPublicKey countersignatory_revocation_base_point_ref;
34472         CHECK(countersignatory_revocation_base_point->arr_len == 33);
34473         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
34474         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
34475         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
34476         return (uint32_t)ret_conv;
34477 }
34478
34479 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint32_t this_obj) {
34480         LDKTxCreationKeys this_obj_conv;
34481         this_obj_conv.inner = (void*)(this_obj & (~1));
34482         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34484         TxCreationKeys_free(this_obj_conv);
34485 }
34486
34487 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
34488         LDKTxCreationKeys this_ptr_conv;
34489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34490         this_ptr_conv.is_owned = false;
34491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34492         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34493         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
34494         return ret_arr;
34495 }
34496
34497 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
34498         LDKTxCreationKeys this_ptr_conv;
34499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34500         this_ptr_conv.is_owned = false;
34501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34502         LDKPublicKey val_ref;
34503         CHECK(val->arr_len == 33);
34504         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34505         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
34506 }
34507
34508 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
34509         LDKTxCreationKeys this_ptr_conv;
34510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34511         this_ptr_conv.is_owned = false;
34512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34513         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34514         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
34515         return ret_arr;
34516 }
34517
34518 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
34519         LDKTxCreationKeys this_ptr_conv;
34520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34521         this_ptr_conv.is_owned = false;
34522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34523         LDKPublicKey val_ref;
34524         CHECK(val->arr_len == 33);
34525         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34526         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
34527 }
34528
34529 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
34530         LDKTxCreationKeys this_ptr_conv;
34531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34532         this_ptr_conv.is_owned = false;
34533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34534         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34535         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
34536         return ret_arr;
34537 }
34538
34539 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
34540         LDKTxCreationKeys this_ptr_conv;
34541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34542         this_ptr_conv.is_owned = false;
34543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34544         LDKPublicKey val_ref;
34545         CHECK(val->arr_len == 33);
34546         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34547         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
34548 }
34549
34550 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
34551         LDKTxCreationKeys this_ptr_conv;
34552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34553         this_ptr_conv.is_owned = false;
34554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34555         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34556         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
34557         return ret_arr;
34558 }
34559
34560 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
34561         LDKTxCreationKeys this_ptr_conv;
34562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34563         this_ptr_conv.is_owned = false;
34564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34565         LDKPublicKey val_ref;
34566         CHECK(val->arr_len == 33);
34567         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34568         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
34569 }
34570
34571 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
34572         LDKTxCreationKeys this_ptr_conv;
34573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34574         this_ptr_conv.is_owned = false;
34575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34576         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34577         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
34578         return ret_arr;
34579 }
34580
34581 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) {
34582         LDKTxCreationKeys this_ptr_conv;
34583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34584         this_ptr_conv.is_owned = false;
34585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34586         LDKPublicKey val_ref;
34587         CHECK(val->arr_len == 33);
34588         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34589         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
34590 }
34591
34592 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) {
34593         LDKPublicKey per_commitment_point_arg_ref;
34594         CHECK(per_commitment_point_arg->arr_len == 33);
34595         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
34596         LDKPublicKey revocation_key_arg_ref;
34597         CHECK(revocation_key_arg->arr_len == 33);
34598         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
34599         LDKPublicKey broadcaster_htlc_key_arg_ref;
34600         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
34601         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
34602         LDKPublicKey countersignatory_htlc_key_arg_ref;
34603         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
34604         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
34605         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
34606         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
34607         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
34608         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);
34609         uint32_t ret_ref = 0;
34610         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34611         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34613         ret_ref = (uintptr_t)ret_var.inner;
34614         if (ret_var.is_owned) {
34615                 ret_ref |= 1;
34616         }
34617         return ret_ref;
34618 }
34619
34620 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
34621         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
34622 uint32_t ret_ref = 0;
34623 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34624 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34625 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34626 ret_ref = (uintptr_t)ret_var.inner;
34627 if (ret_var.is_owned) {
34628         ret_ref |= 1;
34629 }
34630         return ret_ref;
34631 }
34632 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
34633         LDKTxCreationKeys arg_conv;
34634         arg_conv.inner = (void*)(arg & (~1));
34635         arg_conv.is_owned = false;
34636         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34637         uint32_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
34638         return ret_conv;
34639 }
34640
34641 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint32_t orig) {
34642         LDKTxCreationKeys orig_conv;
34643         orig_conv.inner = (void*)(orig & (~1));
34644         orig_conv.is_owned = false;
34645         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34646         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
34647         uint32_t ret_ref = 0;
34648         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34649         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34651         ret_ref = (uintptr_t)ret_var.inner;
34652         if (ret_var.is_owned) {
34653                 ret_ref |= 1;
34654         }
34655         return ret_ref;
34656 }
34657
34658 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint32_t obj) {
34659         LDKTxCreationKeys obj_conv;
34660         obj_conv.inner = (void*)(obj & (~1));
34661         obj_conv.is_owned = false;
34662         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34663         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
34664         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34665         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34666         CVec_u8Z_free(ret_var);
34667         return ret_arr;
34668 }
34669
34670 uint32_t  __attribute__((export_name("TS_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
34671         LDKu8slice ser_ref;
34672         ser_ref.datalen = ser->arr_len;
34673         ser_ref.data = ser->elems;
34674         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
34675         *ret_conv = TxCreationKeys_read(ser_ref);
34676         FREE(ser);
34677         return (uint32_t)ret_conv;
34678 }
34679
34680 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
34681         LDKChannelPublicKeys this_obj_conv;
34682         this_obj_conv.inner = (void*)(this_obj & (~1));
34683         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34685         ChannelPublicKeys_free(this_obj_conv);
34686 }
34687
34688 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
34689         LDKChannelPublicKeys this_ptr_conv;
34690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34691         this_ptr_conv.is_owned = false;
34692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34693         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34694         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
34695         return ret_arr;
34696 }
34697
34698 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
34699         LDKChannelPublicKeys this_ptr_conv;
34700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34701         this_ptr_conv.is_owned = false;
34702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34703         LDKPublicKey val_ref;
34704         CHECK(val->arr_len == 33);
34705         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34706         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
34707 }
34708
34709 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
34710         LDKChannelPublicKeys this_ptr_conv;
34711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34712         this_ptr_conv.is_owned = false;
34713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34714         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34715         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
34716         return ret_arr;
34717 }
34718
34719 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
34720         LDKChannelPublicKeys this_ptr_conv;
34721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34722         this_ptr_conv.is_owned = false;
34723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34724         LDKPublicKey val_ref;
34725         CHECK(val->arr_len == 33);
34726         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34727         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
34728 }
34729
34730 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
34731         LDKChannelPublicKeys this_ptr_conv;
34732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34733         this_ptr_conv.is_owned = false;
34734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34735         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34736         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
34737         return ret_arr;
34738 }
34739
34740 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
34741         LDKChannelPublicKeys this_ptr_conv;
34742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34743         this_ptr_conv.is_owned = false;
34744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34745         LDKPublicKey val_ref;
34746         CHECK(val->arr_len == 33);
34747         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34748         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
34749 }
34750
34751 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
34752         LDKChannelPublicKeys this_ptr_conv;
34753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34754         this_ptr_conv.is_owned = false;
34755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34756         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34757         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
34758         return ret_arr;
34759 }
34760
34761 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
34762         LDKChannelPublicKeys this_ptr_conv;
34763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34764         this_ptr_conv.is_owned = false;
34765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34766         LDKPublicKey val_ref;
34767         CHECK(val->arr_len == 33);
34768         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34769         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
34770 }
34771
34772 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
34773         LDKChannelPublicKeys this_ptr_conv;
34774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34775         this_ptr_conv.is_owned = false;
34776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34777         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34778         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
34779         return ret_arr;
34780 }
34781
34782 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
34783         LDKChannelPublicKeys this_ptr_conv;
34784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34785         this_ptr_conv.is_owned = false;
34786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34787         LDKPublicKey val_ref;
34788         CHECK(val->arr_len == 33);
34789         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34790         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
34791 }
34792
34793 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) {
34794         LDKPublicKey funding_pubkey_arg_ref;
34795         CHECK(funding_pubkey_arg->arr_len == 33);
34796         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
34797         LDKPublicKey revocation_basepoint_arg_ref;
34798         CHECK(revocation_basepoint_arg->arr_len == 33);
34799         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
34800         LDKPublicKey payment_point_arg_ref;
34801         CHECK(payment_point_arg->arr_len == 33);
34802         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
34803         LDKPublicKey delayed_payment_basepoint_arg_ref;
34804         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
34805         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
34806         LDKPublicKey htlc_basepoint_arg_ref;
34807         CHECK(htlc_basepoint_arg->arr_len == 33);
34808         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
34809         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);
34810         uint32_t ret_ref = 0;
34811         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34812         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34814         ret_ref = (uintptr_t)ret_var.inner;
34815         if (ret_var.is_owned) {
34816                 ret_ref |= 1;
34817         }
34818         return ret_ref;
34819 }
34820
34821 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
34822         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
34823 uint32_t ret_ref = 0;
34824 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34825 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34826 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34827 ret_ref = (uintptr_t)ret_var.inner;
34828 if (ret_var.is_owned) {
34829         ret_ref |= 1;
34830 }
34831         return ret_ref;
34832 }
34833 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
34834         LDKChannelPublicKeys arg_conv;
34835         arg_conv.inner = (void*)(arg & (~1));
34836         arg_conv.is_owned = false;
34837         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34838         uint32_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
34839         return ret_conv;
34840 }
34841
34842 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
34843         LDKChannelPublicKeys orig_conv;
34844         orig_conv.inner = (void*)(orig & (~1));
34845         orig_conv.is_owned = false;
34846         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34847         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
34848         uint32_t ret_ref = 0;
34849         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34850         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34852         ret_ref = (uintptr_t)ret_var.inner;
34853         if (ret_var.is_owned) {
34854                 ret_ref |= 1;
34855         }
34856         return ret_ref;
34857 }
34858
34859 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint32_t obj) {
34860         LDKChannelPublicKeys obj_conv;
34861         obj_conv.inner = (void*)(obj & (~1));
34862         obj_conv.is_owned = false;
34863         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34864         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
34865         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34866         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34867         CVec_u8Z_free(ret_var);
34868         return ret_arr;
34869 }
34870
34871 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
34872         LDKu8slice ser_ref;
34873         ser_ref.datalen = ser->arr_len;
34874         ser_ref.data = ser->elems;
34875         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
34876         *ret_conv = ChannelPublicKeys_read(ser_ref);
34877         FREE(ser);
34878         return (uint32_t)ret_conv;
34879 }
34880
34881 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) {
34882         LDKPublicKey per_commitment_point_ref;
34883         CHECK(per_commitment_point->arr_len == 33);
34884         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
34885         LDKPublicKey broadcaster_delayed_payment_base_ref;
34886         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
34887         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
34888         LDKPublicKey broadcaster_htlc_base_ref;
34889         CHECK(broadcaster_htlc_base->arr_len == 33);
34890         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
34891         LDKPublicKey countersignatory_revocation_base_ref;
34892         CHECK(countersignatory_revocation_base->arr_len == 33);
34893         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
34894         LDKPublicKey countersignatory_htlc_base_ref;
34895         CHECK(countersignatory_htlc_base->arr_len == 33);
34896         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
34897         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
34898         *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);
34899         return (uint32_t)ret_conv;
34900 }
34901
34902 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) {
34903         LDKPublicKey per_commitment_point_ref;
34904         CHECK(per_commitment_point->arr_len == 33);
34905         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
34906         LDKChannelPublicKeys broadcaster_keys_conv;
34907         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
34908         broadcaster_keys_conv.is_owned = false;
34909         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
34910         LDKChannelPublicKeys countersignatory_keys_conv;
34911         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
34912         countersignatory_keys_conv.is_owned = false;
34913         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
34914         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
34915         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
34916         return (uint32_t)ret_conv;
34917 }
34918
34919 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) {
34920         LDKPublicKey revocation_key_ref;
34921         CHECK(revocation_key->arr_len == 33);
34922         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
34923         LDKPublicKey broadcaster_delayed_payment_key_ref;
34924         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
34925         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
34926         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
34927         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34928         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34929         CVec_u8Z_free(ret_var);
34930         return ret_arr;
34931 }
34932
34933 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
34934         LDKHTLCOutputInCommitment this_obj_conv;
34935         this_obj_conv.inner = (void*)(this_obj & (~1));
34936         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34938         HTLCOutputInCommitment_free(this_obj_conv);
34939 }
34940
34941 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
34942         LDKHTLCOutputInCommitment this_ptr_conv;
34943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34944         this_ptr_conv.is_owned = false;
34945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34946         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
34947         return ret_conv;
34948 }
34949
34950 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
34951         LDKHTLCOutputInCommitment this_ptr_conv;
34952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34953         this_ptr_conv.is_owned = false;
34954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34955         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
34956 }
34957
34958 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
34959         LDKHTLCOutputInCommitment this_ptr_conv;
34960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34961         this_ptr_conv.is_owned = false;
34962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34963         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
34964         return ret_conv;
34965 }
34966
34967 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
34968         LDKHTLCOutputInCommitment this_ptr_conv;
34969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34970         this_ptr_conv.is_owned = false;
34971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34972         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
34973 }
34974
34975 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
34976         LDKHTLCOutputInCommitment this_ptr_conv;
34977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34978         this_ptr_conv.is_owned = false;
34979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34980         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
34981         return ret_conv;
34982 }
34983
34984 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
34985         LDKHTLCOutputInCommitment this_ptr_conv;
34986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34987         this_ptr_conv.is_owned = false;
34988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34989         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
34990 }
34991
34992 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
34993         LDKHTLCOutputInCommitment this_ptr_conv;
34994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34995         this_ptr_conv.is_owned = false;
34996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34997         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34998         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
34999         return ret_arr;
35000 }
35001
35002 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
35003         LDKHTLCOutputInCommitment this_ptr_conv;
35004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35005         this_ptr_conv.is_owned = false;
35006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35007         LDKThirtyTwoBytes val_ref;
35008         CHECK(val->arr_len == 32);
35009         memcpy(val_ref.data, val->elems, 32); FREE(val);
35010         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
35011 }
35012
35013 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
35014         LDKHTLCOutputInCommitment this_ptr_conv;
35015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35016         this_ptr_conv.is_owned = false;
35017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35018         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
35019         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
35020         uint32_t ret_ref = (uintptr_t)ret_copy;
35021         return ret_ref;
35022 }
35023
35024 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
35025         LDKHTLCOutputInCommitment this_ptr_conv;
35026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35027         this_ptr_conv.is_owned = false;
35028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35029         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
35030         CHECK_ACCESS(val_ptr);
35031         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
35032         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
35033         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
35034 }
35035
35036 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) {
35037         LDKThirtyTwoBytes payment_hash_arg_ref;
35038         CHECK(payment_hash_arg->arr_len == 32);
35039         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
35040         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
35041         CHECK_ACCESS(transaction_output_index_arg_ptr);
35042         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
35043         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
35044         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
35045         uint32_t ret_ref = 0;
35046         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35047         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35049         ret_ref = (uintptr_t)ret_var.inner;
35050         if (ret_var.is_owned) {
35051                 ret_ref |= 1;
35052         }
35053         return ret_ref;
35054 }
35055
35056 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
35057         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
35058 uint32_t ret_ref = 0;
35059 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35060 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35061 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35062 ret_ref = (uintptr_t)ret_var.inner;
35063 if (ret_var.is_owned) {
35064         ret_ref |= 1;
35065 }
35066         return ret_ref;
35067 }
35068 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
35069         LDKHTLCOutputInCommitment arg_conv;
35070         arg_conv.inner = (void*)(arg & (~1));
35071         arg_conv.is_owned = false;
35072         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35073         uint32_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
35074         return ret_conv;
35075 }
35076
35077 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
35078         LDKHTLCOutputInCommitment orig_conv;
35079         orig_conv.inner = (void*)(orig & (~1));
35080         orig_conv.is_owned = false;
35081         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35082         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
35083         uint32_t ret_ref = 0;
35084         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35085         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35087         ret_ref = (uintptr_t)ret_var.inner;
35088         if (ret_var.is_owned) {
35089                 ret_ref |= 1;
35090         }
35091         return ret_ref;
35092 }
35093
35094 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
35095         LDKHTLCOutputInCommitment obj_conv;
35096         obj_conv.inner = (void*)(obj & (~1));
35097         obj_conv.is_owned = false;
35098         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35099         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
35100         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35101         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35102         CVec_u8Z_free(ret_var);
35103         return ret_arr;
35104 }
35105
35106 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
35107         LDKu8slice ser_ref;
35108         ser_ref.datalen = ser->arr_len;
35109         ser_ref.data = ser->elems;
35110         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
35111         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
35112         FREE(ser);
35113         return (uint32_t)ret_conv;
35114 }
35115
35116 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
35117         LDKHTLCOutputInCommitment htlc_conv;
35118         htlc_conv.inner = (void*)(htlc & (~1));
35119         htlc_conv.is_owned = false;
35120         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
35121         LDKTxCreationKeys keys_conv;
35122         keys_conv.inner = (void*)(keys & (~1));
35123         keys_conv.is_owned = false;
35124         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
35125         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
35126         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35127         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35128         CVec_u8Z_free(ret_var);
35129         return ret_arr;
35130 }
35131
35132 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
35133         LDKPublicKey broadcaster_ref;
35134         CHECK(broadcaster->arr_len == 33);
35135         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
35136         LDKPublicKey countersignatory_ref;
35137         CHECK(countersignatory->arr_len == 33);
35138         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
35139         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
35140         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35141         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35142         CVec_u8Z_free(ret_var);
35143         return ret_arr;
35144 }
35145
35146 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) {
35147         unsigned char commitment_txid_arr[32];
35148         CHECK(commitment_txid->arr_len == 32);
35149         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
35150         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
35151         LDKHTLCOutputInCommitment htlc_conv;
35152         htlc_conv.inner = (void*)(htlc & (~1));
35153         htlc_conv.is_owned = false;
35154         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
35155         LDKPublicKey broadcaster_delayed_payment_key_ref;
35156         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
35157         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
35158         LDKPublicKey revocation_key_ref;
35159         CHECK(revocation_key->arr_len == 33);
35160         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
35161         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);
35162         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35163         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35164         Transaction_free(ret_var);
35165         return ret_arr;
35166 }
35167
35168 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
35169         LDKPublicKey funding_pubkey_ref;
35170         CHECK(funding_pubkey->arr_len == 33);
35171         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
35172         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
35173         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35174         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35175         CVec_u8Z_free(ret_var);
35176         return ret_arr;
35177 }
35178
35179 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
35180         LDKChannelTransactionParameters this_obj_conv;
35181         this_obj_conv.inner = (void*)(this_obj & (~1));
35182         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35184         ChannelTransactionParameters_free(this_obj_conv);
35185 }
35186
35187 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
35188         LDKChannelTransactionParameters this_ptr_conv;
35189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35190         this_ptr_conv.is_owned = false;
35191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35192         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
35193         uint32_t ret_ref = 0;
35194         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35195         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35197         ret_ref = (uintptr_t)ret_var.inner;
35198         if (ret_var.is_owned) {
35199                 ret_ref |= 1;
35200         }
35201         return ret_ref;
35202 }
35203
35204 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
35205         LDKChannelTransactionParameters this_ptr_conv;
35206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35207         this_ptr_conv.is_owned = false;
35208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35209         LDKChannelPublicKeys val_conv;
35210         val_conv.inner = (void*)(val & (~1));
35211         val_conv.is_owned = (val & 1) || (val == 0);
35212         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35213         val_conv = ChannelPublicKeys_clone(&val_conv);
35214         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
35215 }
35216
35217 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
35218         LDKChannelTransactionParameters this_ptr_conv;
35219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35220         this_ptr_conv.is_owned = false;
35221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35222         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
35223         return ret_conv;
35224 }
35225
35226 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) {
35227         LDKChannelTransactionParameters this_ptr_conv;
35228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35229         this_ptr_conv.is_owned = false;
35230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35231         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
35232 }
35233
35234 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
35235         LDKChannelTransactionParameters this_ptr_conv;
35236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35237         this_ptr_conv.is_owned = false;
35238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35239         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
35240         return ret_conv;
35241 }
35242
35243 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
35244         LDKChannelTransactionParameters this_ptr_conv;
35245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35246         this_ptr_conv.is_owned = false;
35247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35248         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
35249 }
35250
35251 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
35252         LDKChannelTransactionParameters this_ptr_conv;
35253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35254         this_ptr_conv.is_owned = false;
35255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35256         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
35257         uint32_t ret_ref = 0;
35258         if ((uintptr_t)ret_var.inner > 4096) {
35259                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35260                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35262                 ret_ref = (uintptr_t)ret_var.inner;
35263                 if (ret_var.is_owned) {
35264                         ret_ref |= 1;
35265                 }
35266         }
35267         return ret_ref;
35268 }
35269
35270 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
35271         LDKChannelTransactionParameters this_ptr_conv;
35272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35273         this_ptr_conv.is_owned = false;
35274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35275         LDKCounterpartyChannelTransactionParameters val_conv;
35276         val_conv.inner = (void*)(val & (~1));
35277         val_conv.is_owned = (val & 1) || (val == 0);
35278         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35279         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
35280         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
35281 }
35282
35283 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
35284         LDKChannelTransactionParameters this_ptr_conv;
35285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35286         this_ptr_conv.is_owned = false;
35287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35288         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
35289         uint32_t ret_ref = 0;
35290         if ((uintptr_t)ret_var.inner > 4096) {
35291                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35292                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35294                 ret_ref = (uintptr_t)ret_var.inner;
35295                 if (ret_var.is_owned) {
35296                         ret_ref |= 1;
35297                 }
35298         }
35299         return ret_ref;
35300 }
35301
35302 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
35303         LDKChannelTransactionParameters this_ptr_conv;
35304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35305         this_ptr_conv.is_owned = false;
35306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35307         LDKOutPoint val_conv;
35308         val_conv.inner = (void*)(val & (~1));
35309         val_conv.is_owned = (val & 1) || (val == 0);
35310         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35311         val_conv = OutPoint_clone(&val_conv);
35312         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
35313 }
35314
35315 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
35316         LDKChannelTransactionParameters this_ptr_conv;
35317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35318         this_ptr_conv.is_owned = false;
35319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35320         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
35321         return ret_conv;
35322 }
35323
35324 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
35325         LDKChannelTransactionParameters this_ptr_conv;
35326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35327         this_ptr_conv.is_owned = false;
35328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35329         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
35330         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
35331 }
35332
35333 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) {
35334         LDKChannelPublicKeys holder_pubkeys_arg_conv;
35335         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
35336         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
35337         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
35338         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
35339         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
35340         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
35341         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
35342         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
35343         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
35344         LDKOutPoint funding_outpoint_arg_conv;
35345         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
35346         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
35347         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
35348         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
35349         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
35350         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);
35351         uint32_t ret_ref = 0;
35352         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35353         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35355         ret_ref = (uintptr_t)ret_var.inner;
35356         if (ret_var.is_owned) {
35357                 ret_ref |= 1;
35358         }
35359         return ret_ref;
35360 }
35361
35362 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
35363         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
35364 uint32_t ret_ref = 0;
35365 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35366 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35367 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35368 ret_ref = (uintptr_t)ret_var.inner;
35369 if (ret_var.is_owned) {
35370         ret_ref |= 1;
35371 }
35372         return ret_ref;
35373 }
35374 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
35375         LDKChannelTransactionParameters arg_conv;
35376         arg_conv.inner = (void*)(arg & (~1));
35377         arg_conv.is_owned = false;
35378         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35379         uint32_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
35380         return ret_conv;
35381 }
35382
35383 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
35384         LDKChannelTransactionParameters orig_conv;
35385         orig_conv.inner = (void*)(orig & (~1));
35386         orig_conv.is_owned = false;
35387         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35388         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
35389         uint32_t ret_ref = 0;
35390         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35391         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35393         ret_ref = (uintptr_t)ret_var.inner;
35394         if (ret_var.is_owned) {
35395                 ret_ref |= 1;
35396         }
35397         return ret_ref;
35398 }
35399
35400 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
35401         LDKCounterpartyChannelTransactionParameters this_obj_conv;
35402         this_obj_conv.inner = (void*)(this_obj & (~1));
35403         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35405         CounterpartyChannelTransactionParameters_free(this_obj_conv);
35406 }
35407
35408 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
35409         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
35410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35411         this_ptr_conv.is_owned = false;
35412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35413         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
35414         uint32_t ret_ref = 0;
35415         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35416         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35418         ret_ref = (uintptr_t)ret_var.inner;
35419         if (ret_var.is_owned) {
35420                 ret_ref |= 1;
35421         }
35422         return ret_ref;
35423 }
35424
35425 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
35426         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
35427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35428         this_ptr_conv.is_owned = false;
35429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35430         LDKChannelPublicKeys val_conv;
35431         val_conv.inner = (void*)(val & (~1));
35432         val_conv.is_owned = (val & 1) || (val == 0);
35433         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35434         val_conv = ChannelPublicKeys_clone(&val_conv);
35435         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
35436 }
35437
35438 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
35439         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
35440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35441         this_ptr_conv.is_owned = false;
35442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35443         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
35444         return ret_conv;
35445 }
35446
35447 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
35448         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
35449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35450         this_ptr_conv.is_owned = false;
35451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35452         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
35453 }
35454
35455 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
35456         LDKChannelPublicKeys pubkeys_arg_conv;
35457         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
35458         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
35459         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
35460         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
35461         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
35462         uint32_t ret_ref = 0;
35463         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35464         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35466         ret_ref = (uintptr_t)ret_var.inner;
35467         if (ret_var.is_owned) {
35468                 ret_ref |= 1;
35469         }
35470         return ret_ref;
35471 }
35472
35473 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
35474         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
35475 uint32_t ret_ref = 0;
35476 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35477 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35478 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35479 ret_ref = (uintptr_t)ret_var.inner;
35480 if (ret_var.is_owned) {
35481         ret_ref |= 1;
35482 }
35483         return ret_ref;
35484 }
35485 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
35486         LDKCounterpartyChannelTransactionParameters arg_conv;
35487         arg_conv.inner = (void*)(arg & (~1));
35488         arg_conv.is_owned = false;
35489         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35490         uint32_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
35491         return ret_conv;
35492 }
35493
35494 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
35495         LDKCounterpartyChannelTransactionParameters orig_conv;
35496         orig_conv.inner = (void*)(orig & (~1));
35497         orig_conv.is_owned = false;
35498         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35499         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
35500         uint32_t ret_ref = 0;
35501         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35502         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35504         ret_ref = (uintptr_t)ret_var.inner;
35505         if (ret_var.is_owned) {
35506                 ret_ref |= 1;
35507         }
35508         return ret_ref;
35509 }
35510
35511 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
35512         LDKChannelTransactionParameters this_arg_conv;
35513         this_arg_conv.inner = (void*)(this_arg & (~1));
35514         this_arg_conv.is_owned = false;
35515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35516         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
35517         return ret_conv;
35518 }
35519
35520 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
35521         LDKChannelTransactionParameters this_arg_conv;
35522         this_arg_conv.inner = (void*)(this_arg & (~1));
35523         this_arg_conv.is_owned = false;
35524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35525         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
35526         uint32_t ret_ref = 0;
35527         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35528         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35530         ret_ref = (uintptr_t)ret_var.inner;
35531         if (ret_var.is_owned) {
35532                 ret_ref |= 1;
35533         }
35534         return ret_ref;
35535 }
35536
35537 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
35538         LDKChannelTransactionParameters this_arg_conv;
35539         this_arg_conv.inner = (void*)(this_arg & (~1));
35540         this_arg_conv.is_owned = false;
35541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35542         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
35543         uint32_t ret_ref = 0;
35544         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35545         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35547         ret_ref = (uintptr_t)ret_var.inner;
35548         if (ret_var.is_owned) {
35549                 ret_ref |= 1;
35550         }
35551         return ret_ref;
35552 }
35553
35554 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
35555         LDKCounterpartyChannelTransactionParameters obj_conv;
35556         obj_conv.inner = (void*)(obj & (~1));
35557         obj_conv.is_owned = false;
35558         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35559         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
35560         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35561         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35562         CVec_u8Z_free(ret_var);
35563         return ret_arr;
35564 }
35565
35566 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
35567         LDKu8slice ser_ref;
35568         ser_ref.datalen = ser->arr_len;
35569         ser_ref.data = ser->elems;
35570         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
35571         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
35572         FREE(ser);
35573         return (uint32_t)ret_conv;
35574 }
35575
35576 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
35577         LDKChannelTransactionParameters obj_conv;
35578         obj_conv.inner = (void*)(obj & (~1));
35579         obj_conv.is_owned = false;
35580         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35581         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
35582         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35583         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35584         CVec_u8Z_free(ret_var);
35585         return ret_arr;
35586 }
35587
35588 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
35589         LDKu8slice ser_ref;
35590         ser_ref.datalen = ser->arr_len;
35591         ser_ref.data = ser->elems;
35592         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
35593         *ret_conv = ChannelTransactionParameters_read(ser_ref);
35594         FREE(ser);
35595         return (uint32_t)ret_conv;
35596 }
35597
35598 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
35599         LDKDirectedChannelTransactionParameters this_obj_conv;
35600         this_obj_conv.inner = (void*)(this_obj & (~1));
35601         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35603         DirectedChannelTransactionParameters_free(this_obj_conv);
35604 }
35605
35606 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
35607         LDKDirectedChannelTransactionParameters this_arg_conv;
35608         this_arg_conv.inner = (void*)(this_arg & (~1));
35609         this_arg_conv.is_owned = false;
35610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35611         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
35612         uint32_t ret_ref = 0;
35613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35616         ret_ref = (uintptr_t)ret_var.inner;
35617         if (ret_var.is_owned) {
35618                 ret_ref |= 1;
35619         }
35620         return ret_ref;
35621 }
35622
35623 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
35624         LDKDirectedChannelTransactionParameters this_arg_conv;
35625         this_arg_conv.inner = (void*)(this_arg & (~1));
35626         this_arg_conv.is_owned = false;
35627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35628         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
35629         uint32_t ret_ref = 0;
35630         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35631         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35633         ret_ref = (uintptr_t)ret_var.inner;
35634         if (ret_var.is_owned) {
35635                 ret_ref |= 1;
35636         }
35637         return ret_ref;
35638 }
35639
35640 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
35641         LDKDirectedChannelTransactionParameters this_arg_conv;
35642         this_arg_conv.inner = (void*)(this_arg & (~1));
35643         this_arg_conv.is_owned = false;
35644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35645         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
35646         return ret_conv;
35647 }
35648
35649 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
35650         LDKDirectedChannelTransactionParameters this_arg_conv;
35651         this_arg_conv.inner = (void*)(this_arg & (~1));
35652         this_arg_conv.is_owned = false;
35653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35654         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
35655         return ret_conv;
35656 }
35657
35658 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
35659         LDKDirectedChannelTransactionParameters this_arg_conv;
35660         this_arg_conv.inner = (void*)(this_arg & (~1));
35661         this_arg_conv.is_owned = false;
35662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35663         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
35664         uint32_t ret_ref = 0;
35665         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35666         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35668         ret_ref = (uintptr_t)ret_var.inner;
35669         if (ret_var.is_owned) {
35670                 ret_ref |= 1;
35671         }
35672         return ret_ref;
35673 }
35674
35675 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
35676         LDKDirectedChannelTransactionParameters this_arg_conv;
35677         this_arg_conv.inner = (void*)(this_arg & (~1));
35678         this_arg_conv.is_owned = false;
35679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35680         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
35681         return ret_conv;
35682 }
35683
35684 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
35685         LDKHolderCommitmentTransaction this_obj_conv;
35686         this_obj_conv.inner = (void*)(this_obj & (~1));
35687         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35689         HolderCommitmentTransaction_free(this_obj_conv);
35690 }
35691
35692 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
35693         LDKHolderCommitmentTransaction this_ptr_conv;
35694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35695         this_ptr_conv.is_owned = false;
35696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35697         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
35698         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
35699         return ret_arr;
35700 }
35701
35702 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
35703         LDKHolderCommitmentTransaction this_ptr_conv;
35704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35705         this_ptr_conv.is_owned = false;
35706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35707         LDKSignature val_ref;
35708         CHECK(val->arr_len == 64);
35709         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
35710         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
35711 }
35712
35713 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
35714         LDKHolderCommitmentTransaction this_ptr_conv;
35715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35716         this_ptr_conv.is_owned = false;
35717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35718         LDKCVec_SignatureZ val_constr;
35719         val_constr.datalen = val->arr_len;
35720         if (val_constr.datalen > 0)
35721                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
35722         else
35723                 val_constr.data = NULL;
35724         int8_tArray* val_vals = (void*) val->elems;
35725         for (size_t m = 0; m < val_constr.datalen; m++) {
35726                 int8_tArray val_conv_12 = val_vals[m];
35727                 LDKSignature val_conv_12_ref;
35728                 CHECK(val_conv_12->arr_len == 64);
35729                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
35730                 val_constr.data[m] = val_conv_12_ref;
35731         }
35732         FREE(val);
35733         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
35734 }
35735
35736 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
35737         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
35738 uint32_t ret_ref = 0;
35739 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35740 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35741 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35742 ret_ref = (uintptr_t)ret_var.inner;
35743 if (ret_var.is_owned) {
35744         ret_ref |= 1;
35745 }
35746         return ret_ref;
35747 }
35748 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
35749         LDKHolderCommitmentTransaction arg_conv;
35750         arg_conv.inner = (void*)(arg & (~1));
35751         arg_conv.is_owned = false;
35752         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35753         uint32_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
35754         return ret_conv;
35755 }
35756
35757 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
35758         LDKHolderCommitmentTransaction orig_conv;
35759         orig_conv.inner = (void*)(orig & (~1));
35760         orig_conv.is_owned = false;
35761         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35762         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
35763         uint32_t ret_ref = 0;
35764         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35765         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35767         ret_ref = (uintptr_t)ret_var.inner;
35768         if (ret_var.is_owned) {
35769                 ret_ref |= 1;
35770         }
35771         return ret_ref;
35772 }
35773
35774 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
35775         LDKHolderCommitmentTransaction obj_conv;
35776         obj_conv.inner = (void*)(obj & (~1));
35777         obj_conv.is_owned = false;
35778         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35779         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
35780         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35781         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35782         CVec_u8Z_free(ret_var);
35783         return ret_arr;
35784 }
35785
35786 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
35787         LDKu8slice ser_ref;
35788         ser_ref.datalen = ser->arr_len;
35789         ser_ref.data = ser->elems;
35790         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
35791         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
35792         FREE(ser);
35793         return (uint32_t)ret_conv;
35794 }
35795
35796 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) {
35797         LDKCommitmentTransaction commitment_tx_conv;
35798         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
35799         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
35800         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
35801         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
35802         LDKSignature counterparty_sig_ref;
35803         CHECK(counterparty_sig->arr_len == 64);
35804         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
35805         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
35806         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
35807         if (counterparty_htlc_sigs_constr.datalen > 0)
35808                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
35809         else
35810                 counterparty_htlc_sigs_constr.data = NULL;
35811         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems;
35812         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
35813                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
35814                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
35815                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
35816                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64); FREE(counterparty_htlc_sigs_conv_12);
35817                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
35818         }
35819         FREE(counterparty_htlc_sigs);
35820         LDKPublicKey holder_funding_key_ref;
35821         CHECK(holder_funding_key->arr_len == 33);
35822         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
35823         LDKPublicKey counterparty_funding_key_ref;
35824         CHECK(counterparty_funding_key->arr_len == 33);
35825         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
35826         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
35827         uint32_t ret_ref = 0;
35828         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35829         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35830         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35831         ret_ref = (uintptr_t)ret_var.inner;
35832         if (ret_var.is_owned) {
35833                 ret_ref |= 1;
35834         }
35835         return ret_ref;
35836 }
35837
35838 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
35839         LDKBuiltCommitmentTransaction this_obj_conv;
35840         this_obj_conv.inner = (void*)(this_obj & (~1));
35841         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35843         BuiltCommitmentTransaction_free(this_obj_conv);
35844 }
35845
35846 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
35847         LDKBuiltCommitmentTransaction this_ptr_conv;
35848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35849         this_ptr_conv.is_owned = false;
35850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35851         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
35852         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35853         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35854         Transaction_free(ret_var);
35855         return ret_arr;
35856 }
35857
35858 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
35859         LDKBuiltCommitmentTransaction this_ptr_conv;
35860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35861         this_ptr_conv.is_owned = false;
35862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35863         LDKTransaction val_ref;
35864         val_ref.datalen = val->arr_len;
35865         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
35866         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
35867         val_ref.data_is_owned = true;
35868         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
35869 }
35870
35871 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
35872         LDKBuiltCommitmentTransaction this_ptr_conv;
35873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35874         this_ptr_conv.is_owned = false;
35875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35876         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35877         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
35878         return ret_arr;
35879 }
35880
35881 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
35882         LDKBuiltCommitmentTransaction this_ptr_conv;
35883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35884         this_ptr_conv.is_owned = false;
35885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35886         LDKThirtyTwoBytes val_ref;
35887         CHECK(val->arr_len == 32);
35888         memcpy(val_ref.data, val->elems, 32); FREE(val);
35889         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
35890 }
35891
35892 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
35893         LDKTransaction transaction_arg_ref;
35894         transaction_arg_ref.datalen = transaction_arg->arr_len;
35895         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
35896         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
35897         transaction_arg_ref.data_is_owned = true;
35898         LDKThirtyTwoBytes txid_arg_ref;
35899         CHECK(txid_arg->arr_len == 32);
35900         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
35901         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
35902         uint32_t ret_ref = 0;
35903         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35904         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35906         ret_ref = (uintptr_t)ret_var.inner;
35907         if (ret_var.is_owned) {
35908                 ret_ref |= 1;
35909         }
35910         return ret_ref;
35911 }
35912
35913 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
35914         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
35915 uint32_t ret_ref = 0;
35916 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35917 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35918 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35919 ret_ref = (uintptr_t)ret_var.inner;
35920 if (ret_var.is_owned) {
35921         ret_ref |= 1;
35922 }
35923         return ret_ref;
35924 }
35925 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
35926         LDKBuiltCommitmentTransaction arg_conv;
35927         arg_conv.inner = (void*)(arg & (~1));
35928         arg_conv.is_owned = false;
35929         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35930         uint32_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
35931         return ret_conv;
35932 }
35933
35934 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
35935         LDKBuiltCommitmentTransaction orig_conv;
35936         orig_conv.inner = (void*)(orig & (~1));
35937         orig_conv.is_owned = false;
35938         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35939         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
35940         uint32_t ret_ref = 0;
35941         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35942         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35944         ret_ref = (uintptr_t)ret_var.inner;
35945         if (ret_var.is_owned) {
35946                 ret_ref |= 1;
35947         }
35948         return ret_ref;
35949 }
35950
35951 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
35952         LDKBuiltCommitmentTransaction obj_conv;
35953         obj_conv.inner = (void*)(obj & (~1));
35954         obj_conv.is_owned = false;
35955         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35956         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
35957         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35958         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35959         CVec_u8Z_free(ret_var);
35960         return ret_arr;
35961 }
35962
35963 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
35964         LDKu8slice ser_ref;
35965         ser_ref.datalen = ser->arr_len;
35966         ser_ref.data = ser->elems;
35967         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
35968         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
35969         FREE(ser);
35970         return (uint32_t)ret_conv;
35971 }
35972
35973 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) {
35974         LDKBuiltCommitmentTransaction this_arg_conv;
35975         this_arg_conv.inner = (void*)(this_arg & (~1));
35976         this_arg_conv.is_owned = false;
35977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35978         LDKu8slice funding_redeemscript_ref;
35979         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
35980         funding_redeemscript_ref.data = funding_redeemscript->elems;
35981         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35982         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
35983         FREE(funding_redeemscript);
35984         return ret_arr;
35985 }
35986
35987 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) {
35988         LDKBuiltCommitmentTransaction this_arg_conv;
35989         this_arg_conv.inner = (void*)(this_arg & (~1));
35990         this_arg_conv.is_owned = false;
35991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35992         unsigned char funding_key_arr[32];
35993         CHECK(funding_key->arr_len == 32);
35994         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
35995         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
35996         LDKu8slice funding_redeemscript_ref;
35997         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
35998         funding_redeemscript_ref.data = funding_redeemscript->elems;
35999         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
36000         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
36001         FREE(funding_redeemscript);
36002         return ret_arr;
36003 }
36004
36005 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint32_t this_obj) {
36006         LDKClosingTransaction this_obj_conv;
36007         this_obj_conv.inner = (void*)(this_obj & (~1));
36008         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36010         ClosingTransaction_free(this_obj_conv);
36011 }
36012
36013 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
36014         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
36015 uint32_t ret_ref = 0;
36016 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36017 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36018 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36019 ret_ref = (uintptr_t)ret_var.inner;
36020 if (ret_var.is_owned) {
36021         ret_ref |= 1;
36022 }
36023         return ret_ref;
36024 }
36025 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
36026         LDKClosingTransaction arg_conv;
36027         arg_conv.inner = (void*)(arg & (~1));
36028         arg_conv.is_owned = false;
36029         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36030         uint32_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
36031         return ret_conv;
36032 }
36033
36034 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint32_t orig) {
36035         LDKClosingTransaction orig_conv;
36036         orig_conv.inner = (void*)(orig & (~1));
36037         orig_conv.is_owned = false;
36038         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36039         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
36040         uint32_t ret_ref = 0;
36041         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36042         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36044         ret_ref = (uintptr_t)ret_var.inner;
36045         if (ret_var.is_owned) {
36046                 ret_ref |= 1;
36047         }
36048         return ret_ref;
36049 }
36050
36051 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint32_t o) {
36052         LDKClosingTransaction o_conv;
36053         o_conv.inner = (void*)(o & (~1));
36054         o_conv.is_owned = false;
36055         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36056         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
36057         return ret_conv;
36058 }
36059
36060 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) {
36061         LDKCVec_u8Z to_holder_script_ref;
36062         to_holder_script_ref.datalen = to_holder_script->arr_len;
36063         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
36064         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
36065         LDKCVec_u8Z to_counterparty_script_ref;
36066         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
36067         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
36068         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
36069         LDKOutPoint funding_outpoint_conv;
36070         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
36071         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
36072         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
36073         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
36074         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
36075         uint32_t ret_ref = 0;
36076         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36077         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36079         ret_ref = (uintptr_t)ret_var.inner;
36080         if (ret_var.is_owned) {
36081                 ret_ref |= 1;
36082         }
36083         return ret_ref;
36084 }
36085
36086 uint32_t  __attribute__((export_name("TS_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
36087         LDKClosingTransaction this_arg_conv;
36088         this_arg_conv.inner = (void*)(this_arg & (~1));
36089         this_arg_conv.is_owned = false;
36090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36091         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
36092         uint32_t ret_ref = 0;
36093         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36094         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36096         ret_ref = (uintptr_t)ret_var.inner;
36097         if (ret_var.is_owned) {
36098                 ret_ref |= 1;
36099         }
36100         return ret_ref;
36101 }
36102
36103 uint32_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
36104         LDKClosingTransaction this_arg_conv;
36105         this_arg_conv.inner = (void*)(this_arg & (~1));
36106         this_arg_conv.is_owned = false;
36107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36108         LDKOutPoint funding_outpoint_conv;
36109         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
36110         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
36111         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
36112         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
36113         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
36114         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
36115         return (uint32_t)ret_conv;
36116 }
36117
36118 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
36119         LDKClosingTransaction this_arg_conv;
36120         this_arg_conv.inner = (void*)(this_arg & (~1));
36121         this_arg_conv.is_owned = false;
36122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36123         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
36124         return ret_conv;
36125 }
36126
36127 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
36128         LDKClosingTransaction this_arg_conv;
36129         this_arg_conv.inner = (void*)(this_arg & (~1));
36130         this_arg_conv.is_owned = false;
36131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36132         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
36133         return ret_conv;
36134 }
36135
36136 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
36137         LDKClosingTransaction this_arg_conv;
36138         this_arg_conv.inner = (void*)(this_arg & (~1));
36139         this_arg_conv.is_owned = false;
36140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36141         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
36142         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36143         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36144         return ret_arr;
36145 }
36146
36147 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
36148         LDKClosingTransaction this_arg_conv;
36149         this_arg_conv.inner = (void*)(this_arg & (~1));
36150         this_arg_conv.is_owned = false;
36151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36152         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
36153         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36154         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36155         return ret_arr;
36156 }
36157
36158 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
36159         LDKTrustedClosingTransaction this_obj_conv;
36160         this_obj_conv.inner = (void*)(this_obj & (~1));
36161         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36163         TrustedClosingTransaction_free(this_obj_conv);
36164 }
36165
36166 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
36167         LDKTrustedClosingTransaction this_arg_conv;
36168         this_arg_conv.inner = (void*)(this_arg & (~1));
36169         this_arg_conv.is_owned = false;
36170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36171         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
36172         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36173         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36174         Transaction_free(ret_var);
36175         return ret_arr;
36176 }
36177
36178 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) {
36179         LDKTrustedClosingTransaction this_arg_conv;
36180         this_arg_conv.inner = (void*)(this_arg & (~1));
36181         this_arg_conv.is_owned = false;
36182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36183         LDKu8slice funding_redeemscript_ref;
36184         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
36185         funding_redeemscript_ref.data = funding_redeemscript->elems;
36186         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36187         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
36188         FREE(funding_redeemscript);
36189         return ret_arr;
36190 }
36191
36192 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) {
36193         LDKTrustedClosingTransaction this_arg_conv;
36194         this_arg_conv.inner = (void*)(this_arg & (~1));
36195         this_arg_conv.is_owned = false;
36196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36197         unsigned char funding_key_arr[32];
36198         CHECK(funding_key->arr_len == 32);
36199         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
36200         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
36201         LDKu8slice funding_redeemscript_ref;
36202         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
36203         funding_redeemscript_ref.data = funding_redeemscript->elems;
36204         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
36205         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
36206         FREE(funding_redeemscript);
36207         return ret_arr;
36208 }
36209
36210 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
36211         LDKCommitmentTransaction this_obj_conv;
36212         this_obj_conv.inner = (void*)(this_obj & (~1));
36213         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36215         CommitmentTransaction_free(this_obj_conv);
36216 }
36217
36218 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
36219         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
36220 uint32_t ret_ref = 0;
36221 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36222 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36223 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36224 ret_ref = (uintptr_t)ret_var.inner;
36225 if (ret_var.is_owned) {
36226         ret_ref |= 1;
36227 }
36228         return ret_ref;
36229 }
36230 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
36231         LDKCommitmentTransaction arg_conv;
36232         arg_conv.inner = (void*)(arg & (~1));
36233         arg_conv.is_owned = false;
36234         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36235         uint32_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
36236         return ret_conv;
36237 }
36238
36239 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint32_t orig) {
36240         LDKCommitmentTransaction orig_conv;
36241         orig_conv.inner = (void*)(orig & (~1));
36242         orig_conv.is_owned = false;
36243         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36244         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
36245         uint32_t ret_ref = 0;
36246         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36247         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36249         ret_ref = (uintptr_t)ret_var.inner;
36250         if (ret_var.is_owned) {
36251                 ret_ref |= 1;
36252         }
36253         return ret_ref;
36254 }
36255
36256 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint32_t obj) {
36257         LDKCommitmentTransaction obj_conv;
36258         obj_conv.inner = (void*)(obj & (~1));
36259         obj_conv.is_owned = false;
36260         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36261         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
36262         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36263         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36264         CVec_u8Z_free(ret_var);
36265         return ret_arr;
36266 }
36267
36268 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
36269         LDKu8slice ser_ref;
36270         ser_ref.datalen = ser->arr_len;
36271         ser_ref.data = ser->elems;
36272         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
36273         *ret_conv = CommitmentTransaction_read(ser_ref);
36274         FREE(ser);
36275         return (uint32_t)ret_conv;
36276 }
36277
36278 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
36279         LDKCommitmentTransaction this_arg_conv;
36280         this_arg_conv.inner = (void*)(this_arg & (~1));
36281         this_arg_conv.is_owned = false;
36282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36283         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
36284         return ret_conv;
36285 }
36286
36287 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
36288         LDKCommitmentTransaction this_arg_conv;
36289         this_arg_conv.inner = (void*)(this_arg & (~1));
36290         this_arg_conv.is_owned = false;
36291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36292         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
36293         return ret_conv;
36294 }
36295
36296 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
36297         LDKCommitmentTransaction this_arg_conv;
36298         this_arg_conv.inner = (void*)(this_arg & (~1));
36299         this_arg_conv.is_owned = false;
36300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36301         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
36302         return ret_conv;
36303 }
36304
36305 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
36306         LDKCommitmentTransaction this_arg_conv;
36307         this_arg_conv.inner = (void*)(this_arg & (~1));
36308         this_arg_conv.is_owned = false;
36309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36310         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
36311         return ret_conv;
36312 }
36313
36314 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
36315         LDKCommitmentTransaction this_arg_conv;
36316         this_arg_conv.inner = (void*)(this_arg & (~1));
36317         this_arg_conv.is_owned = false;
36318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36319         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
36320         uint32_t ret_ref = 0;
36321         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36322         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36324         ret_ref = (uintptr_t)ret_var.inner;
36325         if (ret_var.is_owned) {
36326                 ret_ref |= 1;
36327         }
36328         return ret_ref;
36329 }
36330
36331 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) {
36332         LDKCommitmentTransaction this_arg_conv;
36333         this_arg_conv.inner = (void*)(this_arg & (~1));
36334         this_arg_conv.is_owned = false;
36335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36336         LDKDirectedChannelTransactionParameters channel_parameters_conv;
36337         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
36338         channel_parameters_conv.is_owned = false;
36339         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
36340         LDKChannelPublicKeys broadcaster_keys_conv;
36341         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
36342         broadcaster_keys_conv.is_owned = false;
36343         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
36344         LDKChannelPublicKeys countersignatory_keys_conv;
36345         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
36346         countersignatory_keys_conv.is_owned = false;
36347         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
36348         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
36349         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
36350         return (uint32_t)ret_conv;
36351 }
36352
36353 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
36354         LDKTrustedCommitmentTransaction this_obj_conv;
36355         this_obj_conv.inner = (void*)(this_obj & (~1));
36356         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36358         TrustedCommitmentTransaction_free(this_obj_conv);
36359 }
36360
36361 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
36362         LDKTrustedCommitmentTransaction this_arg_conv;
36363         this_arg_conv.inner = (void*)(this_arg & (~1));
36364         this_arg_conv.is_owned = false;
36365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36366         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36367         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
36368         return ret_arr;
36369 }
36370
36371 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
36372         LDKTrustedCommitmentTransaction this_arg_conv;
36373         this_arg_conv.inner = (void*)(this_arg & (~1));
36374         this_arg_conv.is_owned = false;
36375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36376         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
36377         uint32_t ret_ref = 0;
36378         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36379         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36381         ret_ref = (uintptr_t)ret_var.inner;
36382         if (ret_var.is_owned) {
36383                 ret_ref |= 1;
36384         }
36385         return ret_ref;
36386 }
36387
36388 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
36389         LDKTrustedCommitmentTransaction this_arg_conv;
36390         this_arg_conv.inner = (void*)(this_arg & (~1));
36391         this_arg_conv.is_owned = false;
36392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36393         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
36394         uint32_t ret_ref = 0;
36395         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36396         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36398         ret_ref = (uintptr_t)ret_var.inner;
36399         if (ret_var.is_owned) {
36400                 ret_ref |= 1;
36401         }
36402         return ret_ref;
36403 }
36404
36405 jboolean  __attribute__((export_name("TS_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
36406         LDKTrustedCommitmentTransaction this_arg_conv;
36407         this_arg_conv.inner = (void*)(this_arg & (~1));
36408         this_arg_conv.is_owned = false;
36409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36410         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
36411         return ret_conv;
36412 }
36413
36414 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) {
36415         LDKTrustedCommitmentTransaction this_arg_conv;
36416         this_arg_conv.inner = (void*)(this_arg & (~1));
36417         this_arg_conv.is_owned = false;
36418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36419         unsigned char htlc_base_key_arr[32];
36420         CHECK(htlc_base_key->arr_len == 32);
36421         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
36422         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
36423         LDKDirectedChannelTransactionParameters channel_parameters_conv;
36424         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
36425         channel_parameters_conv.is_owned = false;
36426         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
36427         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
36428         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
36429         return (uint32_t)ret_conv;
36430 }
36431
36432 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) {
36433         LDKPublicKey broadcaster_payment_basepoint_ref;
36434         CHECK(broadcaster_payment_basepoint->arr_len == 33);
36435         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
36436         LDKPublicKey countersignatory_payment_basepoint_ref;
36437         CHECK(countersignatory_payment_basepoint->arr_len == 33);
36438         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
36439         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
36440         return ret_conv;
36441 }
36442
36443 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
36444         LDKInitFeatures a_conv;
36445         a_conv.inner = (void*)(a & (~1));
36446         a_conv.is_owned = false;
36447         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36448         LDKInitFeatures b_conv;
36449         b_conv.inner = (void*)(b & (~1));
36450         b_conv.is_owned = false;
36451         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36452         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
36453         return ret_conv;
36454 }
36455
36456 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
36457         LDKNodeFeatures a_conv;
36458         a_conv.inner = (void*)(a & (~1));
36459         a_conv.is_owned = false;
36460         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36461         LDKNodeFeatures b_conv;
36462         b_conv.inner = (void*)(b & (~1));
36463         b_conv.is_owned = false;
36464         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36465         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
36466         return ret_conv;
36467 }
36468
36469 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
36470         LDKChannelFeatures a_conv;
36471         a_conv.inner = (void*)(a & (~1));
36472         a_conv.is_owned = false;
36473         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36474         LDKChannelFeatures b_conv;
36475         b_conv.inner = (void*)(b & (~1));
36476         b_conv.is_owned = false;
36477         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36478         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
36479         return ret_conv;
36480 }
36481
36482 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
36483         LDKInvoiceFeatures a_conv;
36484         a_conv.inner = (void*)(a & (~1));
36485         a_conv.is_owned = false;
36486         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36487         LDKInvoiceFeatures b_conv;
36488         b_conv.inner = (void*)(b & (~1));
36489         b_conv.is_owned = false;
36490         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36491         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
36492         return ret_conv;
36493 }
36494
36495 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
36496         LDKChannelTypeFeatures a_conv;
36497         a_conv.inner = (void*)(a & (~1));
36498         a_conv.is_owned = false;
36499         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36500         LDKChannelTypeFeatures b_conv;
36501         b_conv.inner = (void*)(b & (~1));
36502         b_conv.is_owned = false;
36503         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36504         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
36505         return ret_conv;
36506 }
36507
36508 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
36509         LDKInitFeatures ret_var = InitFeatures_clone(arg);
36510 uint32_t ret_ref = 0;
36511 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36512 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36513 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36514 ret_ref = (uintptr_t)ret_var.inner;
36515 if (ret_var.is_owned) {
36516         ret_ref |= 1;
36517 }
36518         return ret_ref;
36519 }
36520 uint32_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
36521         LDKInitFeatures arg_conv;
36522         arg_conv.inner = (void*)(arg & (~1));
36523         arg_conv.is_owned = false;
36524         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36525         uint32_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
36526         return ret_conv;
36527 }
36528
36529 uint32_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint32_t orig) {
36530         LDKInitFeatures orig_conv;
36531         orig_conv.inner = (void*)(orig & (~1));
36532         orig_conv.is_owned = false;
36533         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36534         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
36535         uint32_t ret_ref = 0;
36536         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36537         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36539         ret_ref = (uintptr_t)ret_var.inner;
36540         if (ret_var.is_owned) {
36541                 ret_ref |= 1;
36542         }
36543         return ret_ref;
36544 }
36545
36546 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
36547         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
36548 uint32_t ret_ref = 0;
36549 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36550 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36551 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36552 ret_ref = (uintptr_t)ret_var.inner;
36553 if (ret_var.is_owned) {
36554         ret_ref |= 1;
36555 }
36556         return ret_ref;
36557 }
36558 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
36559         LDKNodeFeatures arg_conv;
36560         arg_conv.inner = (void*)(arg & (~1));
36561         arg_conv.is_owned = false;
36562         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36563         uint32_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
36564         return ret_conv;
36565 }
36566
36567 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint32_t orig) {
36568         LDKNodeFeatures orig_conv;
36569         orig_conv.inner = (void*)(orig & (~1));
36570         orig_conv.is_owned = false;
36571         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36572         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
36573         uint32_t ret_ref = 0;
36574         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36575         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36577         ret_ref = (uintptr_t)ret_var.inner;
36578         if (ret_var.is_owned) {
36579                 ret_ref |= 1;
36580         }
36581         return ret_ref;
36582 }
36583
36584 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
36585         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
36586 uint32_t ret_ref = 0;
36587 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36588 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36589 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36590 ret_ref = (uintptr_t)ret_var.inner;
36591 if (ret_var.is_owned) {
36592         ret_ref |= 1;
36593 }
36594         return ret_ref;
36595 }
36596 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
36597         LDKChannelFeatures arg_conv;
36598         arg_conv.inner = (void*)(arg & (~1));
36599         arg_conv.is_owned = false;
36600         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36601         uint32_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
36602         return ret_conv;
36603 }
36604
36605 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint32_t orig) {
36606         LDKChannelFeatures orig_conv;
36607         orig_conv.inner = (void*)(orig & (~1));
36608         orig_conv.is_owned = false;
36609         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36610         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
36611         uint32_t ret_ref = 0;
36612         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36613         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36615         ret_ref = (uintptr_t)ret_var.inner;
36616         if (ret_var.is_owned) {
36617                 ret_ref |= 1;
36618         }
36619         return ret_ref;
36620 }
36621
36622 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
36623         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
36624 uint32_t ret_ref = 0;
36625 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36626 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36627 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36628 ret_ref = (uintptr_t)ret_var.inner;
36629 if (ret_var.is_owned) {
36630         ret_ref |= 1;
36631 }
36632         return ret_ref;
36633 }
36634 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
36635         LDKInvoiceFeatures arg_conv;
36636         arg_conv.inner = (void*)(arg & (~1));
36637         arg_conv.is_owned = false;
36638         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36639         uint32_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
36640         return ret_conv;
36641 }
36642
36643 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint32_t orig) {
36644         LDKInvoiceFeatures orig_conv;
36645         orig_conv.inner = (void*)(orig & (~1));
36646         orig_conv.is_owned = false;
36647         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36648         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
36649         uint32_t ret_ref = 0;
36650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36653         ret_ref = (uintptr_t)ret_var.inner;
36654         if (ret_var.is_owned) {
36655                 ret_ref |= 1;
36656         }
36657         return ret_ref;
36658 }
36659
36660 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
36661         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
36662 uint32_t ret_ref = 0;
36663 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36664 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36665 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36666 ret_ref = (uintptr_t)ret_var.inner;
36667 if (ret_var.is_owned) {
36668         ret_ref |= 1;
36669 }
36670         return ret_ref;
36671 }
36672 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
36673         LDKChannelTypeFeatures arg_conv;
36674         arg_conv.inner = (void*)(arg & (~1));
36675         arg_conv.is_owned = false;
36676         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36677         uint32_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
36678         return ret_conv;
36679 }
36680
36681 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
36682         LDKChannelTypeFeatures orig_conv;
36683         orig_conv.inner = (void*)(orig & (~1));
36684         orig_conv.is_owned = false;
36685         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36686         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
36687         uint32_t ret_ref = 0;
36688         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36689         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36691         ret_ref = (uintptr_t)ret_var.inner;
36692         if (ret_var.is_owned) {
36693                 ret_ref |= 1;
36694         }
36695         return ret_ref;
36696 }
36697
36698 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint32_t this_obj) {
36699         LDKInitFeatures this_obj_conv;
36700         this_obj_conv.inner = (void*)(this_obj & (~1));
36701         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36703         InitFeatures_free(this_obj_conv);
36704 }
36705
36706 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint32_t this_obj) {
36707         LDKNodeFeatures this_obj_conv;
36708         this_obj_conv.inner = (void*)(this_obj & (~1));
36709         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36711         NodeFeatures_free(this_obj_conv);
36712 }
36713
36714 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint32_t this_obj) {
36715         LDKChannelFeatures this_obj_conv;
36716         this_obj_conv.inner = (void*)(this_obj & (~1));
36717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36719         ChannelFeatures_free(this_obj_conv);
36720 }
36721
36722 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
36723         LDKInvoiceFeatures this_obj_conv;
36724         this_obj_conv.inner = (void*)(this_obj & (~1));
36725         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36727         InvoiceFeatures_free(this_obj_conv);
36728 }
36729
36730 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
36731         LDKChannelTypeFeatures this_obj_conv;
36732         this_obj_conv.inner = (void*)(this_obj & (~1));
36733         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36735         ChannelTypeFeatures_free(this_obj_conv);
36736 }
36737
36738 uint32_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
36739         LDKInitFeatures ret_var = InitFeatures_empty();
36740         uint32_t ret_ref = 0;
36741         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36742         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36744         ret_ref = (uintptr_t)ret_var.inner;
36745         if (ret_var.is_owned) {
36746                 ret_ref |= 1;
36747         }
36748         return ret_ref;
36749 }
36750
36751 uint32_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
36752         LDKInitFeatures ret_var = InitFeatures_known();
36753         uint32_t ret_ref = 0;
36754         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36755         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36757         ret_ref = (uintptr_t)ret_var.inner;
36758         if (ret_var.is_owned) {
36759                 ret_ref |= 1;
36760         }
36761         return ret_ref;
36762 }
36763
36764 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
36765         LDKInitFeatures this_arg_conv;
36766         this_arg_conv.inner = (void*)(this_arg & (~1));
36767         this_arg_conv.is_owned = false;
36768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36769         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
36770         return ret_conv;
36771 }
36772
36773 uint32_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
36774         LDKNodeFeatures ret_var = NodeFeatures_empty();
36775         uint32_t ret_ref = 0;
36776         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36777         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36779         ret_ref = (uintptr_t)ret_var.inner;
36780         if (ret_var.is_owned) {
36781                 ret_ref |= 1;
36782         }
36783         return ret_ref;
36784 }
36785
36786 uint32_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
36787         LDKNodeFeatures ret_var = NodeFeatures_known();
36788         uint32_t ret_ref = 0;
36789         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36790         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36792         ret_ref = (uintptr_t)ret_var.inner;
36793         if (ret_var.is_owned) {
36794                 ret_ref |= 1;
36795         }
36796         return ret_ref;
36797 }
36798
36799 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
36800         LDKNodeFeatures this_arg_conv;
36801         this_arg_conv.inner = (void*)(this_arg & (~1));
36802         this_arg_conv.is_owned = false;
36803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36804         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
36805         return ret_conv;
36806 }
36807
36808 uint32_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
36809         LDKChannelFeatures ret_var = ChannelFeatures_empty();
36810         uint32_t ret_ref = 0;
36811         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36812         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36814         ret_ref = (uintptr_t)ret_var.inner;
36815         if (ret_var.is_owned) {
36816                 ret_ref |= 1;
36817         }
36818         return ret_ref;
36819 }
36820
36821 uint32_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
36822         LDKChannelFeatures ret_var = ChannelFeatures_known();
36823         uint32_t ret_ref = 0;
36824         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36825         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36827         ret_ref = (uintptr_t)ret_var.inner;
36828         if (ret_var.is_owned) {
36829                 ret_ref |= 1;
36830         }
36831         return ret_ref;
36832 }
36833
36834 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
36835         LDKChannelFeatures this_arg_conv;
36836         this_arg_conv.inner = (void*)(this_arg & (~1));
36837         this_arg_conv.is_owned = false;
36838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36839         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
36840         return ret_conv;
36841 }
36842
36843 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
36844         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
36845         uint32_t ret_ref = 0;
36846         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36847         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36849         ret_ref = (uintptr_t)ret_var.inner;
36850         if (ret_var.is_owned) {
36851                 ret_ref |= 1;
36852         }
36853         return ret_ref;
36854 }
36855
36856 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
36857         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
36858         uint32_t ret_ref = 0;
36859         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36860         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36862         ret_ref = (uintptr_t)ret_var.inner;
36863         if (ret_var.is_owned) {
36864                 ret_ref |= 1;
36865         }
36866         return ret_ref;
36867 }
36868
36869 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
36870         LDKInvoiceFeatures this_arg_conv;
36871         this_arg_conv.inner = (void*)(this_arg & (~1));
36872         this_arg_conv.is_owned = false;
36873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36874         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
36875         return ret_conv;
36876 }
36877
36878 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
36879         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
36880         uint32_t ret_ref = 0;
36881         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36882         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36884         ret_ref = (uintptr_t)ret_var.inner;
36885         if (ret_var.is_owned) {
36886                 ret_ref |= 1;
36887         }
36888         return ret_ref;
36889 }
36890
36891 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
36892         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
36893         uint32_t ret_ref = 0;
36894         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36895         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36897         ret_ref = (uintptr_t)ret_var.inner;
36898         if (ret_var.is_owned) {
36899                 ret_ref |= 1;
36900         }
36901         return ret_ref;
36902 }
36903
36904 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
36905         LDKChannelTypeFeatures this_arg_conv;
36906         this_arg_conv.inner = (void*)(this_arg & (~1));
36907         this_arg_conv.is_owned = false;
36908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36909         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
36910         return ret_conv;
36911 }
36912
36913 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint32_t obj) {
36914         LDKInitFeatures obj_conv;
36915         obj_conv.inner = (void*)(obj & (~1));
36916         obj_conv.is_owned = false;
36917         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36918         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
36919         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36920         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36921         CVec_u8Z_free(ret_var);
36922         return ret_arr;
36923 }
36924
36925 uint32_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
36926         LDKu8slice ser_ref;
36927         ser_ref.datalen = ser->arr_len;
36928         ser_ref.data = ser->elems;
36929         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
36930         *ret_conv = InitFeatures_read(ser_ref);
36931         FREE(ser);
36932         return (uint32_t)ret_conv;
36933 }
36934
36935 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint32_t obj) {
36936         LDKChannelFeatures obj_conv;
36937         obj_conv.inner = (void*)(obj & (~1));
36938         obj_conv.is_owned = false;
36939         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36940         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
36941         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36942         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36943         CVec_u8Z_free(ret_var);
36944         return ret_arr;
36945 }
36946
36947 uint32_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
36948         LDKu8slice ser_ref;
36949         ser_ref.datalen = ser->arr_len;
36950         ser_ref.data = ser->elems;
36951         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
36952         *ret_conv = ChannelFeatures_read(ser_ref);
36953         FREE(ser);
36954         return (uint32_t)ret_conv;
36955 }
36956
36957 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint32_t obj) {
36958         LDKNodeFeatures obj_conv;
36959         obj_conv.inner = (void*)(obj & (~1));
36960         obj_conv.is_owned = false;
36961         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36962         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
36963         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36964         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36965         CVec_u8Z_free(ret_var);
36966         return ret_arr;
36967 }
36968
36969 uint32_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
36970         LDKu8slice ser_ref;
36971         ser_ref.datalen = ser->arr_len;
36972         ser_ref.data = ser->elems;
36973         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
36974         *ret_conv = NodeFeatures_read(ser_ref);
36975         FREE(ser);
36976         return (uint32_t)ret_conv;
36977 }
36978
36979 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint32_t obj) {
36980         LDKInvoiceFeatures obj_conv;
36981         obj_conv.inner = (void*)(obj & (~1));
36982         obj_conv.is_owned = false;
36983         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36984         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
36985         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36986         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36987         CVec_u8Z_free(ret_var);
36988         return ret_arr;
36989 }
36990
36991 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_read"))) TS_InvoiceFeatures_read(int8_tArray ser) {
36992         LDKu8slice ser_ref;
36993         ser_ref.datalen = ser->arr_len;
36994         ser_ref.data = ser->elems;
36995         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
36996         *ret_conv = InvoiceFeatures_read(ser_ref);
36997         FREE(ser);
36998         return (uint32_t)ret_conv;
36999 }
37000
37001 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
37002         LDKChannelTypeFeatures obj_conv;
37003         obj_conv.inner = (void*)(obj & (~1));
37004         obj_conv.is_owned = false;
37005         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37006         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
37007         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37008         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37009         CVec_u8Z_free(ret_var);
37010         return ret_arr;
37011 }
37012
37013 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
37014         LDKu8slice ser_ref;
37015         ser_ref.datalen = ser->arr_len;
37016         ser_ref.data = ser->elems;
37017         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
37018         *ret_conv = ChannelTypeFeatures_read(ser_ref);
37019         FREE(ser);
37020         return (uint32_t)ret_conv;
37021 }
37022
37023 void  __attribute__((export_name("TS_InitFeatures_set_data_loss_protect_optional"))) TS_InitFeatures_set_data_loss_protect_optional(uint32_t this_arg) {
37024         LDKInitFeatures this_arg_conv;
37025         this_arg_conv.inner = (void*)(this_arg & (~1));
37026         this_arg_conv.is_owned = false;
37027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37028         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
37029 }
37030
37031 void  __attribute__((export_name("TS_InitFeatures_set_data_loss_protect_required"))) TS_InitFeatures_set_data_loss_protect_required(uint32_t this_arg) {
37032         LDKInitFeatures this_arg_conv;
37033         this_arg_conv.inner = (void*)(this_arg & (~1));
37034         this_arg_conv.is_owned = false;
37035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37036         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
37037 }
37038
37039 jboolean  __attribute__((export_name("TS_InitFeatures_supports_data_loss_protect"))) TS_InitFeatures_supports_data_loss_protect(uint32_t this_arg) {
37040         LDKInitFeatures this_arg_conv;
37041         this_arg_conv.inner = (void*)(this_arg & (~1));
37042         this_arg_conv.is_owned = false;
37043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37044         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
37045         return ret_conv;
37046 }
37047
37048 void  __attribute__((export_name("TS_NodeFeatures_set_data_loss_protect_optional"))) TS_NodeFeatures_set_data_loss_protect_optional(uint32_t this_arg) {
37049         LDKNodeFeatures this_arg_conv;
37050         this_arg_conv.inner = (void*)(this_arg & (~1));
37051         this_arg_conv.is_owned = false;
37052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37053         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
37054 }
37055
37056 void  __attribute__((export_name("TS_NodeFeatures_set_data_loss_protect_required"))) TS_NodeFeatures_set_data_loss_protect_required(uint32_t this_arg) {
37057         LDKNodeFeatures this_arg_conv;
37058         this_arg_conv.inner = (void*)(this_arg & (~1));
37059         this_arg_conv.is_owned = false;
37060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37061         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
37062 }
37063
37064 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_data_loss_protect"))) TS_NodeFeatures_supports_data_loss_protect(uint32_t this_arg) {
37065         LDKNodeFeatures this_arg_conv;
37066         this_arg_conv.inner = (void*)(this_arg & (~1));
37067         this_arg_conv.is_owned = false;
37068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37069         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
37070         return ret_conv;
37071 }
37072
37073 jboolean  __attribute__((export_name("TS_InitFeatures_requires_data_loss_protect"))) TS_InitFeatures_requires_data_loss_protect(uint32_t this_arg) {
37074         LDKInitFeatures this_arg_conv;
37075         this_arg_conv.inner = (void*)(this_arg & (~1));
37076         this_arg_conv.is_owned = false;
37077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37078         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
37079         return ret_conv;
37080 }
37081
37082 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_data_loss_protect"))) TS_NodeFeatures_requires_data_loss_protect(uint32_t this_arg) {
37083         LDKNodeFeatures this_arg_conv;
37084         this_arg_conv.inner = (void*)(this_arg & (~1));
37085         this_arg_conv.is_owned = false;
37086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37087         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
37088         return ret_conv;
37089 }
37090
37091 void  __attribute__((export_name("TS_InitFeatures_set_initial_routing_sync_optional"))) TS_InitFeatures_set_initial_routing_sync_optional(uint32_t this_arg) {
37092         LDKInitFeatures this_arg_conv;
37093         this_arg_conv.inner = (void*)(this_arg & (~1));
37094         this_arg_conv.is_owned = false;
37095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37096         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
37097 }
37098
37099 void  __attribute__((export_name("TS_InitFeatures_set_initial_routing_sync_required"))) TS_InitFeatures_set_initial_routing_sync_required(uint32_t this_arg) {
37100         LDKInitFeatures this_arg_conv;
37101         this_arg_conv.inner = (void*)(this_arg & (~1));
37102         this_arg_conv.is_owned = false;
37103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37104         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
37105 }
37106
37107 jboolean  __attribute__((export_name("TS_InitFeatures_initial_routing_sync"))) TS_InitFeatures_initial_routing_sync(uint32_t this_arg) {
37108         LDKInitFeatures this_arg_conv;
37109         this_arg_conv.inner = (void*)(this_arg & (~1));
37110         this_arg_conv.is_owned = false;
37111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37112         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
37113         return ret_conv;
37114 }
37115
37116 void  __attribute__((export_name("TS_InitFeatures_set_upfront_shutdown_script_optional"))) TS_InitFeatures_set_upfront_shutdown_script_optional(uint32_t this_arg) {
37117         LDKInitFeatures this_arg_conv;
37118         this_arg_conv.inner = (void*)(this_arg & (~1));
37119         this_arg_conv.is_owned = false;
37120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37121         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
37122 }
37123
37124 void  __attribute__((export_name("TS_InitFeatures_set_upfront_shutdown_script_required"))) TS_InitFeatures_set_upfront_shutdown_script_required(uint32_t this_arg) {
37125         LDKInitFeatures this_arg_conv;
37126         this_arg_conv.inner = (void*)(this_arg & (~1));
37127         this_arg_conv.is_owned = false;
37128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37129         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
37130 }
37131
37132 jboolean  __attribute__((export_name("TS_InitFeatures_supports_upfront_shutdown_script"))) TS_InitFeatures_supports_upfront_shutdown_script(uint32_t this_arg) {
37133         LDKInitFeatures this_arg_conv;
37134         this_arg_conv.inner = (void*)(this_arg & (~1));
37135         this_arg_conv.is_owned = false;
37136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37137         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
37138         return ret_conv;
37139 }
37140
37141 void  __attribute__((export_name("TS_NodeFeatures_set_upfront_shutdown_script_optional"))) TS_NodeFeatures_set_upfront_shutdown_script_optional(uint32_t this_arg) {
37142         LDKNodeFeatures this_arg_conv;
37143         this_arg_conv.inner = (void*)(this_arg & (~1));
37144         this_arg_conv.is_owned = false;
37145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37146         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
37147 }
37148
37149 void  __attribute__((export_name("TS_NodeFeatures_set_upfront_shutdown_script_required"))) TS_NodeFeatures_set_upfront_shutdown_script_required(uint32_t this_arg) {
37150         LDKNodeFeatures this_arg_conv;
37151         this_arg_conv.inner = (void*)(this_arg & (~1));
37152         this_arg_conv.is_owned = false;
37153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37154         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
37155 }
37156
37157 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_upfront_shutdown_script"))) TS_NodeFeatures_supports_upfront_shutdown_script(uint32_t this_arg) {
37158         LDKNodeFeatures this_arg_conv;
37159         this_arg_conv.inner = (void*)(this_arg & (~1));
37160         this_arg_conv.is_owned = false;
37161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37162         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
37163         return ret_conv;
37164 }
37165
37166 jboolean  __attribute__((export_name("TS_InitFeatures_requires_upfront_shutdown_script"))) TS_InitFeatures_requires_upfront_shutdown_script(uint32_t this_arg) {
37167         LDKInitFeatures this_arg_conv;
37168         this_arg_conv.inner = (void*)(this_arg & (~1));
37169         this_arg_conv.is_owned = false;
37170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37171         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
37172         return ret_conv;
37173 }
37174
37175 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_upfront_shutdown_script"))) TS_NodeFeatures_requires_upfront_shutdown_script(uint32_t this_arg) {
37176         LDKNodeFeatures this_arg_conv;
37177         this_arg_conv.inner = (void*)(this_arg & (~1));
37178         this_arg_conv.is_owned = false;
37179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37180         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
37181         return ret_conv;
37182 }
37183
37184 void  __attribute__((export_name("TS_InitFeatures_set_gossip_queries_optional"))) TS_InitFeatures_set_gossip_queries_optional(uint32_t this_arg) {
37185         LDKInitFeatures this_arg_conv;
37186         this_arg_conv.inner = (void*)(this_arg & (~1));
37187         this_arg_conv.is_owned = false;
37188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37189         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
37190 }
37191
37192 void  __attribute__((export_name("TS_InitFeatures_set_gossip_queries_required"))) TS_InitFeatures_set_gossip_queries_required(uint32_t this_arg) {
37193         LDKInitFeatures this_arg_conv;
37194         this_arg_conv.inner = (void*)(this_arg & (~1));
37195         this_arg_conv.is_owned = false;
37196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37197         InitFeatures_set_gossip_queries_required(&this_arg_conv);
37198 }
37199
37200 jboolean  __attribute__((export_name("TS_InitFeatures_supports_gossip_queries"))) TS_InitFeatures_supports_gossip_queries(uint32_t this_arg) {
37201         LDKInitFeatures this_arg_conv;
37202         this_arg_conv.inner = (void*)(this_arg & (~1));
37203         this_arg_conv.is_owned = false;
37204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37205         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
37206         return ret_conv;
37207 }
37208
37209 void  __attribute__((export_name("TS_NodeFeatures_set_gossip_queries_optional"))) TS_NodeFeatures_set_gossip_queries_optional(uint32_t this_arg) {
37210         LDKNodeFeatures this_arg_conv;
37211         this_arg_conv.inner = (void*)(this_arg & (~1));
37212         this_arg_conv.is_owned = false;
37213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37214         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
37215 }
37216
37217 void  __attribute__((export_name("TS_NodeFeatures_set_gossip_queries_required"))) TS_NodeFeatures_set_gossip_queries_required(uint32_t this_arg) {
37218         LDKNodeFeatures this_arg_conv;
37219         this_arg_conv.inner = (void*)(this_arg & (~1));
37220         this_arg_conv.is_owned = false;
37221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37222         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
37223 }
37224
37225 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_gossip_queries"))) TS_NodeFeatures_supports_gossip_queries(uint32_t this_arg) {
37226         LDKNodeFeatures this_arg_conv;
37227         this_arg_conv.inner = (void*)(this_arg & (~1));
37228         this_arg_conv.is_owned = false;
37229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37230         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
37231         return ret_conv;
37232 }
37233
37234 jboolean  __attribute__((export_name("TS_InitFeatures_requires_gossip_queries"))) TS_InitFeatures_requires_gossip_queries(uint32_t this_arg) {
37235         LDKInitFeatures this_arg_conv;
37236         this_arg_conv.inner = (void*)(this_arg & (~1));
37237         this_arg_conv.is_owned = false;
37238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37239         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
37240         return ret_conv;
37241 }
37242
37243 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_gossip_queries"))) TS_NodeFeatures_requires_gossip_queries(uint32_t this_arg) {
37244         LDKNodeFeatures this_arg_conv;
37245         this_arg_conv.inner = (void*)(this_arg & (~1));
37246         this_arg_conv.is_owned = false;
37247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37248         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
37249         return ret_conv;
37250 }
37251
37252 void  __attribute__((export_name("TS_InitFeatures_set_variable_length_onion_optional"))) TS_InitFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
37253         LDKInitFeatures this_arg_conv;
37254         this_arg_conv.inner = (void*)(this_arg & (~1));
37255         this_arg_conv.is_owned = false;
37256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37257         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
37258 }
37259
37260 void  __attribute__((export_name("TS_InitFeatures_set_variable_length_onion_required"))) TS_InitFeatures_set_variable_length_onion_required(uint32_t this_arg) {
37261         LDKInitFeatures this_arg_conv;
37262         this_arg_conv.inner = (void*)(this_arg & (~1));
37263         this_arg_conv.is_owned = false;
37264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37265         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
37266 }
37267
37268 jboolean  __attribute__((export_name("TS_InitFeatures_supports_variable_length_onion"))) TS_InitFeatures_supports_variable_length_onion(uint32_t this_arg) {
37269         LDKInitFeatures this_arg_conv;
37270         this_arg_conv.inner = (void*)(this_arg & (~1));
37271         this_arg_conv.is_owned = false;
37272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37273         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
37274         return ret_conv;
37275 }
37276
37277 void  __attribute__((export_name("TS_NodeFeatures_set_variable_length_onion_optional"))) TS_NodeFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
37278         LDKNodeFeatures this_arg_conv;
37279         this_arg_conv.inner = (void*)(this_arg & (~1));
37280         this_arg_conv.is_owned = false;
37281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37282         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
37283 }
37284
37285 void  __attribute__((export_name("TS_NodeFeatures_set_variable_length_onion_required"))) TS_NodeFeatures_set_variable_length_onion_required(uint32_t this_arg) {
37286         LDKNodeFeatures this_arg_conv;
37287         this_arg_conv.inner = (void*)(this_arg & (~1));
37288         this_arg_conv.is_owned = false;
37289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37290         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
37291 }
37292
37293 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_variable_length_onion"))) TS_NodeFeatures_supports_variable_length_onion(uint32_t this_arg) {
37294         LDKNodeFeatures this_arg_conv;
37295         this_arg_conv.inner = (void*)(this_arg & (~1));
37296         this_arg_conv.is_owned = false;
37297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37298         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
37299         return ret_conv;
37300 }
37301
37302 void  __attribute__((export_name("TS_InvoiceFeatures_set_variable_length_onion_optional"))) TS_InvoiceFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
37303         LDKInvoiceFeatures this_arg_conv;
37304         this_arg_conv.inner = (void*)(this_arg & (~1));
37305         this_arg_conv.is_owned = false;
37306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37307         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
37308 }
37309
37310 void  __attribute__((export_name("TS_InvoiceFeatures_set_variable_length_onion_required"))) TS_InvoiceFeatures_set_variable_length_onion_required(uint32_t this_arg) {
37311         LDKInvoiceFeatures this_arg_conv;
37312         this_arg_conv.inner = (void*)(this_arg & (~1));
37313         this_arg_conv.is_owned = false;
37314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37315         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
37316 }
37317
37318 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_variable_length_onion"))) TS_InvoiceFeatures_supports_variable_length_onion(uint32_t this_arg) {
37319         LDKInvoiceFeatures this_arg_conv;
37320         this_arg_conv.inner = (void*)(this_arg & (~1));
37321         this_arg_conv.is_owned = false;
37322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37323         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
37324         return ret_conv;
37325 }
37326
37327 jboolean  __attribute__((export_name("TS_InitFeatures_requires_variable_length_onion"))) TS_InitFeatures_requires_variable_length_onion(uint32_t this_arg) {
37328         LDKInitFeatures this_arg_conv;
37329         this_arg_conv.inner = (void*)(this_arg & (~1));
37330         this_arg_conv.is_owned = false;
37331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37332         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
37333         return ret_conv;
37334 }
37335
37336 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_variable_length_onion"))) TS_NodeFeatures_requires_variable_length_onion(uint32_t this_arg) {
37337         LDKNodeFeatures this_arg_conv;
37338         this_arg_conv.inner = (void*)(this_arg & (~1));
37339         this_arg_conv.is_owned = false;
37340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37341         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
37342         return ret_conv;
37343 }
37344
37345 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_variable_length_onion"))) TS_InvoiceFeatures_requires_variable_length_onion(uint32_t this_arg) {
37346         LDKInvoiceFeatures this_arg_conv;
37347         this_arg_conv.inner = (void*)(this_arg & (~1));
37348         this_arg_conv.is_owned = false;
37349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37350         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
37351         return ret_conv;
37352 }
37353
37354 void  __attribute__((export_name("TS_InitFeatures_set_static_remote_key_optional"))) TS_InitFeatures_set_static_remote_key_optional(uint32_t this_arg) {
37355         LDKInitFeatures this_arg_conv;
37356         this_arg_conv.inner = (void*)(this_arg & (~1));
37357         this_arg_conv.is_owned = false;
37358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37359         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
37360 }
37361
37362 void  __attribute__((export_name("TS_InitFeatures_set_static_remote_key_required"))) TS_InitFeatures_set_static_remote_key_required(uint32_t this_arg) {
37363         LDKInitFeatures this_arg_conv;
37364         this_arg_conv.inner = (void*)(this_arg & (~1));
37365         this_arg_conv.is_owned = false;
37366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37367         InitFeatures_set_static_remote_key_required(&this_arg_conv);
37368 }
37369
37370 jboolean  __attribute__((export_name("TS_InitFeatures_supports_static_remote_key"))) TS_InitFeatures_supports_static_remote_key(uint32_t this_arg) {
37371         LDKInitFeatures this_arg_conv;
37372         this_arg_conv.inner = (void*)(this_arg & (~1));
37373         this_arg_conv.is_owned = false;
37374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37375         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
37376         return ret_conv;
37377 }
37378
37379 void  __attribute__((export_name("TS_NodeFeatures_set_static_remote_key_optional"))) TS_NodeFeatures_set_static_remote_key_optional(uint32_t this_arg) {
37380         LDKNodeFeatures this_arg_conv;
37381         this_arg_conv.inner = (void*)(this_arg & (~1));
37382         this_arg_conv.is_owned = false;
37383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37384         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
37385 }
37386
37387 void  __attribute__((export_name("TS_NodeFeatures_set_static_remote_key_required"))) TS_NodeFeatures_set_static_remote_key_required(uint32_t this_arg) {
37388         LDKNodeFeatures this_arg_conv;
37389         this_arg_conv.inner = (void*)(this_arg & (~1));
37390         this_arg_conv.is_owned = false;
37391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37392         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
37393 }
37394
37395 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_static_remote_key"))) TS_NodeFeatures_supports_static_remote_key(uint32_t this_arg) {
37396         LDKNodeFeatures this_arg_conv;
37397         this_arg_conv.inner = (void*)(this_arg & (~1));
37398         this_arg_conv.is_owned = false;
37399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37400         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
37401         return ret_conv;
37402 }
37403
37404 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_static_remote_key_optional"))) TS_ChannelTypeFeatures_set_static_remote_key_optional(uint32_t this_arg) {
37405         LDKChannelTypeFeatures this_arg_conv;
37406         this_arg_conv.inner = (void*)(this_arg & (~1));
37407         this_arg_conv.is_owned = false;
37408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37409         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
37410 }
37411
37412 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_static_remote_key_required"))) TS_ChannelTypeFeatures_set_static_remote_key_required(uint32_t this_arg) {
37413         LDKChannelTypeFeatures this_arg_conv;
37414         this_arg_conv.inner = (void*)(this_arg & (~1));
37415         this_arg_conv.is_owned = false;
37416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37417         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
37418 }
37419
37420 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_static_remote_key"))) TS_ChannelTypeFeatures_supports_static_remote_key(uint32_t this_arg) {
37421         LDKChannelTypeFeatures this_arg_conv;
37422         this_arg_conv.inner = (void*)(this_arg & (~1));
37423         this_arg_conv.is_owned = false;
37424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37425         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
37426         return ret_conv;
37427 }
37428
37429 jboolean  __attribute__((export_name("TS_InitFeatures_requires_static_remote_key"))) TS_InitFeatures_requires_static_remote_key(uint32_t this_arg) {
37430         LDKInitFeatures this_arg_conv;
37431         this_arg_conv.inner = (void*)(this_arg & (~1));
37432         this_arg_conv.is_owned = false;
37433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37434         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
37435         return ret_conv;
37436 }
37437
37438 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_static_remote_key"))) TS_NodeFeatures_requires_static_remote_key(uint32_t this_arg) {
37439         LDKNodeFeatures this_arg_conv;
37440         this_arg_conv.inner = (void*)(this_arg & (~1));
37441         this_arg_conv.is_owned = false;
37442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37443         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
37444         return ret_conv;
37445 }
37446
37447 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_static_remote_key"))) TS_ChannelTypeFeatures_requires_static_remote_key(uint32_t this_arg) {
37448         LDKChannelTypeFeatures this_arg_conv;
37449         this_arg_conv.inner = (void*)(this_arg & (~1));
37450         this_arg_conv.is_owned = false;
37451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37452         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
37453         return ret_conv;
37454 }
37455
37456 void  __attribute__((export_name("TS_InitFeatures_set_payment_secret_optional"))) TS_InitFeatures_set_payment_secret_optional(uint32_t this_arg) {
37457         LDKInitFeatures this_arg_conv;
37458         this_arg_conv.inner = (void*)(this_arg & (~1));
37459         this_arg_conv.is_owned = false;
37460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37461         InitFeatures_set_payment_secret_optional(&this_arg_conv);
37462 }
37463
37464 void  __attribute__((export_name("TS_InitFeatures_set_payment_secret_required"))) TS_InitFeatures_set_payment_secret_required(uint32_t this_arg) {
37465         LDKInitFeatures this_arg_conv;
37466         this_arg_conv.inner = (void*)(this_arg & (~1));
37467         this_arg_conv.is_owned = false;
37468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37469         InitFeatures_set_payment_secret_required(&this_arg_conv);
37470 }
37471
37472 jboolean  __attribute__((export_name("TS_InitFeatures_supports_payment_secret"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) {
37473         LDKInitFeatures this_arg_conv;
37474         this_arg_conv.inner = (void*)(this_arg & (~1));
37475         this_arg_conv.is_owned = false;
37476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37477         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
37478         return ret_conv;
37479 }
37480
37481 void  __attribute__((export_name("TS_NodeFeatures_set_payment_secret_optional"))) TS_NodeFeatures_set_payment_secret_optional(uint32_t this_arg) {
37482         LDKNodeFeatures this_arg_conv;
37483         this_arg_conv.inner = (void*)(this_arg & (~1));
37484         this_arg_conv.is_owned = false;
37485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37486         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
37487 }
37488
37489 void  __attribute__((export_name("TS_NodeFeatures_set_payment_secret_required"))) TS_NodeFeatures_set_payment_secret_required(uint32_t this_arg) {
37490         LDKNodeFeatures this_arg_conv;
37491         this_arg_conv.inner = (void*)(this_arg & (~1));
37492         this_arg_conv.is_owned = false;
37493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37494         NodeFeatures_set_payment_secret_required(&this_arg_conv);
37495 }
37496
37497 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_payment_secret"))) TS_NodeFeatures_supports_payment_secret(uint32_t this_arg) {
37498         LDKNodeFeatures this_arg_conv;
37499         this_arg_conv.inner = (void*)(this_arg & (~1));
37500         this_arg_conv.is_owned = false;
37501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37502         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
37503         return ret_conv;
37504 }
37505
37506 void  __attribute__((export_name("TS_InvoiceFeatures_set_payment_secret_optional"))) TS_InvoiceFeatures_set_payment_secret_optional(uint32_t this_arg) {
37507         LDKInvoiceFeatures this_arg_conv;
37508         this_arg_conv.inner = (void*)(this_arg & (~1));
37509         this_arg_conv.is_owned = false;
37510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37511         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
37512 }
37513
37514 void  __attribute__((export_name("TS_InvoiceFeatures_set_payment_secret_required"))) TS_InvoiceFeatures_set_payment_secret_required(uint32_t this_arg) {
37515         LDKInvoiceFeatures this_arg_conv;
37516         this_arg_conv.inner = (void*)(this_arg & (~1));
37517         this_arg_conv.is_owned = false;
37518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37519         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
37520 }
37521
37522 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_payment_secret"))) TS_InvoiceFeatures_supports_payment_secret(uint32_t this_arg) {
37523         LDKInvoiceFeatures this_arg_conv;
37524         this_arg_conv.inner = (void*)(this_arg & (~1));
37525         this_arg_conv.is_owned = false;
37526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37527         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
37528         return ret_conv;
37529 }
37530
37531 jboolean  __attribute__((export_name("TS_InitFeatures_requires_payment_secret"))) TS_InitFeatures_requires_payment_secret(uint32_t this_arg) {
37532         LDKInitFeatures this_arg_conv;
37533         this_arg_conv.inner = (void*)(this_arg & (~1));
37534         this_arg_conv.is_owned = false;
37535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37536         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
37537         return ret_conv;
37538 }
37539
37540 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_payment_secret"))) TS_NodeFeatures_requires_payment_secret(uint32_t this_arg) {
37541         LDKNodeFeatures this_arg_conv;
37542         this_arg_conv.inner = (void*)(this_arg & (~1));
37543         this_arg_conv.is_owned = false;
37544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37545         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
37546         return ret_conv;
37547 }
37548
37549 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_payment_secret"))) TS_InvoiceFeatures_requires_payment_secret(uint32_t this_arg) {
37550         LDKInvoiceFeatures this_arg_conv;
37551         this_arg_conv.inner = (void*)(this_arg & (~1));
37552         this_arg_conv.is_owned = false;
37553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37554         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
37555         return ret_conv;
37556 }
37557
37558 void  __attribute__((export_name("TS_InitFeatures_set_basic_mpp_optional"))) TS_InitFeatures_set_basic_mpp_optional(uint32_t this_arg) {
37559         LDKInitFeatures this_arg_conv;
37560         this_arg_conv.inner = (void*)(this_arg & (~1));
37561         this_arg_conv.is_owned = false;
37562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37563         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
37564 }
37565
37566 void  __attribute__((export_name("TS_InitFeatures_set_basic_mpp_required"))) TS_InitFeatures_set_basic_mpp_required(uint32_t this_arg) {
37567         LDKInitFeatures this_arg_conv;
37568         this_arg_conv.inner = (void*)(this_arg & (~1));
37569         this_arg_conv.is_owned = false;
37570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37571         InitFeatures_set_basic_mpp_required(&this_arg_conv);
37572 }
37573
37574 jboolean  __attribute__((export_name("TS_InitFeatures_supports_basic_mpp"))) TS_InitFeatures_supports_basic_mpp(uint32_t this_arg) {
37575         LDKInitFeatures this_arg_conv;
37576         this_arg_conv.inner = (void*)(this_arg & (~1));
37577         this_arg_conv.is_owned = false;
37578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37579         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
37580         return ret_conv;
37581 }
37582
37583 void  __attribute__((export_name("TS_NodeFeatures_set_basic_mpp_optional"))) TS_NodeFeatures_set_basic_mpp_optional(uint32_t this_arg) {
37584         LDKNodeFeatures this_arg_conv;
37585         this_arg_conv.inner = (void*)(this_arg & (~1));
37586         this_arg_conv.is_owned = false;
37587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37588         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
37589 }
37590
37591 void  __attribute__((export_name("TS_NodeFeatures_set_basic_mpp_required"))) TS_NodeFeatures_set_basic_mpp_required(uint32_t this_arg) {
37592         LDKNodeFeatures this_arg_conv;
37593         this_arg_conv.inner = (void*)(this_arg & (~1));
37594         this_arg_conv.is_owned = false;
37595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37596         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
37597 }
37598
37599 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_basic_mpp"))) TS_NodeFeatures_supports_basic_mpp(uint32_t this_arg) {
37600         LDKNodeFeatures this_arg_conv;
37601         this_arg_conv.inner = (void*)(this_arg & (~1));
37602         this_arg_conv.is_owned = false;
37603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37604         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
37605         return ret_conv;
37606 }
37607
37608 void  __attribute__((export_name("TS_InvoiceFeatures_set_basic_mpp_optional"))) TS_InvoiceFeatures_set_basic_mpp_optional(uint32_t this_arg) {
37609         LDKInvoiceFeatures this_arg_conv;
37610         this_arg_conv.inner = (void*)(this_arg & (~1));
37611         this_arg_conv.is_owned = false;
37612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37613         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
37614 }
37615
37616 void  __attribute__((export_name("TS_InvoiceFeatures_set_basic_mpp_required"))) TS_InvoiceFeatures_set_basic_mpp_required(uint32_t this_arg) {
37617         LDKInvoiceFeatures this_arg_conv;
37618         this_arg_conv.inner = (void*)(this_arg & (~1));
37619         this_arg_conv.is_owned = false;
37620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37621         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
37622 }
37623
37624 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_basic_mpp"))) TS_InvoiceFeatures_supports_basic_mpp(uint32_t this_arg) {
37625         LDKInvoiceFeatures this_arg_conv;
37626         this_arg_conv.inner = (void*)(this_arg & (~1));
37627         this_arg_conv.is_owned = false;
37628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37629         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
37630         return ret_conv;
37631 }
37632
37633 jboolean  __attribute__((export_name("TS_InitFeatures_requires_basic_mpp"))) TS_InitFeatures_requires_basic_mpp(uint32_t this_arg) {
37634         LDKInitFeatures this_arg_conv;
37635         this_arg_conv.inner = (void*)(this_arg & (~1));
37636         this_arg_conv.is_owned = false;
37637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37638         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
37639         return ret_conv;
37640 }
37641
37642 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_basic_mpp"))) TS_NodeFeatures_requires_basic_mpp(uint32_t this_arg) {
37643         LDKNodeFeatures this_arg_conv;
37644         this_arg_conv.inner = (void*)(this_arg & (~1));
37645         this_arg_conv.is_owned = false;
37646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37647         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
37648         return ret_conv;
37649 }
37650
37651 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_basic_mpp"))) TS_InvoiceFeatures_requires_basic_mpp(uint32_t this_arg) {
37652         LDKInvoiceFeatures this_arg_conv;
37653         this_arg_conv.inner = (void*)(this_arg & (~1));
37654         this_arg_conv.is_owned = false;
37655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37656         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
37657         return ret_conv;
37658 }
37659
37660 void  __attribute__((export_name("TS_InitFeatures_set_wumbo_optional"))) TS_InitFeatures_set_wumbo_optional(uint32_t this_arg) {
37661         LDKInitFeatures this_arg_conv;
37662         this_arg_conv.inner = (void*)(this_arg & (~1));
37663         this_arg_conv.is_owned = false;
37664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37665         InitFeatures_set_wumbo_optional(&this_arg_conv);
37666 }
37667
37668 void  __attribute__((export_name("TS_InitFeatures_set_wumbo_required"))) TS_InitFeatures_set_wumbo_required(uint32_t this_arg) {
37669         LDKInitFeatures this_arg_conv;
37670         this_arg_conv.inner = (void*)(this_arg & (~1));
37671         this_arg_conv.is_owned = false;
37672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37673         InitFeatures_set_wumbo_required(&this_arg_conv);
37674 }
37675
37676 jboolean  __attribute__((export_name("TS_InitFeatures_supports_wumbo"))) TS_InitFeatures_supports_wumbo(uint32_t this_arg) {
37677         LDKInitFeatures this_arg_conv;
37678         this_arg_conv.inner = (void*)(this_arg & (~1));
37679         this_arg_conv.is_owned = false;
37680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37681         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
37682         return ret_conv;
37683 }
37684
37685 void  __attribute__((export_name("TS_NodeFeatures_set_wumbo_optional"))) TS_NodeFeatures_set_wumbo_optional(uint32_t this_arg) {
37686         LDKNodeFeatures this_arg_conv;
37687         this_arg_conv.inner = (void*)(this_arg & (~1));
37688         this_arg_conv.is_owned = false;
37689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37690         NodeFeatures_set_wumbo_optional(&this_arg_conv);
37691 }
37692
37693 void  __attribute__((export_name("TS_NodeFeatures_set_wumbo_required"))) TS_NodeFeatures_set_wumbo_required(uint32_t this_arg) {
37694         LDKNodeFeatures this_arg_conv;
37695         this_arg_conv.inner = (void*)(this_arg & (~1));
37696         this_arg_conv.is_owned = false;
37697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37698         NodeFeatures_set_wumbo_required(&this_arg_conv);
37699 }
37700
37701 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_wumbo"))) TS_NodeFeatures_supports_wumbo(uint32_t this_arg) {
37702         LDKNodeFeatures this_arg_conv;
37703         this_arg_conv.inner = (void*)(this_arg & (~1));
37704         this_arg_conv.is_owned = false;
37705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37706         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
37707         return ret_conv;
37708 }
37709
37710 jboolean  __attribute__((export_name("TS_InitFeatures_requires_wumbo"))) TS_InitFeatures_requires_wumbo(uint32_t this_arg) {
37711         LDKInitFeatures this_arg_conv;
37712         this_arg_conv.inner = (void*)(this_arg & (~1));
37713         this_arg_conv.is_owned = false;
37714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37715         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
37716         return ret_conv;
37717 }
37718
37719 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_wumbo"))) TS_NodeFeatures_requires_wumbo(uint32_t this_arg) {
37720         LDKNodeFeatures this_arg_conv;
37721         this_arg_conv.inner = (void*)(this_arg & (~1));
37722         this_arg_conv.is_owned = false;
37723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37724         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
37725         return ret_conv;
37726 }
37727
37728 void  __attribute__((export_name("TS_InitFeatures_set_shutdown_any_segwit_optional"))) TS_InitFeatures_set_shutdown_any_segwit_optional(uint32_t this_arg) {
37729         LDKInitFeatures this_arg_conv;
37730         this_arg_conv.inner = (void*)(this_arg & (~1));
37731         this_arg_conv.is_owned = false;
37732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37733         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
37734 }
37735
37736 void  __attribute__((export_name("TS_InitFeatures_set_shutdown_any_segwit_required"))) TS_InitFeatures_set_shutdown_any_segwit_required(uint32_t this_arg) {
37737         LDKInitFeatures this_arg_conv;
37738         this_arg_conv.inner = (void*)(this_arg & (~1));
37739         this_arg_conv.is_owned = false;
37740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37741         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
37742 }
37743
37744 jboolean  __attribute__((export_name("TS_InitFeatures_supports_shutdown_anysegwit"))) TS_InitFeatures_supports_shutdown_anysegwit(uint32_t this_arg) {
37745         LDKInitFeatures this_arg_conv;
37746         this_arg_conv.inner = (void*)(this_arg & (~1));
37747         this_arg_conv.is_owned = false;
37748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37749         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
37750         return ret_conv;
37751 }
37752
37753 void  __attribute__((export_name("TS_NodeFeatures_set_shutdown_any_segwit_optional"))) TS_NodeFeatures_set_shutdown_any_segwit_optional(uint32_t this_arg) {
37754         LDKNodeFeatures this_arg_conv;
37755         this_arg_conv.inner = (void*)(this_arg & (~1));
37756         this_arg_conv.is_owned = false;
37757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37758         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
37759 }
37760
37761 void  __attribute__((export_name("TS_NodeFeatures_set_shutdown_any_segwit_required"))) TS_NodeFeatures_set_shutdown_any_segwit_required(uint32_t this_arg) {
37762         LDKNodeFeatures this_arg_conv;
37763         this_arg_conv.inner = (void*)(this_arg & (~1));
37764         this_arg_conv.is_owned = false;
37765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37766         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
37767 }
37768
37769 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_shutdown_anysegwit"))) TS_NodeFeatures_supports_shutdown_anysegwit(uint32_t this_arg) {
37770         LDKNodeFeatures this_arg_conv;
37771         this_arg_conv.inner = (void*)(this_arg & (~1));
37772         this_arg_conv.is_owned = false;
37773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37774         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
37775         return ret_conv;
37776 }
37777
37778 jboolean  __attribute__((export_name("TS_InitFeatures_requires_shutdown_anysegwit"))) TS_InitFeatures_requires_shutdown_anysegwit(uint32_t this_arg) {
37779         LDKInitFeatures this_arg_conv;
37780         this_arg_conv.inner = (void*)(this_arg & (~1));
37781         this_arg_conv.is_owned = false;
37782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37783         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
37784         return ret_conv;
37785 }
37786
37787 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_shutdown_anysegwit"))) TS_NodeFeatures_requires_shutdown_anysegwit(uint32_t this_arg) {
37788         LDKNodeFeatures this_arg_conv;
37789         this_arg_conv.inner = (void*)(this_arg & (~1));
37790         this_arg_conv.is_owned = false;
37791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37792         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
37793         return ret_conv;
37794 }
37795
37796 void  __attribute__((export_name("TS_InitFeatures_set_channel_type_optional"))) TS_InitFeatures_set_channel_type_optional(uint32_t this_arg) {
37797         LDKInitFeatures this_arg_conv;
37798         this_arg_conv.inner = (void*)(this_arg & (~1));
37799         this_arg_conv.is_owned = false;
37800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37801         InitFeatures_set_channel_type_optional(&this_arg_conv);
37802 }
37803
37804 void  __attribute__((export_name("TS_InitFeatures_set_channel_type_required"))) TS_InitFeatures_set_channel_type_required(uint32_t this_arg) {
37805         LDKInitFeatures this_arg_conv;
37806         this_arg_conv.inner = (void*)(this_arg & (~1));
37807         this_arg_conv.is_owned = false;
37808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37809         InitFeatures_set_channel_type_required(&this_arg_conv);
37810 }
37811
37812 jboolean  __attribute__((export_name("TS_InitFeatures_supports_channel_type"))) TS_InitFeatures_supports_channel_type(uint32_t this_arg) {
37813         LDKInitFeatures this_arg_conv;
37814         this_arg_conv.inner = (void*)(this_arg & (~1));
37815         this_arg_conv.is_owned = false;
37816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37817         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
37818         return ret_conv;
37819 }
37820
37821 void  __attribute__((export_name("TS_NodeFeatures_set_channel_type_optional"))) TS_NodeFeatures_set_channel_type_optional(uint32_t this_arg) {
37822         LDKNodeFeatures this_arg_conv;
37823         this_arg_conv.inner = (void*)(this_arg & (~1));
37824         this_arg_conv.is_owned = false;
37825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37826         NodeFeatures_set_channel_type_optional(&this_arg_conv);
37827 }
37828
37829 void  __attribute__((export_name("TS_NodeFeatures_set_channel_type_required"))) TS_NodeFeatures_set_channel_type_required(uint32_t this_arg) {
37830         LDKNodeFeatures this_arg_conv;
37831         this_arg_conv.inner = (void*)(this_arg & (~1));
37832         this_arg_conv.is_owned = false;
37833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37834         NodeFeatures_set_channel_type_required(&this_arg_conv);
37835 }
37836
37837 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_channel_type"))) TS_NodeFeatures_supports_channel_type(uint32_t this_arg) {
37838         LDKNodeFeatures this_arg_conv;
37839         this_arg_conv.inner = (void*)(this_arg & (~1));
37840         this_arg_conv.is_owned = false;
37841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37842         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
37843         return ret_conv;
37844 }
37845
37846 jboolean  __attribute__((export_name("TS_InitFeatures_requires_channel_type"))) TS_InitFeatures_requires_channel_type(uint32_t this_arg) {
37847         LDKInitFeatures this_arg_conv;
37848         this_arg_conv.inner = (void*)(this_arg & (~1));
37849         this_arg_conv.is_owned = false;
37850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37851         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
37852         return ret_conv;
37853 }
37854
37855 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_channel_type"))) TS_NodeFeatures_requires_channel_type(uint32_t this_arg) {
37856         LDKNodeFeatures this_arg_conv;
37857         this_arg_conv.inner = (void*)(this_arg & (~1));
37858         this_arg_conv.is_owned = false;
37859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37860         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
37861         return ret_conv;
37862 }
37863
37864 void  __attribute__((export_name("TS_InitFeatures_set_scid_privacy_optional"))) TS_InitFeatures_set_scid_privacy_optional(uint32_t this_arg) {
37865         LDKInitFeatures this_arg_conv;
37866         this_arg_conv.inner = (void*)(this_arg & (~1));
37867         this_arg_conv.is_owned = false;
37868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37869         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
37870 }
37871
37872 void  __attribute__((export_name("TS_InitFeatures_set_scid_privacy_required"))) TS_InitFeatures_set_scid_privacy_required(uint32_t this_arg) {
37873         LDKInitFeatures this_arg_conv;
37874         this_arg_conv.inner = (void*)(this_arg & (~1));
37875         this_arg_conv.is_owned = false;
37876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37877         InitFeatures_set_scid_privacy_required(&this_arg_conv);
37878 }
37879
37880 jboolean  __attribute__((export_name("TS_InitFeatures_supports_scid_privacy"))) TS_InitFeatures_supports_scid_privacy(uint32_t this_arg) {
37881         LDKInitFeatures this_arg_conv;
37882         this_arg_conv.inner = (void*)(this_arg & (~1));
37883         this_arg_conv.is_owned = false;
37884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37885         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
37886         return ret_conv;
37887 }
37888
37889 void  __attribute__((export_name("TS_NodeFeatures_set_scid_privacy_optional"))) TS_NodeFeatures_set_scid_privacy_optional(uint32_t this_arg) {
37890         LDKNodeFeatures this_arg_conv;
37891         this_arg_conv.inner = (void*)(this_arg & (~1));
37892         this_arg_conv.is_owned = false;
37893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37894         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
37895 }
37896
37897 void  __attribute__((export_name("TS_NodeFeatures_set_scid_privacy_required"))) TS_NodeFeatures_set_scid_privacy_required(uint32_t this_arg) {
37898         LDKNodeFeatures this_arg_conv;
37899         this_arg_conv.inner = (void*)(this_arg & (~1));
37900         this_arg_conv.is_owned = false;
37901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37902         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
37903 }
37904
37905 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_scid_privacy"))) TS_NodeFeatures_supports_scid_privacy(uint32_t this_arg) {
37906         LDKNodeFeatures this_arg_conv;
37907         this_arg_conv.inner = (void*)(this_arg & (~1));
37908         this_arg_conv.is_owned = false;
37909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37910         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
37911         return ret_conv;
37912 }
37913
37914 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_scid_privacy_optional"))) TS_ChannelTypeFeatures_set_scid_privacy_optional(uint32_t this_arg) {
37915         LDKChannelTypeFeatures this_arg_conv;
37916         this_arg_conv.inner = (void*)(this_arg & (~1));
37917         this_arg_conv.is_owned = false;
37918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37919         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
37920 }
37921
37922 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_scid_privacy_required"))) TS_ChannelTypeFeatures_set_scid_privacy_required(uint32_t this_arg) {
37923         LDKChannelTypeFeatures this_arg_conv;
37924         this_arg_conv.inner = (void*)(this_arg & (~1));
37925         this_arg_conv.is_owned = false;
37926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37927         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
37928 }
37929
37930 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_scid_privacy"))) TS_ChannelTypeFeatures_supports_scid_privacy(uint32_t this_arg) {
37931         LDKChannelTypeFeatures this_arg_conv;
37932         this_arg_conv.inner = (void*)(this_arg & (~1));
37933         this_arg_conv.is_owned = false;
37934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37935         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
37936         return ret_conv;
37937 }
37938
37939 jboolean  __attribute__((export_name("TS_InitFeatures_requires_scid_privacy"))) TS_InitFeatures_requires_scid_privacy(uint32_t this_arg) {
37940         LDKInitFeatures this_arg_conv;
37941         this_arg_conv.inner = (void*)(this_arg & (~1));
37942         this_arg_conv.is_owned = false;
37943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37944         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
37945         return ret_conv;
37946 }
37947
37948 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_scid_privacy"))) TS_NodeFeatures_requires_scid_privacy(uint32_t this_arg) {
37949         LDKNodeFeatures this_arg_conv;
37950         this_arg_conv.inner = (void*)(this_arg & (~1));
37951         this_arg_conv.is_owned = false;
37952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37953         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
37954         return ret_conv;
37955 }
37956
37957 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_scid_privacy"))) TS_ChannelTypeFeatures_requires_scid_privacy(uint32_t this_arg) {
37958         LDKChannelTypeFeatures this_arg_conv;
37959         this_arg_conv.inner = (void*)(this_arg & (~1));
37960         this_arg_conv.is_owned = false;
37961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37962         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
37963         return ret_conv;
37964 }
37965
37966 void  __attribute__((export_name("TS_InitFeatures_set_zero_conf_optional"))) TS_InitFeatures_set_zero_conf_optional(uint32_t this_arg) {
37967         LDKInitFeatures this_arg_conv;
37968         this_arg_conv.inner = (void*)(this_arg & (~1));
37969         this_arg_conv.is_owned = false;
37970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37971         InitFeatures_set_zero_conf_optional(&this_arg_conv);
37972 }
37973
37974 void  __attribute__((export_name("TS_InitFeatures_set_zero_conf_required"))) TS_InitFeatures_set_zero_conf_required(uint32_t this_arg) {
37975         LDKInitFeatures this_arg_conv;
37976         this_arg_conv.inner = (void*)(this_arg & (~1));
37977         this_arg_conv.is_owned = false;
37978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37979         InitFeatures_set_zero_conf_required(&this_arg_conv);
37980 }
37981
37982 jboolean  __attribute__((export_name("TS_InitFeatures_supports_zero_conf"))) TS_InitFeatures_supports_zero_conf(uint32_t this_arg) {
37983         LDKInitFeatures this_arg_conv;
37984         this_arg_conv.inner = (void*)(this_arg & (~1));
37985         this_arg_conv.is_owned = false;
37986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37987         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
37988         return ret_conv;
37989 }
37990
37991 void  __attribute__((export_name("TS_NodeFeatures_set_zero_conf_optional"))) TS_NodeFeatures_set_zero_conf_optional(uint32_t this_arg) {
37992         LDKNodeFeatures this_arg_conv;
37993         this_arg_conv.inner = (void*)(this_arg & (~1));
37994         this_arg_conv.is_owned = false;
37995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37996         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
37997 }
37998
37999 void  __attribute__((export_name("TS_NodeFeatures_set_zero_conf_required"))) TS_NodeFeatures_set_zero_conf_required(uint32_t this_arg) {
38000         LDKNodeFeatures this_arg_conv;
38001         this_arg_conv.inner = (void*)(this_arg & (~1));
38002         this_arg_conv.is_owned = false;
38003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38004         NodeFeatures_set_zero_conf_required(&this_arg_conv);
38005 }
38006
38007 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_zero_conf"))) TS_NodeFeatures_supports_zero_conf(uint32_t this_arg) {
38008         LDKNodeFeatures this_arg_conv;
38009         this_arg_conv.inner = (void*)(this_arg & (~1));
38010         this_arg_conv.is_owned = false;
38011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38012         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
38013         return ret_conv;
38014 }
38015
38016 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_zero_conf_optional"))) TS_ChannelTypeFeatures_set_zero_conf_optional(uint32_t this_arg) {
38017         LDKChannelTypeFeatures this_arg_conv;
38018         this_arg_conv.inner = (void*)(this_arg & (~1));
38019         this_arg_conv.is_owned = false;
38020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38021         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
38022 }
38023
38024 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_zero_conf_required"))) TS_ChannelTypeFeatures_set_zero_conf_required(uint32_t this_arg) {
38025         LDKChannelTypeFeatures this_arg_conv;
38026         this_arg_conv.inner = (void*)(this_arg & (~1));
38027         this_arg_conv.is_owned = false;
38028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38029         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
38030 }
38031
38032 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_zero_conf"))) TS_ChannelTypeFeatures_supports_zero_conf(uint32_t this_arg) {
38033         LDKChannelTypeFeatures this_arg_conv;
38034         this_arg_conv.inner = (void*)(this_arg & (~1));
38035         this_arg_conv.is_owned = false;
38036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38037         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
38038         return ret_conv;
38039 }
38040
38041 jboolean  __attribute__((export_name("TS_InitFeatures_requires_zero_conf"))) TS_InitFeatures_requires_zero_conf(uint32_t this_arg) {
38042         LDKInitFeatures this_arg_conv;
38043         this_arg_conv.inner = (void*)(this_arg & (~1));
38044         this_arg_conv.is_owned = false;
38045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38046         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
38047         return ret_conv;
38048 }
38049
38050 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_zero_conf"))) TS_NodeFeatures_requires_zero_conf(uint32_t this_arg) {
38051         LDKNodeFeatures this_arg_conv;
38052         this_arg_conv.inner = (void*)(this_arg & (~1));
38053         this_arg_conv.is_owned = false;
38054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38055         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
38056         return ret_conv;
38057 }
38058
38059 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_zero_conf"))) TS_ChannelTypeFeatures_requires_zero_conf(uint32_t this_arg) {
38060         LDKChannelTypeFeatures this_arg_conv;
38061         this_arg_conv.inner = (void*)(this_arg & (~1));
38062         this_arg_conv.is_owned = false;
38063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38064         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
38065         return ret_conv;
38066 }
38067
38068 void  __attribute__((export_name("TS_NodeFeatures_set_keysend_optional"))) TS_NodeFeatures_set_keysend_optional(uint32_t this_arg) {
38069         LDKNodeFeatures this_arg_conv;
38070         this_arg_conv.inner = (void*)(this_arg & (~1));
38071         this_arg_conv.is_owned = false;
38072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38073         NodeFeatures_set_keysend_optional(&this_arg_conv);
38074 }
38075
38076 void  __attribute__((export_name("TS_NodeFeatures_set_keysend_required"))) TS_NodeFeatures_set_keysend_required(uint32_t this_arg) {
38077         LDKNodeFeatures this_arg_conv;
38078         this_arg_conv.inner = (void*)(this_arg & (~1));
38079         this_arg_conv.is_owned = false;
38080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38081         NodeFeatures_set_keysend_required(&this_arg_conv);
38082 }
38083
38084 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_keysend"))) TS_NodeFeatures_supports_keysend(uint32_t this_arg) {
38085         LDKNodeFeatures this_arg_conv;
38086         this_arg_conv.inner = (void*)(this_arg & (~1));
38087         this_arg_conv.is_owned = false;
38088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38089         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
38090         return ret_conv;
38091 }
38092
38093 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_keysend"))) TS_NodeFeatures_requires_keysend(uint32_t this_arg) {
38094         LDKNodeFeatures this_arg_conv;
38095         this_arg_conv.inner = (void*)(this_arg & (~1));
38096         this_arg_conv.is_owned = false;
38097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38098         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
38099         return ret_conv;
38100 }
38101
38102 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint32_t this_obj) {
38103         LDKShutdownScript this_obj_conv;
38104         this_obj_conv.inner = (void*)(this_obj & (~1));
38105         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38107         ShutdownScript_free(this_obj_conv);
38108 }
38109
38110 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
38111         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
38112 uint32_t ret_ref = 0;
38113 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38114 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38115 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38116 ret_ref = (uintptr_t)ret_var.inner;
38117 if (ret_var.is_owned) {
38118         ret_ref |= 1;
38119 }
38120         return ret_ref;
38121 }
38122 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
38123         LDKShutdownScript arg_conv;
38124         arg_conv.inner = (void*)(arg & (~1));
38125         arg_conv.is_owned = false;
38126         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38127         uint32_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
38128         return ret_conv;
38129 }
38130
38131 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint32_t orig) {
38132         LDKShutdownScript orig_conv;
38133         orig_conv.inner = (void*)(orig & (~1));
38134         orig_conv.is_owned = false;
38135         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38136         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
38137         uint32_t ret_ref = 0;
38138         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38139         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38141         ret_ref = (uintptr_t)ret_var.inner;
38142         if (ret_var.is_owned) {
38143                 ret_ref |= 1;
38144         }
38145         return ret_ref;
38146 }
38147
38148 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
38149         LDKInvalidShutdownScript this_obj_conv;
38150         this_obj_conv.inner = (void*)(this_obj & (~1));
38151         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38153         InvalidShutdownScript_free(this_obj_conv);
38154 }
38155
38156 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
38157         LDKInvalidShutdownScript this_ptr_conv;
38158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38159         this_ptr_conv.is_owned = false;
38160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38161         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
38162         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38163         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38164         return ret_arr;
38165 }
38166
38167 void  __attribute__((export_name("TS_InvalidShutdownScript_set_script"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
38168         LDKInvalidShutdownScript this_ptr_conv;
38169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38170         this_ptr_conv.is_owned = false;
38171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38172         LDKCVec_u8Z val_ref;
38173         val_ref.datalen = val->arr_len;
38174         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
38175         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
38176         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
38177 }
38178
38179 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
38180         LDKCVec_u8Z script_arg_ref;
38181         script_arg_ref.datalen = script_arg->arr_len;
38182         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
38183         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
38184         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
38185         uint32_t ret_ref = 0;
38186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38189         ret_ref = (uintptr_t)ret_var.inner;
38190         if (ret_var.is_owned) {
38191                 ret_ref |= 1;
38192         }
38193         return ret_ref;
38194 }
38195
38196 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
38197         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
38198 uint32_t ret_ref = 0;
38199 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38200 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38201 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38202 ret_ref = (uintptr_t)ret_var.inner;
38203 if (ret_var.is_owned) {
38204         ret_ref |= 1;
38205 }
38206         return ret_ref;
38207 }
38208 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
38209         LDKInvalidShutdownScript arg_conv;
38210         arg_conv.inner = (void*)(arg & (~1));
38211         arg_conv.is_owned = false;
38212         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38213         uint32_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
38214         return ret_conv;
38215 }
38216
38217 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
38218         LDKInvalidShutdownScript orig_conv;
38219         orig_conv.inner = (void*)(orig & (~1));
38220         orig_conv.is_owned = false;
38221         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38222         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
38223         uint32_t ret_ref = 0;
38224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38227         ret_ref = (uintptr_t)ret_var.inner;
38228         if (ret_var.is_owned) {
38229                 ret_ref |= 1;
38230         }
38231         return ret_ref;
38232 }
38233
38234 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint32_t obj) {
38235         LDKShutdownScript obj_conv;
38236         obj_conv.inner = (void*)(obj & (~1));
38237         obj_conv.is_owned = false;
38238         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38239         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
38240         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38241         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38242         CVec_u8Z_free(ret_var);
38243         return ret_arr;
38244 }
38245
38246 uint32_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
38247         LDKu8slice ser_ref;
38248         ser_ref.datalen = ser->arr_len;
38249         ser_ref.data = ser->elems;
38250         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
38251         *ret_conv = ShutdownScript_read(ser_ref);
38252         FREE(ser);
38253         return (uint32_t)ret_conv;
38254 }
38255
38256 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
38257         unsigned char pubkey_hash_arr[20];
38258         CHECK(pubkey_hash->arr_len == 20);
38259         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
38260         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
38261         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
38262         uint32_t ret_ref = 0;
38263         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38264         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38266         ret_ref = (uintptr_t)ret_var.inner;
38267         if (ret_var.is_owned) {
38268                 ret_ref |= 1;
38269         }
38270         return ret_ref;
38271 }
38272
38273 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
38274         unsigned char script_hash_arr[32];
38275         CHECK(script_hash->arr_len == 32);
38276         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
38277         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
38278         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
38279         uint32_t ret_ref = 0;
38280         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38281         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38283         ret_ref = (uintptr_t)ret_var.inner;
38284         if (ret_var.is_owned) {
38285                 ret_ref |= 1;
38286         }
38287         return ret_ref;
38288 }
38289
38290 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
38291         
38292         LDKu8slice program_ref;
38293         program_ref.datalen = program->arr_len;
38294         program_ref.data = program->elems;
38295         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
38296         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
38297         FREE(program);
38298         return (uint32_t)ret_conv;
38299 }
38300
38301 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
38302         LDKShutdownScript this_arg_conv;
38303         this_arg_conv.inner = (void*)(this_arg & (~1));
38304         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
38305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38306         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
38307         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
38308         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38309         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38310         CVec_u8Z_free(ret_var);
38311         return ret_arr;
38312 }
38313
38314 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
38315         LDKShutdownScript this_arg_conv;
38316         this_arg_conv.inner = (void*)(this_arg & (~1));
38317         this_arg_conv.is_owned = false;
38318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38319         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38320         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
38321         return ret_arr;
38322 }
38323
38324 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
38325         LDKShutdownScript this_arg_conv;
38326         this_arg_conv.inner = (void*)(this_arg & (~1));
38327         this_arg_conv.is_owned = false;
38328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38329         LDKInitFeatures features_conv;
38330         features_conv.inner = (void*)(features & (~1));
38331         features_conv.is_owned = false;
38332         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
38333         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
38334         return ret_conv;
38335 }
38336
38337 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
38338         if ((this_ptr & 1) != 0) return;
38339         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38340         CHECK_ACCESS(this_ptr_ptr);
38341         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
38342         FREE((void*)this_ptr);
38343         CustomMessageReader_free(this_ptr_conv);
38344 }
38345
38346 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
38347         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
38348         *ret_ret = Type_clone(arg);
38349         return (uint32_t)ret_ret;
38350 }
38351 uint32_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint32_t arg) {
38352         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
38353         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
38354         LDKType* arg_conv = (LDKType*)arg_ptr;
38355         uint32_t ret_conv = Type_clone_ptr(arg_conv);
38356         return ret_conv;
38357 }
38358
38359 uint32_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint32_t orig) {
38360         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
38361         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
38362         LDKType* orig_conv = (LDKType*)orig_ptr;
38363         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
38364         *ret_ret = Type_clone(orig_conv);
38365         return (uint32_t)ret_ret;
38366 }
38367
38368 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint32_t this_ptr) {
38369         if ((this_ptr & 1) != 0) return;
38370         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38371         CHECK_ACCESS(this_ptr_ptr);
38372         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
38373         FREE((void*)this_ptr);
38374         Type_free(this_ptr_conv);
38375 }
38376
38377 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint32_t this_obj) {
38378         LDKNodeId this_obj_conv;
38379         this_obj_conv.inner = (void*)(this_obj & (~1));
38380         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38382         NodeId_free(this_obj_conv);
38383 }
38384
38385 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
38386         LDKNodeId ret_var = NodeId_clone(arg);
38387 uint32_t ret_ref = 0;
38388 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38389 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38390 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38391 ret_ref = (uintptr_t)ret_var.inner;
38392 if (ret_var.is_owned) {
38393         ret_ref |= 1;
38394 }
38395         return ret_ref;
38396 }
38397 uint32_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint32_t arg) {
38398         LDKNodeId arg_conv;
38399         arg_conv.inner = (void*)(arg & (~1));
38400         arg_conv.is_owned = false;
38401         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38402         uint32_t ret_conv = NodeId_clone_ptr(&arg_conv);
38403         return ret_conv;
38404 }
38405
38406 uint32_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint32_t orig) {
38407         LDKNodeId orig_conv;
38408         orig_conv.inner = (void*)(orig & (~1));
38409         orig_conv.is_owned = false;
38410         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38411         LDKNodeId ret_var = NodeId_clone(&orig_conv);
38412         uint32_t ret_ref = 0;
38413         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38414         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38416         ret_ref = (uintptr_t)ret_var.inner;
38417         if (ret_var.is_owned) {
38418                 ret_ref |= 1;
38419         }
38420         return ret_ref;
38421 }
38422
38423 uint32_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
38424         LDKPublicKey pubkey_ref;
38425         CHECK(pubkey->arr_len == 33);
38426         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
38427         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
38428         uint32_t ret_ref = 0;
38429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38432         ret_ref = (uintptr_t)ret_var.inner;
38433         if (ret_var.is_owned) {
38434                 ret_ref |= 1;
38435         }
38436         return ret_ref;
38437 }
38438
38439 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint32_t this_arg) {
38440         LDKNodeId this_arg_conv;
38441         this_arg_conv.inner = (void*)(this_arg & (~1));
38442         this_arg_conv.is_owned = false;
38443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38444         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
38445         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38446         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38447         return ret_arr;
38448 }
38449
38450 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint32_t o) {
38451         LDKNodeId o_conv;
38452         o_conv.inner = (void*)(o & (~1));
38453         o_conv.is_owned = false;
38454         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38455         int64_t ret_conv = NodeId_hash(&o_conv);
38456         return ret_conv;
38457 }
38458
38459 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint32_t obj) {
38460         LDKNodeId obj_conv;
38461         obj_conv.inner = (void*)(obj & (~1));
38462         obj_conv.is_owned = false;
38463         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38464         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
38465         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38466         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38467         CVec_u8Z_free(ret_var);
38468         return ret_arr;
38469 }
38470
38471 uint32_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
38472         LDKu8slice ser_ref;
38473         ser_ref.datalen = ser->arr_len;
38474         ser_ref.data = ser->elems;
38475         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
38476         *ret_conv = NodeId_read(ser_ref);
38477         FREE(ser);
38478         return (uint32_t)ret_conv;
38479 }
38480
38481 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint32_t this_obj) {
38482         LDKNetworkGraph this_obj_conv;
38483         this_obj_conv.inner = (void*)(this_obj & (~1));
38484         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38486         NetworkGraph_free(this_obj_conv);
38487 }
38488
38489 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
38490         LDKReadOnlyNetworkGraph this_obj_conv;
38491         this_obj_conv.inner = (void*)(this_obj & (~1));
38492         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38494         ReadOnlyNetworkGraph_free(this_obj_conv);
38495 }
38496
38497 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
38498         if ((this_ptr & 1) != 0) return;
38499         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38500         CHECK_ACCESS(this_ptr_ptr);
38501         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
38502         FREE((void*)this_ptr);
38503         NetworkUpdate_free(this_ptr_conv);
38504 }
38505
38506 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
38507         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
38508         *ret_copy = NetworkUpdate_clone(arg);
38509 uint32_t ret_ref = (uintptr_t)ret_copy;
38510         return ret_ref;
38511 }
38512 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
38513         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
38514         uint32_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
38515         return ret_conv;
38516 }
38517
38518 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint32_t orig) {
38519         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
38520         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
38521         *ret_copy = NetworkUpdate_clone(orig_conv);
38522         uint32_t ret_ref = (uintptr_t)ret_copy;
38523         return ret_ref;
38524 }
38525
38526 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
38527         LDKChannelUpdate msg_conv;
38528         msg_conv.inner = (void*)(msg & (~1));
38529         msg_conv.is_owned = (msg & 1) || (msg == 0);
38530         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
38531         msg_conv = ChannelUpdate_clone(&msg_conv);
38532         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
38533         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
38534         uint32_t ret_ref = (uintptr_t)ret_copy;
38535         return ret_ref;
38536 }
38537
38538 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_failure"))) TS_NetworkUpdate_channel_failure(int64_t short_channel_id, jboolean is_permanent) {
38539         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
38540         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
38541         uint32_t ret_ref = (uintptr_t)ret_copy;
38542         return ret_ref;
38543 }
38544
38545 uint32_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
38546         LDKPublicKey node_id_ref;
38547         CHECK(node_id->arr_len == 33);
38548         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
38549         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
38550         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
38551         uint32_t ret_ref = (uintptr_t)ret_copy;
38552         return ret_ref;
38553 }
38554
38555 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint32_t obj) {
38556         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
38557         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
38558         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38559         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38560         CVec_u8Z_free(ret_var);
38561         return ret_arr;
38562 }
38563
38564 uint32_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
38565         LDKu8slice ser_ref;
38566         ser_ref.datalen = ser->arr_len;
38567         ser_ref.data = ser->elems;
38568         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
38569         *ret_conv = NetworkUpdate_read(ser_ref);
38570         FREE(ser);
38571         return (uint32_t)ret_conv;
38572 }
38573
38574 void  __attribute__((export_name("TS_P2PGossipSync_free"))) TS_P2PGossipSync_free(uint32_t this_obj) {
38575         LDKP2PGossipSync this_obj_conv;
38576         this_obj_conv.inner = (void*)(this_obj & (~1));
38577         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38579         P2PGossipSync_free(this_obj_conv);
38580 }
38581
38582 uint32_t  __attribute__((export_name("TS_P2PGossipSync_new"))) TS_P2PGossipSync_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
38583         LDKNetworkGraph network_graph_conv;
38584         network_graph_conv.inner = (void*)(network_graph & (~1));
38585         network_graph_conv.is_owned = false;
38586         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
38587         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
38588         CHECK_ACCESS(chain_access_ptr);
38589         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
38590         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
38591         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
38592                 // Manually implement clone for Java trait instances
38593                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
38594                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38595                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
38596                 }
38597         }
38598         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
38599         CHECK_ACCESS(logger_ptr);
38600         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
38601         if (logger_conv.free == LDKLogger_JCalls_free) {
38602                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38603                 LDKLogger_JCalls_cloned(&logger_conv);
38604         }
38605         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
38606         uint32_t ret_ref = 0;
38607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38610         ret_ref = (uintptr_t)ret_var.inner;
38611         if (ret_var.is_owned) {
38612                 ret_ref |= 1;
38613         }
38614         return ret_ref;
38615 }
38616
38617 void  __attribute__((export_name("TS_P2PGossipSync_add_chain_access"))) TS_P2PGossipSync_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
38618         LDKP2PGossipSync this_arg_conv;
38619         this_arg_conv.inner = (void*)(this_arg & (~1));
38620         this_arg_conv.is_owned = false;
38621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38622         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
38623         CHECK_ACCESS(chain_access_ptr);
38624         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
38625         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
38626         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
38627                 // Manually implement clone for Java trait instances
38628                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
38629                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38630                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
38631                 }
38632         }
38633         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
38634 }
38635
38636 uint32_t  __attribute__((export_name("TS_NetworkGraph_as_EventHandler"))) TS_NetworkGraph_as_EventHandler(uint32_t this_arg) {
38637         LDKNetworkGraph this_arg_conv;
38638         this_arg_conv.inner = (void*)(this_arg & (~1));
38639         this_arg_conv.is_owned = false;
38640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38641         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
38642         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
38643         return (uint32_t)ret_ret;
38644 }
38645
38646 uint32_t  __attribute__((export_name("TS_P2PGossipSync_as_RoutingMessageHandler"))) TS_P2PGossipSync_as_RoutingMessageHandler(uint32_t this_arg) {
38647         LDKP2PGossipSync this_arg_conv;
38648         this_arg_conv.inner = (void*)(this_arg & (~1));
38649         this_arg_conv.is_owned = false;
38650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38651         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
38652         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
38653         return (uint32_t)ret_ret;
38654 }
38655
38656 uint32_t  __attribute__((export_name("TS_P2PGossipSync_as_MessageSendEventsProvider"))) TS_P2PGossipSync_as_MessageSendEventsProvider(uint32_t this_arg) {
38657         LDKP2PGossipSync this_arg_conv;
38658         this_arg_conv.inner = (void*)(this_arg & (~1));
38659         this_arg_conv.is_owned = false;
38660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38661         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
38662         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
38663         return (uint32_t)ret_ret;
38664 }
38665
38666 void  __attribute__((export_name("TS_ChannelUpdateInfo_free"))) TS_ChannelUpdateInfo_free(uint32_t this_obj) {
38667         LDKChannelUpdateInfo this_obj_conv;
38668         this_obj_conv.inner = (void*)(this_obj & (~1));
38669         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38671         ChannelUpdateInfo_free(this_obj_conv);
38672 }
38673
38674 int32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update"))) TS_ChannelUpdateInfo_get_last_update(uint32_t this_ptr) {
38675         LDKChannelUpdateInfo this_ptr_conv;
38676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38677         this_ptr_conv.is_owned = false;
38678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38679         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
38680         return ret_conv;
38681 }
38682
38683 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update"))) TS_ChannelUpdateInfo_set_last_update(uint32_t this_ptr, int32_t val) {
38684         LDKChannelUpdateInfo this_ptr_conv;
38685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38686         this_ptr_conv.is_owned = false;
38687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38688         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
38689 }
38690
38691 jboolean  __attribute__((export_name("TS_ChannelUpdateInfo_get_enabled"))) TS_ChannelUpdateInfo_get_enabled(uint32_t this_ptr) {
38692         LDKChannelUpdateInfo this_ptr_conv;
38693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38694         this_ptr_conv.is_owned = false;
38695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38696         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
38697         return ret_conv;
38698 }
38699
38700 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_enabled"))) TS_ChannelUpdateInfo_set_enabled(uint32_t this_ptr, jboolean val) {
38701         LDKChannelUpdateInfo this_ptr_conv;
38702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38703         this_ptr_conv.is_owned = false;
38704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38705         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
38706 }
38707
38708 int16_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_cltv_expiry_delta"))) TS_ChannelUpdateInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
38709         LDKChannelUpdateInfo this_ptr_conv;
38710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38711         this_ptr_conv.is_owned = false;
38712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38713         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
38714         return ret_conv;
38715 }
38716
38717 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_cltv_expiry_delta"))) TS_ChannelUpdateInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
38718         LDKChannelUpdateInfo this_ptr_conv;
38719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38720         this_ptr_conv.is_owned = false;
38721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38722         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
38723 }
38724
38725 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_minimum_msat"))) TS_ChannelUpdateInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
38726         LDKChannelUpdateInfo this_ptr_conv;
38727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38728         this_ptr_conv.is_owned = false;
38729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38730         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
38731         return ret_conv;
38732 }
38733
38734 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_minimum_msat"))) TS_ChannelUpdateInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
38735         LDKChannelUpdateInfo this_ptr_conv;
38736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38737         this_ptr_conv.is_owned = false;
38738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38739         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
38740 }
38741
38742 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_maximum_msat"))) TS_ChannelUpdateInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
38743         LDKChannelUpdateInfo this_ptr_conv;
38744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38745         this_ptr_conv.is_owned = false;
38746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38747         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38748         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
38749         uint32_t ret_ref = (uintptr_t)ret_copy;
38750         return ret_ref;
38751 }
38752
38753 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_maximum_msat"))) TS_ChannelUpdateInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
38754         LDKChannelUpdateInfo this_ptr_conv;
38755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38756         this_ptr_conv.is_owned = false;
38757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38758         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38759         CHECK_ACCESS(val_ptr);
38760         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38761         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38762         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
38763 }
38764
38765 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_fees"))) TS_ChannelUpdateInfo_get_fees(uint32_t this_ptr) {
38766         LDKChannelUpdateInfo this_ptr_conv;
38767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38768         this_ptr_conv.is_owned = false;
38769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38770         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
38771         uint32_t ret_ref = 0;
38772         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38773         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38775         ret_ref = (uintptr_t)ret_var.inner;
38776         if (ret_var.is_owned) {
38777                 ret_ref |= 1;
38778         }
38779         return ret_ref;
38780 }
38781
38782 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_fees"))) TS_ChannelUpdateInfo_set_fees(uint32_t this_ptr, uint32_t val) {
38783         LDKChannelUpdateInfo this_ptr_conv;
38784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38785         this_ptr_conv.is_owned = false;
38786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38787         LDKRoutingFees val_conv;
38788         val_conv.inner = (void*)(val & (~1));
38789         val_conv.is_owned = (val & 1) || (val == 0);
38790         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38791         val_conv = RoutingFees_clone(&val_conv);
38792         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
38793 }
38794
38795 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update_message"))) TS_ChannelUpdateInfo_get_last_update_message(uint32_t this_ptr) {
38796         LDKChannelUpdateInfo this_ptr_conv;
38797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38798         this_ptr_conv.is_owned = false;
38799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38800         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
38801         uint32_t ret_ref = 0;
38802         if ((uintptr_t)ret_var.inner > 4096) {
38803                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38804                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38806                 ret_ref = (uintptr_t)ret_var.inner;
38807                 if (ret_var.is_owned) {
38808                         ret_ref |= 1;
38809                 }
38810         }
38811         return ret_ref;
38812 }
38813
38814 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update_message"))) TS_ChannelUpdateInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
38815         LDKChannelUpdateInfo this_ptr_conv;
38816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38817         this_ptr_conv.is_owned = false;
38818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38819         LDKChannelUpdate val_conv;
38820         val_conv.inner = (void*)(val & (~1));
38821         val_conv.is_owned = (val & 1) || (val == 0);
38822         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38823         val_conv = ChannelUpdate_clone(&val_conv);
38824         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
38825 }
38826
38827 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) {
38828         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
38829         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
38830         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
38831         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
38832         LDKRoutingFees fees_arg_conv;
38833         fees_arg_conv.inner = (void*)(fees_arg & (~1));
38834         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
38835         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
38836         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
38837         LDKChannelUpdate last_update_message_arg_conv;
38838         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
38839         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
38840         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
38841         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
38842         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);
38843         uint32_t ret_ref = 0;
38844         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38845         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38847         ret_ref = (uintptr_t)ret_var.inner;
38848         if (ret_var.is_owned) {
38849                 ret_ref |= 1;
38850         }
38851         return ret_ref;
38852 }
38853
38854 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
38855         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
38856 uint32_t ret_ref = 0;
38857 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38858 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38859 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38860 ret_ref = (uintptr_t)ret_var.inner;
38861 if (ret_var.is_owned) {
38862         ret_ref |= 1;
38863 }
38864         return ret_ref;
38865 }
38866 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone_ptr"))) TS_ChannelUpdateInfo_clone_ptr(uint32_t arg) {
38867         LDKChannelUpdateInfo arg_conv;
38868         arg_conv.inner = (void*)(arg & (~1));
38869         arg_conv.is_owned = false;
38870         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38871         uint32_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
38872         return ret_conv;
38873 }
38874
38875 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone"))) TS_ChannelUpdateInfo_clone(uint32_t orig) {
38876         LDKChannelUpdateInfo orig_conv;
38877         orig_conv.inner = (void*)(orig & (~1));
38878         orig_conv.is_owned = false;
38879         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38880         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
38881         uint32_t ret_ref = 0;
38882         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38883         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38885         ret_ref = (uintptr_t)ret_var.inner;
38886         if (ret_var.is_owned) {
38887                 ret_ref |= 1;
38888         }
38889         return ret_ref;
38890 }
38891
38892 int8_tArray  __attribute__((export_name("TS_ChannelUpdateInfo_write"))) TS_ChannelUpdateInfo_write(uint32_t obj) {
38893         LDKChannelUpdateInfo obj_conv;
38894         obj_conv.inner = (void*)(obj & (~1));
38895         obj_conv.is_owned = false;
38896         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38897         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
38898         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38899         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38900         CVec_u8Z_free(ret_var);
38901         return ret_arr;
38902 }
38903
38904 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_read"))) TS_ChannelUpdateInfo_read(int8_tArray ser) {
38905         LDKu8slice ser_ref;
38906         ser_ref.datalen = ser->arr_len;
38907         ser_ref.data = ser->elems;
38908         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
38909         *ret_conv = ChannelUpdateInfo_read(ser_ref);
38910         FREE(ser);
38911         return (uint32_t)ret_conv;
38912 }
38913
38914 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint32_t this_obj) {
38915         LDKChannelInfo this_obj_conv;
38916         this_obj_conv.inner = (void*)(this_obj & (~1));
38917         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38919         ChannelInfo_free(this_obj_conv);
38920 }
38921
38922 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
38923         LDKChannelInfo this_ptr_conv;
38924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38925         this_ptr_conv.is_owned = false;
38926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38927         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
38928         uint32_t ret_ref = 0;
38929         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38930         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38932         ret_ref = (uintptr_t)ret_var.inner;
38933         if (ret_var.is_owned) {
38934                 ret_ref |= 1;
38935         }
38936         return ret_ref;
38937 }
38938
38939 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
38940         LDKChannelInfo this_ptr_conv;
38941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38942         this_ptr_conv.is_owned = false;
38943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38944         LDKChannelFeatures val_conv;
38945         val_conv.inner = (void*)(val & (~1));
38946         val_conv.is_owned = (val & 1) || (val == 0);
38947         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38948         val_conv = ChannelFeatures_clone(&val_conv);
38949         ChannelInfo_set_features(&this_ptr_conv, val_conv);
38950 }
38951
38952 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
38953         LDKChannelInfo this_ptr_conv;
38954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38955         this_ptr_conv.is_owned = false;
38956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38957         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
38958         uint32_t ret_ref = 0;
38959         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38960         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38961         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38962         ret_ref = (uintptr_t)ret_var.inner;
38963         if (ret_var.is_owned) {
38964                 ret_ref |= 1;
38965         }
38966         return ret_ref;
38967 }
38968
38969 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
38970         LDKChannelInfo this_ptr_conv;
38971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38972         this_ptr_conv.is_owned = false;
38973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38974         LDKNodeId val_conv;
38975         val_conv.inner = (void*)(val & (~1));
38976         val_conv.is_owned = (val & 1) || (val == 0);
38977         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38978         val_conv = NodeId_clone(&val_conv);
38979         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
38980 }
38981
38982 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
38983         LDKChannelInfo this_ptr_conv;
38984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38985         this_ptr_conv.is_owned = false;
38986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38987         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
38988         uint32_t ret_ref = 0;
38989         if ((uintptr_t)ret_var.inner > 4096) {
38990                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38991                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38993                 ret_ref = (uintptr_t)ret_var.inner;
38994                 if (ret_var.is_owned) {
38995                         ret_ref |= 1;
38996                 }
38997         }
38998         return ret_ref;
38999 }
39000
39001 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
39002         LDKChannelInfo this_ptr_conv;
39003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39004         this_ptr_conv.is_owned = false;
39005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39006         LDKChannelUpdateInfo val_conv;
39007         val_conv.inner = (void*)(val & (~1));
39008         val_conv.is_owned = (val & 1) || (val == 0);
39009         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39010         val_conv = ChannelUpdateInfo_clone(&val_conv);
39011         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
39012 }
39013
39014 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
39015         LDKChannelInfo this_ptr_conv;
39016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39017         this_ptr_conv.is_owned = false;
39018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39019         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
39020         uint32_t ret_ref = 0;
39021         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39022         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39024         ret_ref = (uintptr_t)ret_var.inner;
39025         if (ret_var.is_owned) {
39026                 ret_ref |= 1;
39027         }
39028         return ret_ref;
39029 }
39030
39031 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
39032         LDKChannelInfo this_ptr_conv;
39033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39034         this_ptr_conv.is_owned = false;
39035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39036         LDKNodeId val_conv;
39037         val_conv.inner = (void*)(val & (~1));
39038         val_conv.is_owned = (val & 1) || (val == 0);
39039         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39040         val_conv = NodeId_clone(&val_conv);
39041         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
39042 }
39043
39044 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
39045         LDKChannelInfo this_ptr_conv;
39046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39047         this_ptr_conv.is_owned = false;
39048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39049         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
39050         uint32_t ret_ref = 0;
39051         if ((uintptr_t)ret_var.inner > 4096) {
39052                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39053                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39055                 ret_ref = (uintptr_t)ret_var.inner;
39056                 if (ret_var.is_owned) {
39057                         ret_ref |= 1;
39058                 }
39059         }
39060         return ret_ref;
39061 }
39062
39063 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
39064         LDKChannelInfo this_ptr_conv;
39065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39066         this_ptr_conv.is_owned = false;
39067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39068         LDKChannelUpdateInfo val_conv;
39069         val_conv.inner = (void*)(val & (~1));
39070         val_conv.is_owned = (val & 1) || (val == 0);
39071         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39072         val_conv = ChannelUpdateInfo_clone(&val_conv);
39073         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
39074 }
39075
39076 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
39077         LDKChannelInfo this_ptr_conv;
39078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39079         this_ptr_conv.is_owned = false;
39080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39081         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39082         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
39083         uint32_t ret_ref = (uintptr_t)ret_copy;
39084         return ret_ref;
39085 }
39086
39087 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
39088         LDKChannelInfo this_ptr_conv;
39089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39090         this_ptr_conv.is_owned = false;
39091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39092         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
39093         CHECK_ACCESS(val_ptr);
39094         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
39095         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
39096         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
39097 }
39098
39099 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
39100         LDKChannelInfo this_ptr_conv;
39101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39102         this_ptr_conv.is_owned = false;
39103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39104         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
39105         uint32_t ret_ref = 0;
39106         if ((uintptr_t)ret_var.inner > 4096) {
39107                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39108                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39110                 ret_ref = (uintptr_t)ret_var.inner;
39111                 if (ret_var.is_owned) {
39112                         ret_ref |= 1;
39113                 }
39114         }
39115         return ret_ref;
39116 }
39117
39118 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
39119         LDKChannelInfo this_ptr_conv;
39120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39121         this_ptr_conv.is_owned = false;
39122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39123         LDKChannelAnnouncement val_conv;
39124         val_conv.inner = (void*)(val & (~1));
39125         val_conv.is_owned = (val & 1) || (val == 0);
39126         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39127         val_conv = ChannelAnnouncement_clone(&val_conv);
39128         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
39129 }
39130
39131 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
39132         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
39133 uint32_t ret_ref = 0;
39134 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39135 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39136 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39137 ret_ref = (uintptr_t)ret_var.inner;
39138 if (ret_var.is_owned) {
39139         ret_ref |= 1;
39140 }
39141         return ret_ref;
39142 }
39143 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
39144         LDKChannelInfo arg_conv;
39145         arg_conv.inner = (void*)(arg & (~1));
39146         arg_conv.is_owned = false;
39147         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39148         uint32_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
39149         return ret_conv;
39150 }
39151
39152 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint32_t orig) {
39153         LDKChannelInfo orig_conv;
39154         orig_conv.inner = (void*)(orig & (~1));
39155         orig_conv.is_owned = false;
39156         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39157         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
39158         uint32_t ret_ref = 0;
39159         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39160         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39162         ret_ref = (uintptr_t)ret_var.inner;
39163         if (ret_var.is_owned) {
39164                 ret_ref |= 1;
39165         }
39166         return ret_ref;
39167 }
39168
39169 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_directional_info"))) TS_ChannelInfo_get_directional_info(uint32_t this_arg, int8_t channel_flags) {
39170         LDKChannelInfo this_arg_conv;
39171         this_arg_conv.inner = (void*)(this_arg & (~1));
39172         this_arg_conv.is_owned = false;
39173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39174         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
39175         uint32_t ret_ref = 0;
39176         if ((uintptr_t)ret_var.inner > 4096) {
39177                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39178                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39180                 ret_ref = (uintptr_t)ret_var.inner;
39181                 if (ret_var.is_owned) {
39182                         ret_ref |= 1;
39183                 }
39184         }
39185         return ret_ref;
39186 }
39187
39188 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint32_t obj) {
39189         LDKChannelInfo obj_conv;
39190         obj_conv.inner = (void*)(obj & (~1));
39191         obj_conv.is_owned = false;
39192         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39193         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
39194         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39195         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39196         CVec_u8Z_free(ret_var);
39197         return ret_arr;
39198 }
39199
39200 uint32_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
39201         LDKu8slice ser_ref;
39202         ser_ref.datalen = ser->arr_len;
39203         ser_ref.data = ser->elems;
39204         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
39205         *ret_conv = ChannelInfo_read(ser_ref);
39206         FREE(ser);
39207         return (uint32_t)ret_conv;
39208 }
39209
39210 void  __attribute__((export_name("TS_DirectedChannelInfo_free"))) TS_DirectedChannelInfo_free(uint32_t this_obj) {
39211         LDKDirectedChannelInfo this_obj_conv;
39212         this_obj_conv.inner = (void*)(this_obj & (~1));
39213         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39215         DirectedChannelInfo_free(this_obj_conv);
39216 }
39217
39218 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
39219         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
39220 uint32_t ret_ref = 0;
39221 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39222 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39223 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39224 ret_ref = (uintptr_t)ret_var.inner;
39225 if (ret_var.is_owned) {
39226         ret_ref |= 1;
39227 }
39228         return ret_ref;
39229 }
39230 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone_ptr"))) TS_DirectedChannelInfo_clone_ptr(uint32_t arg) {
39231         LDKDirectedChannelInfo arg_conv;
39232         arg_conv.inner = (void*)(arg & (~1));
39233         arg_conv.is_owned = false;
39234         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39235         uint32_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
39236         return ret_conv;
39237 }
39238
39239 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone"))) TS_DirectedChannelInfo_clone(uint32_t orig) {
39240         LDKDirectedChannelInfo orig_conv;
39241         orig_conv.inner = (void*)(orig & (~1));
39242         orig_conv.is_owned = false;
39243         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39244         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
39245         uint32_t ret_ref = 0;
39246         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39247         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39249         ret_ref = (uintptr_t)ret_var.inner;
39250         if (ret_var.is_owned) {
39251                 ret_ref |= 1;
39252         }
39253         return ret_ref;
39254 }
39255
39256 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_channel"))) TS_DirectedChannelInfo_channel(uint32_t this_arg) {
39257         LDKDirectedChannelInfo this_arg_conv;
39258         this_arg_conv.inner = (void*)(this_arg & (~1));
39259         this_arg_conv.is_owned = false;
39260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39261         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
39262         uint32_t ret_ref = 0;
39263         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39264         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39266         ret_ref = (uintptr_t)ret_var.inner;
39267         if (ret_var.is_owned) {
39268                 ret_ref |= 1;
39269         }
39270         return ret_ref;
39271 }
39272
39273 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_direction"))) TS_DirectedChannelInfo_direction(uint32_t this_arg) {
39274         LDKDirectedChannelInfo this_arg_conv;
39275         this_arg_conv.inner = (void*)(this_arg & (~1));
39276         this_arg_conv.is_owned = false;
39277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39278         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
39279         uint32_t ret_ref = 0;
39280         if ((uintptr_t)ret_var.inner > 4096) {
39281                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39282                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39284                 ret_ref = (uintptr_t)ret_var.inner;
39285                 if (ret_var.is_owned) {
39286                         ret_ref |= 1;
39287                 }
39288         }
39289         return ret_ref;
39290 }
39291
39292 int64_t  __attribute__((export_name("TS_DirectedChannelInfo_htlc_maximum_msat"))) TS_DirectedChannelInfo_htlc_maximum_msat(uint32_t this_arg) {
39293         LDKDirectedChannelInfo this_arg_conv;
39294         this_arg_conv.inner = (void*)(this_arg & (~1));
39295         this_arg_conv.is_owned = false;
39296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39297         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
39298         return ret_conv;
39299 }
39300
39301 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_effective_capacity"))) TS_DirectedChannelInfo_effective_capacity(uint32_t this_arg) {
39302         LDKDirectedChannelInfo this_arg_conv;
39303         this_arg_conv.inner = (void*)(this_arg & (~1));
39304         this_arg_conv.is_owned = false;
39305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39306         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39307         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
39308         uint32_t ret_ref = (uintptr_t)ret_copy;
39309         return ret_ref;
39310 }
39311
39312 void  __attribute__((export_name("TS_EffectiveCapacity_free"))) TS_EffectiveCapacity_free(uint32_t this_ptr) {
39313         if ((this_ptr & 1) != 0) return;
39314         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39315         CHECK_ACCESS(this_ptr_ptr);
39316         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
39317         FREE((void*)this_ptr);
39318         EffectiveCapacity_free(this_ptr_conv);
39319 }
39320
39321 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
39322         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39323         *ret_copy = EffectiveCapacity_clone(arg);
39324 uint32_t ret_ref = (uintptr_t)ret_copy;
39325         return ret_ref;
39326 }
39327 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone_ptr"))) TS_EffectiveCapacity_clone_ptr(uint32_t arg) {
39328         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
39329         uint32_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
39330         return ret_conv;
39331 }
39332
39333 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone"))) TS_EffectiveCapacity_clone(uint32_t orig) {
39334         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
39335         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39336         *ret_copy = EffectiveCapacity_clone(orig_conv);
39337         uint32_t ret_ref = (uintptr_t)ret_copy;
39338         return ret_ref;
39339 }
39340
39341 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_exact_liquidity"))) TS_EffectiveCapacity_exact_liquidity(int64_t liquidity_msat) {
39342         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39343         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
39344         uint32_t ret_ref = (uintptr_t)ret_copy;
39345         return ret_ref;
39346 }
39347
39348 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_maximum_htlc"))) TS_EffectiveCapacity_maximum_htlc(int64_t amount_msat) {
39349         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39350         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
39351         uint32_t ret_ref = (uintptr_t)ret_copy;
39352         return ret_ref;
39353 }
39354
39355 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_total"))) TS_EffectiveCapacity_total(int64_t capacity_msat, uint32_t htlc_maximum_msat) {
39356         void* htlc_maximum_msat_ptr = (void*)(((uintptr_t)htlc_maximum_msat) & ~1);
39357         CHECK_ACCESS(htlc_maximum_msat_ptr);
39358         LDKCOption_u64Z htlc_maximum_msat_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_ptr);
39359         htlc_maximum_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat) & ~1));
39360         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39361         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat_conv);
39362         uint32_t ret_ref = (uintptr_t)ret_copy;
39363         return ret_ref;
39364 }
39365
39366 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_infinite"))) TS_EffectiveCapacity_infinite() {
39367         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39368         *ret_copy = EffectiveCapacity_infinite();
39369         uint32_t ret_ref = (uintptr_t)ret_copy;
39370         return ret_ref;
39371 }
39372
39373 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_unknown"))) TS_EffectiveCapacity_unknown() {
39374         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
39375         *ret_copy = EffectiveCapacity_unknown();
39376         uint32_t ret_ref = (uintptr_t)ret_copy;
39377         return ret_ref;
39378 }
39379
39380 int64_t  __attribute__((export_name("TS_EffectiveCapacity_as_msat"))) TS_EffectiveCapacity_as_msat(uint32_t this_arg) {
39381         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
39382         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
39383         return ret_conv;
39384 }
39385
39386 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint32_t this_obj) {
39387         LDKRoutingFees this_obj_conv;
39388         this_obj_conv.inner = (void*)(this_obj & (~1));
39389         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39391         RoutingFees_free(this_obj_conv);
39392 }
39393
39394 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
39395         LDKRoutingFees this_ptr_conv;
39396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39397         this_ptr_conv.is_owned = false;
39398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39399         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
39400         return ret_conv;
39401 }
39402
39403 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
39404         LDKRoutingFees this_ptr_conv;
39405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39406         this_ptr_conv.is_owned = false;
39407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39408         RoutingFees_set_base_msat(&this_ptr_conv, val);
39409 }
39410
39411 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
39412         LDKRoutingFees this_ptr_conv;
39413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39414         this_ptr_conv.is_owned = false;
39415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39416         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
39417         return ret_conv;
39418 }
39419
39420 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
39421         LDKRoutingFees this_ptr_conv;
39422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39423         this_ptr_conv.is_owned = false;
39424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39425         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
39426 }
39427
39428 uint32_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
39429         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
39430         uint32_t ret_ref = 0;
39431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39434         ret_ref = (uintptr_t)ret_var.inner;
39435         if (ret_var.is_owned) {
39436                 ret_ref |= 1;
39437         }
39438         return ret_ref;
39439 }
39440
39441 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
39442         LDKRoutingFees a_conv;
39443         a_conv.inner = (void*)(a & (~1));
39444         a_conv.is_owned = false;
39445         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39446         LDKRoutingFees b_conv;
39447         b_conv.inner = (void*)(b & (~1));
39448         b_conv.is_owned = false;
39449         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39450         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
39451         return ret_conv;
39452 }
39453
39454 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
39455         LDKRoutingFees ret_var = RoutingFees_clone(arg);
39456 uint32_t ret_ref = 0;
39457 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39458 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39459 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39460 ret_ref = (uintptr_t)ret_var.inner;
39461 if (ret_var.is_owned) {
39462         ret_ref |= 1;
39463 }
39464         return ret_ref;
39465 }
39466 uint32_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
39467         LDKRoutingFees arg_conv;
39468         arg_conv.inner = (void*)(arg & (~1));
39469         arg_conv.is_owned = false;
39470         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39471         uint32_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
39472         return ret_conv;
39473 }
39474
39475 uint32_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint32_t orig) {
39476         LDKRoutingFees orig_conv;
39477         orig_conv.inner = (void*)(orig & (~1));
39478         orig_conv.is_owned = false;
39479         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39480         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
39481         uint32_t ret_ref = 0;
39482         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39483         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39485         ret_ref = (uintptr_t)ret_var.inner;
39486         if (ret_var.is_owned) {
39487                 ret_ref |= 1;
39488         }
39489         return ret_ref;
39490 }
39491
39492 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint32_t o) {
39493         LDKRoutingFees o_conv;
39494         o_conv.inner = (void*)(o & (~1));
39495         o_conv.is_owned = false;
39496         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39497         int64_t ret_conv = RoutingFees_hash(&o_conv);
39498         return ret_conv;
39499 }
39500
39501 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint32_t obj) {
39502         LDKRoutingFees obj_conv;
39503         obj_conv.inner = (void*)(obj & (~1));
39504         obj_conv.is_owned = false;
39505         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39506         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
39507         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39508         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39509         CVec_u8Z_free(ret_var);
39510         return ret_arr;
39511 }
39512
39513 uint32_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
39514         LDKu8slice ser_ref;
39515         ser_ref.datalen = ser->arr_len;
39516         ser_ref.data = ser->elems;
39517         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
39518         *ret_conv = RoutingFees_read(ser_ref);
39519         FREE(ser);
39520         return (uint32_t)ret_conv;
39521 }
39522
39523 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
39524         LDKNodeAnnouncementInfo this_obj_conv;
39525         this_obj_conv.inner = (void*)(this_obj & (~1));
39526         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39528         NodeAnnouncementInfo_free(this_obj_conv);
39529 }
39530
39531 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
39532         LDKNodeAnnouncementInfo this_ptr_conv;
39533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39534         this_ptr_conv.is_owned = false;
39535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39536         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
39537         uint32_t ret_ref = 0;
39538         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39539         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39541         ret_ref = (uintptr_t)ret_var.inner;
39542         if (ret_var.is_owned) {
39543                 ret_ref |= 1;
39544         }
39545         return ret_ref;
39546 }
39547
39548 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
39549         LDKNodeAnnouncementInfo this_ptr_conv;
39550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39551         this_ptr_conv.is_owned = false;
39552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39553         LDKNodeFeatures val_conv;
39554         val_conv.inner = (void*)(val & (~1));
39555         val_conv.is_owned = (val & 1) || (val == 0);
39556         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39557         val_conv = NodeFeatures_clone(&val_conv);
39558         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
39559 }
39560
39561 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
39562         LDKNodeAnnouncementInfo this_ptr_conv;
39563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39564         this_ptr_conv.is_owned = false;
39565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39566         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
39567         return ret_conv;
39568 }
39569
39570 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
39571         LDKNodeAnnouncementInfo this_ptr_conv;
39572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39573         this_ptr_conv.is_owned = false;
39574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39575         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
39576 }
39577
39578 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
39579         LDKNodeAnnouncementInfo this_ptr_conv;
39580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39581         this_ptr_conv.is_owned = false;
39582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39583         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
39584         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
39585         return ret_arr;
39586 }
39587
39588 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
39589         LDKNodeAnnouncementInfo this_ptr_conv;
39590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39591         this_ptr_conv.is_owned = false;
39592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39593         LDKThreeBytes val_ref;
39594         CHECK(val->arr_len == 3);
39595         memcpy(val_ref.data, val->elems, 3); FREE(val);
39596         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
39597 }
39598
39599 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
39600         LDKNodeAnnouncementInfo this_ptr_conv;
39601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39602         this_ptr_conv.is_owned = false;
39603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39604         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
39605         uint32_t ret_ref = 0;
39606         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39607         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39609         ret_ref = (uintptr_t)ret_var.inner;
39610         if (ret_var.is_owned) {
39611                 ret_ref |= 1;
39612         }
39613         return ret_ref;
39614 }
39615
39616 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, uint32_t val) {
39617         LDKNodeAnnouncementInfo this_ptr_conv;
39618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39619         this_ptr_conv.is_owned = false;
39620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39621         LDKNodeAlias val_conv;
39622         val_conv.inner = (void*)(val & (~1));
39623         val_conv.is_owned = (val & 1) || (val == 0);
39624         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39625         val_conv = NodeAlias_clone(&val_conv);
39626         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
39627 }
39628
39629 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
39630         LDKNodeAnnouncementInfo this_ptr_conv;
39631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39632         this_ptr_conv.is_owned = false;
39633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39634         LDKCVec_NetAddressZ val_constr;
39635         val_constr.datalen = val->arr_len;
39636         if (val_constr.datalen > 0)
39637                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
39638         else
39639                 val_constr.data = NULL;
39640         uint32_t* val_vals = val->elems;
39641         for (size_t m = 0; m < val_constr.datalen; m++) {
39642                 uint32_t val_conv_12 = val_vals[m];
39643                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
39644                 CHECK_ACCESS(val_conv_12_ptr);
39645                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
39646                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
39647                 val_constr.data[m] = val_conv_12_conv;
39648         }
39649         FREE(val);
39650         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
39651 }
39652
39653 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
39654         LDKNodeAnnouncementInfo this_ptr_conv;
39655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39656         this_ptr_conv.is_owned = false;
39657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39658         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
39659         uint32_t ret_ref = 0;
39660         if ((uintptr_t)ret_var.inner > 4096) {
39661                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39662                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39664                 ret_ref = (uintptr_t)ret_var.inner;
39665                 if (ret_var.is_owned) {
39666                         ret_ref |= 1;
39667                 }
39668         }
39669         return ret_ref;
39670 }
39671
39672 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
39673         LDKNodeAnnouncementInfo this_ptr_conv;
39674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39675         this_ptr_conv.is_owned = false;
39676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39677         LDKNodeAnnouncement val_conv;
39678         val_conv.inner = (void*)(val & (~1));
39679         val_conv.is_owned = (val & 1) || (val == 0);
39680         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39681         val_conv = NodeAnnouncement_clone(&val_conv);
39682         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
39683 }
39684
39685 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) {
39686         LDKNodeFeatures features_arg_conv;
39687         features_arg_conv.inner = (void*)(features_arg & (~1));
39688         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
39689         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
39690         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
39691         LDKThreeBytes rgb_arg_ref;
39692         CHECK(rgb_arg->arr_len == 3);
39693         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
39694         LDKNodeAlias alias_arg_conv;
39695         alias_arg_conv.inner = (void*)(alias_arg & (~1));
39696         alias_arg_conv.is_owned = (alias_arg & 1) || (alias_arg == 0);
39697         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
39698         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
39699         LDKCVec_NetAddressZ addresses_arg_constr;
39700         addresses_arg_constr.datalen = addresses_arg->arr_len;
39701         if (addresses_arg_constr.datalen > 0)
39702                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
39703         else
39704                 addresses_arg_constr.data = NULL;
39705         uint32_t* addresses_arg_vals = addresses_arg->elems;
39706         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
39707                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
39708                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
39709                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
39710                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
39711                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
39712         }
39713         FREE(addresses_arg);
39714         LDKNodeAnnouncement announcement_message_arg_conv;
39715         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
39716         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
39717         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
39718         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
39719         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
39720         uint32_t ret_ref = 0;
39721         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39722         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39724         ret_ref = (uintptr_t)ret_var.inner;
39725         if (ret_var.is_owned) {
39726                 ret_ref |= 1;
39727         }
39728         return ret_ref;
39729 }
39730
39731 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
39732         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
39733 uint32_t ret_ref = 0;
39734 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39735 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39736 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39737 ret_ref = (uintptr_t)ret_var.inner;
39738 if (ret_var.is_owned) {
39739         ret_ref |= 1;
39740 }
39741         return ret_ref;
39742 }
39743 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
39744         LDKNodeAnnouncementInfo arg_conv;
39745         arg_conv.inner = (void*)(arg & (~1));
39746         arg_conv.is_owned = false;
39747         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39748         uint32_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
39749         return ret_conv;
39750 }
39751
39752 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
39753         LDKNodeAnnouncementInfo orig_conv;
39754         orig_conv.inner = (void*)(orig & (~1));
39755         orig_conv.is_owned = false;
39756         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39757         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
39758         uint32_t ret_ref = 0;
39759         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39760         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39762         ret_ref = (uintptr_t)ret_var.inner;
39763         if (ret_var.is_owned) {
39764                 ret_ref |= 1;
39765         }
39766         return ret_ref;
39767 }
39768
39769 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
39770         LDKNodeAnnouncementInfo obj_conv;
39771         obj_conv.inner = (void*)(obj & (~1));
39772         obj_conv.is_owned = false;
39773         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39774         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
39775         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39776         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39777         CVec_u8Z_free(ret_var);
39778         return ret_arr;
39779 }
39780
39781 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
39782         LDKu8slice ser_ref;
39783         ser_ref.datalen = ser->arr_len;
39784         ser_ref.data = ser->elems;
39785         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
39786         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
39787         FREE(ser);
39788         return (uint32_t)ret_conv;
39789 }
39790
39791 void  __attribute__((export_name("TS_NodeAlias_free"))) TS_NodeAlias_free(uint32_t this_obj) {
39792         LDKNodeAlias this_obj_conv;
39793         this_obj_conv.inner = (void*)(this_obj & (~1));
39794         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39796         NodeAlias_free(this_obj_conv);
39797 }
39798
39799 int8_tArray  __attribute__((export_name("TS_NodeAlias_get_a"))) TS_NodeAlias_get_a(uint32_t this_ptr) {
39800         LDKNodeAlias this_ptr_conv;
39801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39802         this_ptr_conv.is_owned = false;
39803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39804         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
39805         memcpy(ret_arr->elems, *NodeAlias_get_a(&this_ptr_conv), 32);
39806         return ret_arr;
39807 }
39808
39809 void  __attribute__((export_name("TS_NodeAlias_set_a"))) TS_NodeAlias_set_a(uint32_t this_ptr, int8_tArray val) {
39810         LDKNodeAlias this_ptr_conv;
39811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39812         this_ptr_conv.is_owned = false;
39813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39814         LDKThirtyTwoBytes val_ref;
39815         CHECK(val->arr_len == 32);
39816         memcpy(val_ref.data, val->elems, 32); FREE(val);
39817         NodeAlias_set_a(&this_ptr_conv, val_ref);
39818 }
39819
39820 uint32_t  __attribute__((export_name("TS_NodeAlias_new"))) TS_NodeAlias_new(int8_tArray a_arg) {
39821         LDKThirtyTwoBytes a_arg_ref;
39822         CHECK(a_arg->arr_len == 32);
39823         memcpy(a_arg_ref.data, a_arg->elems, 32); FREE(a_arg);
39824         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
39825         uint32_t ret_ref = 0;
39826         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39827         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39829         ret_ref = (uintptr_t)ret_var.inner;
39830         if (ret_var.is_owned) {
39831                 ret_ref |= 1;
39832         }
39833         return ret_ref;
39834 }
39835
39836 static inline uintptr_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
39837         LDKNodeAlias ret_var = NodeAlias_clone(arg);
39838 uint32_t ret_ref = 0;
39839 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39840 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39841 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39842 ret_ref = (uintptr_t)ret_var.inner;
39843 if (ret_var.is_owned) {
39844         ret_ref |= 1;
39845 }
39846         return ret_ref;
39847 }
39848 uint32_t  __attribute__((export_name("TS_NodeAlias_clone_ptr"))) TS_NodeAlias_clone_ptr(uint32_t arg) {
39849         LDKNodeAlias arg_conv;
39850         arg_conv.inner = (void*)(arg & (~1));
39851         arg_conv.is_owned = false;
39852         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39853         uint32_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
39854         return ret_conv;
39855 }
39856
39857 uint32_t  __attribute__((export_name("TS_NodeAlias_clone"))) TS_NodeAlias_clone(uint32_t orig) {
39858         LDKNodeAlias orig_conv;
39859         orig_conv.inner = (void*)(orig & (~1));
39860         orig_conv.is_owned = false;
39861         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39862         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
39863         uint32_t ret_ref = 0;
39864         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39865         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39867         ret_ref = (uintptr_t)ret_var.inner;
39868         if (ret_var.is_owned) {
39869                 ret_ref |= 1;
39870         }
39871         return ret_ref;
39872 }
39873
39874 int8_tArray  __attribute__((export_name("TS_NodeAlias_write"))) TS_NodeAlias_write(uint32_t obj) {
39875         LDKNodeAlias obj_conv;
39876         obj_conv.inner = (void*)(obj & (~1));
39877         obj_conv.is_owned = false;
39878         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39879         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
39880         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39881         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39882         CVec_u8Z_free(ret_var);
39883         return ret_arr;
39884 }
39885
39886 uint32_t  __attribute__((export_name("TS_NodeAlias_read"))) TS_NodeAlias_read(int8_tArray ser) {
39887         LDKu8slice ser_ref;
39888         ser_ref.datalen = ser->arr_len;
39889         ser_ref.data = ser->elems;
39890         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
39891         *ret_conv = NodeAlias_read(ser_ref);
39892         FREE(ser);
39893         return (uint32_t)ret_conv;
39894 }
39895
39896 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint32_t this_obj) {
39897         LDKNodeInfo this_obj_conv;
39898         this_obj_conv.inner = (void*)(this_obj & (~1));
39899         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39901         NodeInfo_free(this_obj_conv);
39902 }
39903
39904 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
39905         LDKNodeInfo this_ptr_conv;
39906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39907         this_ptr_conv.is_owned = false;
39908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39909         LDKCVec_u64Z val_constr;
39910         val_constr.datalen = val->arr_len;
39911         if (val_constr.datalen > 0)
39912                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39913         else
39914                 val_constr.data = NULL;
39915         int64_t* val_vals = val->elems;
39916         for (size_t i = 0; i < val_constr.datalen; i++) {
39917                 int64_t val_conv_8 = val_vals[i];
39918                 val_constr.data[i] = val_conv_8;
39919         }
39920         FREE(val);
39921         NodeInfo_set_channels(&this_ptr_conv, val_constr);
39922 }
39923
39924 uint32_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
39925         LDKNodeInfo this_ptr_conv;
39926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39927         this_ptr_conv.is_owned = false;
39928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39929         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
39930         uint32_t ret_ref = 0;
39931         if ((uintptr_t)ret_var.inner > 4096) {
39932                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39933                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39935                 ret_ref = (uintptr_t)ret_var.inner;
39936                 if (ret_var.is_owned) {
39937                         ret_ref |= 1;
39938                 }
39939         }
39940         return ret_ref;
39941 }
39942
39943 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) {
39944         LDKNodeInfo this_ptr_conv;
39945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39946         this_ptr_conv.is_owned = false;
39947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39948         LDKRoutingFees val_conv;
39949         val_conv.inner = (void*)(val & (~1));
39950         val_conv.is_owned = (val & 1) || (val == 0);
39951         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39952         val_conv = RoutingFees_clone(&val_conv);
39953         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
39954 }
39955
39956 uint32_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
39957         LDKNodeInfo this_ptr_conv;
39958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39959         this_ptr_conv.is_owned = false;
39960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39961         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
39962         uint32_t ret_ref = 0;
39963         if ((uintptr_t)ret_var.inner > 4096) {
39964                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39965                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39967                 ret_ref = (uintptr_t)ret_var.inner;
39968                 if (ret_var.is_owned) {
39969                         ret_ref |= 1;
39970                 }
39971         }
39972         return ret_ref;
39973 }
39974
39975 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
39976         LDKNodeInfo this_ptr_conv;
39977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39978         this_ptr_conv.is_owned = false;
39979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39980         LDKNodeAnnouncementInfo val_conv;
39981         val_conv.inner = (void*)(val & (~1));
39982         val_conv.is_owned = (val & 1) || (val == 0);
39983         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39984         val_conv = NodeAnnouncementInfo_clone(&val_conv);
39985         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
39986 }
39987
39988 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) {
39989         LDKCVec_u64Z channels_arg_constr;
39990         channels_arg_constr.datalen = channels_arg->arr_len;
39991         if (channels_arg_constr.datalen > 0)
39992                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39993         else
39994                 channels_arg_constr.data = NULL;
39995         int64_t* channels_arg_vals = channels_arg->elems;
39996         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
39997                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
39998                 channels_arg_constr.data[i] = channels_arg_conv_8;
39999         }
40000         FREE(channels_arg);
40001         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
40002         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
40003         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
40004         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
40005         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
40006         LDKNodeAnnouncementInfo announcement_info_arg_conv;
40007         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
40008         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
40009         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
40010         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
40011         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
40012         uint32_t ret_ref = 0;
40013         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40014         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40016         ret_ref = (uintptr_t)ret_var.inner;
40017         if (ret_var.is_owned) {
40018                 ret_ref |= 1;
40019         }
40020         return ret_ref;
40021 }
40022
40023 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
40024         LDKNodeInfo ret_var = NodeInfo_clone(arg);
40025 uint32_t ret_ref = 0;
40026 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40027 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40028 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40029 ret_ref = (uintptr_t)ret_var.inner;
40030 if (ret_var.is_owned) {
40031         ret_ref |= 1;
40032 }
40033         return ret_ref;
40034 }
40035 uint32_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
40036         LDKNodeInfo arg_conv;
40037         arg_conv.inner = (void*)(arg & (~1));
40038         arg_conv.is_owned = false;
40039         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40040         uint32_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
40041         return ret_conv;
40042 }
40043
40044 uint32_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint32_t orig) {
40045         LDKNodeInfo orig_conv;
40046         orig_conv.inner = (void*)(orig & (~1));
40047         orig_conv.is_owned = false;
40048         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40049         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
40050         uint32_t ret_ref = 0;
40051         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40052         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40054         ret_ref = (uintptr_t)ret_var.inner;
40055         if (ret_var.is_owned) {
40056                 ret_ref |= 1;
40057         }
40058         return ret_ref;
40059 }
40060
40061 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint32_t obj) {
40062         LDKNodeInfo obj_conv;
40063         obj_conv.inner = (void*)(obj & (~1));
40064         obj_conv.is_owned = false;
40065         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40066         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
40067         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40068         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40069         CVec_u8Z_free(ret_var);
40070         return ret_arr;
40071 }
40072
40073 uint32_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
40074         LDKu8slice ser_ref;
40075         ser_ref.datalen = ser->arr_len;
40076         ser_ref.data = ser->elems;
40077         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
40078         *ret_conv = NodeInfo_read(ser_ref);
40079         FREE(ser);
40080         return (uint32_t)ret_conv;
40081 }
40082
40083 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint32_t obj) {
40084         LDKNetworkGraph obj_conv;
40085         obj_conv.inner = (void*)(obj & (~1));
40086         obj_conv.is_owned = false;
40087         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40088         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
40089         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40090         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40091         CVec_u8Z_free(ret_var);
40092         return ret_arr;
40093 }
40094
40095 uint32_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser, uint32_t arg) {
40096         LDKu8slice ser_ref;
40097         ser_ref.datalen = ser->arr_len;
40098         ser_ref.data = ser->elems;
40099         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
40100         CHECK_ACCESS(arg_ptr);
40101         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
40102         if (arg_conv.free == LDKLogger_JCalls_free) {
40103                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40104                 LDKLogger_JCalls_cloned(&arg_conv);
40105         }
40106         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
40107         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
40108         FREE(ser);
40109         return (uint32_t)ret_conv;
40110 }
40111
40112 uint32_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash, uint32_t logger) {
40113         LDKThirtyTwoBytes genesis_hash_ref;
40114         CHECK(genesis_hash->arr_len == 32);
40115         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32); FREE(genesis_hash);
40116         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
40117         CHECK_ACCESS(logger_ptr);
40118         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
40119         if (logger_conv.free == LDKLogger_JCalls_free) {
40120                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40121                 LDKLogger_JCalls_cloned(&logger_conv);
40122         }
40123         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
40124         uint32_t ret_ref = 0;
40125         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40126         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40128         ret_ref = (uintptr_t)ret_var.inner;
40129         if (ret_var.is_owned) {
40130                 ret_ref |= 1;
40131         }
40132         return ret_ref;
40133 }
40134
40135 uint32_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
40136         LDKNetworkGraph this_arg_conv;
40137         this_arg_conv.inner = (void*)(this_arg & (~1));
40138         this_arg_conv.is_owned = false;
40139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40140         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
40141         uint32_t ret_ref = 0;
40142         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40143         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40145         ret_ref = (uintptr_t)ret_var.inner;
40146         if (ret_var.is_owned) {
40147                 ret_ref |= 1;
40148         }
40149         return ret_ref;
40150 }
40151
40152 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) {
40153         LDKNetworkGraph this_arg_conv;
40154         this_arg_conv.inner = (void*)(this_arg & (~1));
40155         this_arg_conv.is_owned = false;
40156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40157         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
40158         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
40159         uint32_t ret_ref = (uintptr_t)ret_copy;
40160         return ret_ref;
40161 }
40162
40163 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) {
40164         LDKNetworkGraph this_arg_conv;
40165         this_arg_conv.inner = (void*)(this_arg & (~1));
40166         this_arg_conv.is_owned = false;
40167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40168         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
40169 }
40170
40171 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
40172         LDKNetworkGraph this_arg_conv;
40173         this_arg_conv.inner = (void*)(this_arg & (~1));
40174         this_arg_conv.is_owned = false;
40175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40176         LDKNodeAnnouncement msg_conv;
40177         msg_conv.inner = (void*)(msg & (~1));
40178         msg_conv.is_owned = false;
40179         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40180         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40181         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
40182         return (uint32_t)ret_conv;
40183 }
40184
40185 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) {
40186         LDKNetworkGraph this_arg_conv;
40187         this_arg_conv.inner = (void*)(this_arg & (~1));
40188         this_arg_conv.is_owned = false;
40189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40190         LDKUnsignedNodeAnnouncement msg_conv;
40191         msg_conv.inner = (void*)(msg & (~1));
40192         msg_conv.is_owned = false;
40193         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40194         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40195         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
40196         return (uint32_t)ret_conv;
40197 }
40198
40199 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) {
40200         LDKNetworkGraph this_arg_conv;
40201         this_arg_conv.inner = (void*)(this_arg & (~1));
40202         this_arg_conv.is_owned = false;
40203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40204         LDKChannelAnnouncement msg_conv;
40205         msg_conv.inner = (void*)(msg & (~1));
40206         msg_conv.is_owned = false;
40207         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40208         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
40209         CHECK_ACCESS(chain_access_ptr);
40210         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
40211         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
40212         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
40213                 // Manually implement clone for Java trait instances
40214                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
40215                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40216                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
40217                 }
40218         }
40219         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40220         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
40221         return (uint32_t)ret_conv;
40222 }
40223
40224 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) {
40225         LDKNetworkGraph this_arg_conv;
40226         this_arg_conv.inner = (void*)(this_arg & (~1));
40227         this_arg_conv.is_owned = false;
40228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40229         LDKUnsignedChannelAnnouncement msg_conv;
40230         msg_conv.inner = (void*)(msg & (~1));
40231         msg_conv.is_owned = false;
40232         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40233         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
40234         CHECK_ACCESS(chain_access_ptr);
40235         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
40236         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
40237         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
40238                 // Manually implement clone for Java trait instances
40239                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
40240                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40241                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
40242                 }
40243         }
40244         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40245         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
40246         return (uint32_t)ret_conv;
40247 }
40248
40249 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) {
40250         LDKNetworkGraph this_arg_conv;
40251         this_arg_conv.inner = (void*)(this_arg & (~1));
40252         this_arg_conv.is_owned = false;
40253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40254         LDKChannelFeatures features_conv;
40255         features_conv.inner = (void*)(features & (~1));
40256         features_conv.is_owned = (features & 1) || (features == 0);
40257         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
40258         features_conv = ChannelFeatures_clone(&features_conv);
40259         LDKPublicKey node_id_1_ref;
40260         CHECK(node_id_1->arr_len == 33);
40261         memcpy(node_id_1_ref.compressed_form, node_id_1->elems, 33); FREE(node_id_1);
40262         LDKPublicKey node_id_2_ref;
40263         CHECK(node_id_2->arr_len == 33);
40264         memcpy(node_id_2_ref.compressed_form, node_id_2->elems, 33); FREE(node_id_2);
40265         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40266         *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);
40267         return (uint32_t)ret_conv;
40268 }
40269
40270 void  __attribute__((export_name("TS_NetworkGraph_channel_failed"))) TS_NetworkGraph_channel_failed(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
40271         LDKNetworkGraph this_arg_conv;
40272         this_arg_conv.inner = (void*)(this_arg & (~1));
40273         this_arg_conv.is_owned = false;
40274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40275         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
40276 }
40277
40278 void  __attribute__((export_name("TS_NetworkGraph_node_failed"))) TS_NetworkGraph_node_failed(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
40279         LDKNetworkGraph this_arg_conv;
40280         this_arg_conv.inner = (void*)(this_arg & (~1));
40281         this_arg_conv.is_owned = false;
40282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40283         LDKPublicKey _node_id_ref;
40284         CHECK(_node_id->arr_len == 33);
40285         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33); FREE(_node_id);
40286         NetworkGraph_node_failed(&this_arg_conv, _node_id_ref, is_permanent);
40287 }
40288
40289 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) {
40290         LDKNetworkGraph this_arg_conv;
40291         this_arg_conv.inner = (void*)(this_arg & (~1));
40292         this_arg_conv.is_owned = false;
40293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40294         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
40295 }
40296
40297 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
40298         LDKNetworkGraph this_arg_conv;
40299         this_arg_conv.inner = (void*)(this_arg & (~1));
40300         this_arg_conv.is_owned = false;
40301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40302         LDKChannelUpdate msg_conv;
40303         msg_conv.inner = (void*)(msg & (~1));
40304         msg_conv.is_owned = false;
40305         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40306         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40307         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
40308         return (uint32_t)ret_conv;
40309 }
40310
40311 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
40312         LDKNetworkGraph this_arg_conv;
40313         this_arg_conv.inner = (void*)(this_arg & (~1));
40314         this_arg_conv.is_owned = false;
40315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40316         LDKUnsignedChannelUpdate msg_conv;
40317         msg_conv.inner = (void*)(msg & (~1));
40318         msg_conv.is_owned = false;
40319         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
40320         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
40321         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
40322         return (uint32_t)ret_conv;
40323 }
40324
40325 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
40326         LDKReadOnlyNetworkGraph this_arg_conv;
40327         this_arg_conv.inner = (void*)(this_arg & (~1));
40328         this_arg_conv.is_owned = false;
40329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40330         LDKPublicKey pubkey_ref;
40331         CHECK(pubkey->arr_len == 33);
40332         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
40333         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
40334         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
40335         uint32_t ret_ref = (uintptr_t)ret_copy;
40336         return ret_ref;
40337 }
40338
40339 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint32_t this_obj) {
40340         LDKRouteHop this_obj_conv;
40341         this_obj_conv.inner = (void*)(this_obj & (~1));
40342         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40344         RouteHop_free(this_obj_conv);
40345 }
40346
40347 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
40348         LDKRouteHop this_ptr_conv;
40349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40350         this_ptr_conv.is_owned = false;
40351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40352         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
40353         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
40354         return ret_arr;
40355 }
40356
40357 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
40358         LDKRouteHop this_ptr_conv;
40359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40360         this_ptr_conv.is_owned = false;
40361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40362         LDKPublicKey val_ref;
40363         CHECK(val->arr_len == 33);
40364         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
40365         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
40366 }
40367
40368 uint32_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
40369         LDKRouteHop this_ptr_conv;
40370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40371         this_ptr_conv.is_owned = false;
40372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40373         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
40374         uint32_t ret_ref = 0;
40375         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40376         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40378         ret_ref = (uintptr_t)ret_var.inner;
40379         if (ret_var.is_owned) {
40380                 ret_ref |= 1;
40381         }
40382         return ret_ref;
40383 }
40384
40385 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
40386         LDKRouteHop this_ptr_conv;
40387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40388         this_ptr_conv.is_owned = false;
40389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40390         LDKNodeFeatures val_conv;
40391         val_conv.inner = (void*)(val & (~1));
40392         val_conv.is_owned = (val & 1) || (val == 0);
40393         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40394         val_conv = NodeFeatures_clone(&val_conv);
40395         RouteHop_set_node_features(&this_ptr_conv, val_conv);
40396 }
40397
40398 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
40399         LDKRouteHop this_ptr_conv;
40400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40401         this_ptr_conv.is_owned = false;
40402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40403         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
40404         return ret_conv;
40405 }
40406
40407 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
40408         LDKRouteHop this_ptr_conv;
40409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40410         this_ptr_conv.is_owned = false;
40411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40412         RouteHop_set_short_channel_id(&this_ptr_conv, val);
40413 }
40414
40415 uint32_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
40416         LDKRouteHop this_ptr_conv;
40417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40418         this_ptr_conv.is_owned = false;
40419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40420         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
40421         uint32_t ret_ref = 0;
40422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40425         ret_ref = (uintptr_t)ret_var.inner;
40426         if (ret_var.is_owned) {
40427                 ret_ref |= 1;
40428         }
40429         return ret_ref;
40430 }
40431
40432 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
40433         LDKRouteHop this_ptr_conv;
40434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40435         this_ptr_conv.is_owned = false;
40436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40437         LDKChannelFeatures val_conv;
40438         val_conv.inner = (void*)(val & (~1));
40439         val_conv.is_owned = (val & 1) || (val == 0);
40440         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40441         val_conv = ChannelFeatures_clone(&val_conv);
40442         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
40443 }
40444
40445 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
40446         LDKRouteHop this_ptr_conv;
40447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40448         this_ptr_conv.is_owned = false;
40449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40450         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
40451         return ret_conv;
40452 }
40453
40454 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
40455         LDKRouteHop this_ptr_conv;
40456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40457         this_ptr_conv.is_owned = false;
40458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40459         RouteHop_set_fee_msat(&this_ptr_conv, val);
40460 }
40461
40462 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
40463         LDKRouteHop this_ptr_conv;
40464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40465         this_ptr_conv.is_owned = false;
40466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40467         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
40468         return ret_conv;
40469 }
40470
40471 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
40472         LDKRouteHop this_ptr_conv;
40473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40474         this_ptr_conv.is_owned = false;
40475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40476         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
40477 }
40478
40479 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) {
40480         LDKPublicKey pubkey_arg_ref;
40481         CHECK(pubkey_arg->arr_len == 33);
40482         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
40483         LDKNodeFeatures node_features_arg_conv;
40484         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
40485         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
40486         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
40487         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
40488         LDKChannelFeatures channel_features_arg_conv;
40489         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
40490         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
40491         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
40492         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
40493         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);
40494         uint32_t ret_ref = 0;
40495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40498         ret_ref = (uintptr_t)ret_var.inner;
40499         if (ret_var.is_owned) {
40500                 ret_ref |= 1;
40501         }
40502         return ret_ref;
40503 }
40504
40505 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
40506         LDKRouteHop ret_var = RouteHop_clone(arg);
40507 uint32_t ret_ref = 0;
40508 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40509 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40510 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40511 ret_ref = (uintptr_t)ret_var.inner;
40512 if (ret_var.is_owned) {
40513         ret_ref |= 1;
40514 }
40515         return ret_ref;
40516 }
40517 uint32_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint32_t arg) {
40518         LDKRouteHop arg_conv;
40519         arg_conv.inner = (void*)(arg & (~1));
40520         arg_conv.is_owned = false;
40521         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40522         uint32_t ret_conv = RouteHop_clone_ptr(&arg_conv);
40523         return ret_conv;
40524 }
40525
40526 uint32_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint32_t orig) {
40527         LDKRouteHop orig_conv;
40528         orig_conv.inner = (void*)(orig & (~1));
40529         orig_conv.is_owned = false;
40530         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40531         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
40532         uint32_t ret_ref = 0;
40533         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40534         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40536         ret_ref = (uintptr_t)ret_var.inner;
40537         if (ret_var.is_owned) {
40538                 ret_ref |= 1;
40539         }
40540         return ret_ref;
40541 }
40542
40543 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint32_t o) {
40544         LDKRouteHop o_conv;
40545         o_conv.inner = (void*)(o & (~1));
40546         o_conv.is_owned = false;
40547         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40548         int64_t ret_conv = RouteHop_hash(&o_conv);
40549         return ret_conv;
40550 }
40551
40552 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
40553         LDKRouteHop a_conv;
40554         a_conv.inner = (void*)(a & (~1));
40555         a_conv.is_owned = false;
40556         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40557         LDKRouteHop b_conv;
40558         b_conv.inner = (void*)(b & (~1));
40559         b_conv.is_owned = false;
40560         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40561         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
40562         return ret_conv;
40563 }
40564
40565 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint32_t obj) {
40566         LDKRouteHop obj_conv;
40567         obj_conv.inner = (void*)(obj & (~1));
40568         obj_conv.is_owned = false;
40569         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40570         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
40571         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40572         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40573         CVec_u8Z_free(ret_var);
40574         return ret_arr;
40575 }
40576
40577 uint32_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
40578         LDKu8slice ser_ref;
40579         ser_ref.datalen = ser->arr_len;
40580         ser_ref.data = ser->elems;
40581         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
40582         *ret_conv = RouteHop_read(ser_ref);
40583         FREE(ser);
40584         return (uint32_t)ret_conv;
40585 }
40586
40587 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint32_t this_obj) {
40588         LDKRoute this_obj_conv;
40589         this_obj_conv.inner = (void*)(this_obj & (~1));
40590         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40592         Route_free(this_obj_conv);
40593 }
40594
40595 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint32_t this_ptr) {
40596         LDKRoute this_ptr_conv;
40597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40598         this_ptr_conv.is_owned = false;
40599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40600         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
40601         ptrArray ret_arr = NULL;
40602         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
40603         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(((uint8_t*)ret_arr) + 4);
40604         for (size_t m = 0; m < ret_var.datalen; m++) {
40605                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
40606                 uint32_tArray ret_conv_12_arr = NULL;
40607                 ret_conv_12_arr = init_uint32_tArray(ret_conv_12_var.datalen, __LINE__);
40608                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(((uint8_t*)ret_conv_12_arr) + 4);
40609                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
40610                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
40611                         uint32_t ret_conv_12_conv_10_ref = 0;
40612                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40613                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40614                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
40615                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
40616                         if (ret_conv_12_conv_10_var.is_owned) {
40617                                 ret_conv_12_conv_10_ref |= 1;
40618                         }
40619                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
40620                 }
40621                 
40622                 FREE(ret_conv_12_var.data);
40623                 ret_arr_ptr[m] = ret_conv_12_arr;
40624         }
40625         
40626         FREE(ret_var.data);
40627         return ret_arr;
40628 }
40629
40630 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
40631         LDKRoute this_ptr_conv;
40632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40633         this_ptr_conv.is_owned = false;
40634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40635         LDKCVec_CVec_RouteHopZZ val_constr;
40636         val_constr.datalen = val->arr_len;
40637         if (val_constr.datalen > 0)
40638                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
40639         else
40640                 val_constr.data = NULL;
40641         uint32_tArray* val_vals = (void*) val->elems;
40642         for (size_t m = 0; m < val_constr.datalen; m++) {
40643                 uint32_tArray val_conv_12 = val_vals[m];
40644                 LDKCVec_RouteHopZ val_conv_12_constr;
40645                 val_conv_12_constr.datalen = val_conv_12->arr_len;
40646                 if (val_conv_12_constr.datalen > 0)
40647                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
40648                 else
40649                         val_conv_12_constr.data = NULL;
40650                 uint32_t* val_conv_12_vals = val_conv_12->elems;
40651                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
40652                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
40653                         LDKRouteHop val_conv_12_conv_10_conv;
40654                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
40655                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
40656                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
40657                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
40658                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
40659                 }
40660                 FREE(val_conv_12);
40661                 val_constr.data[m] = val_conv_12_constr;
40662         }
40663         FREE(val);
40664         Route_set_paths(&this_ptr_conv, val_constr);
40665 }
40666
40667 uint32_t  __attribute__((export_name("TS_Route_get_payment_params"))) TS_Route_get_payment_params(uint32_t this_ptr) {
40668         LDKRoute this_ptr_conv;
40669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40670         this_ptr_conv.is_owned = false;
40671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40672         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
40673         uint32_t ret_ref = 0;
40674         if ((uintptr_t)ret_var.inner > 4096) {
40675                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40676                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40678                 ret_ref = (uintptr_t)ret_var.inner;
40679                 if (ret_var.is_owned) {
40680                         ret_ref |= 1;
40681                 }
40682         }
40683         return ret_ref;
40684 }
40685
40686 void  __attribute__((export_name("TS_Route_set_payment_params"))) TS_Route_set_payment_params(uint32_t this_ptr, uint32_t val) {
40687         LDKRoute this_ptr_conv;
40688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40689         this_ptr_conv.is_owned = false;
40690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40691         LDKPaymentParameters val_conv;
40692         val_conv.inner = (void*)(val & (~1));
40693         val_conv.is_owned = (val & 1) || (val == 0);
40694         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40695         val_conv = PaymentParameters_clone(&val_conv);
40696         Route_set_payment_params(&this_ptr_conv, val_conv);
40697 }
40698
40699 uint32_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint32_t payment_params_arg) {
40700         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
40701         paths_arg_constr.datalen = paths_arg->arr_len;
40702         if (paths_arg_constr.datalen > 0)
40703                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
40704         else
40705                 paths_arg_constr.data = NULL;
40706         uint32_tArray* paths_arg_vals = (void*) paths_arg->elems;
40707         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
40708                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
40709                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
40710                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
40711                 if (paths_arg_conv_12_constr.datalen > 0)
40712                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
40713                 else
40714                         paths_arg_conv_12_constr.data = NULL;
40715                 uint32_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems;
40716                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
40717                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
40718                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
40719                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
40720                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
40721                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
40722                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
40723                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
40724                 }
40725                 FREE(paths_arg_conv_12);
40726                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
40727         }
40728         FREE(paths_arg);
40729         LDKPaymentParameters payment_params_arg_conv;
40730         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
40731         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
40732         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
40733         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
40734         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
40735         uint32_t ret_ref = 0;
40736         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40737         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40739         ret_ref = (uintptr_t)ret_var.inner;
40740         if (ret_var.is_owned) {
40741                 ret_ref |= 1;
40742         }
40743         return ret_ref;
40744 }
40745
40746 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
40747         LDKRoute ret_var = Route_clone(arg);
40748 uint32_t ret_ref = 0;
40749 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40750 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40751 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40752 ret_ref = (uintptr_t)ret_var.inner;
40753 if (ret_var.is_owned) {
40754         ret_ref |= 1;
40755 }
40756         return ret_ref;
40757 }
40758 uint32_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint32_t arg) {
40759         LDKRoute arg_conv;
40760         arg_conv.inner = (void*)(arg & (~1));
40761         arg_conv.is_owned = false;
40762         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40763         uint32_t ret_conv = Route_clone_ptr(&arg_conv);
40764         return ret_conv;
40765 }
40766
40767 uint32_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint32_t orig) {
40768         LDKRoute orig_conv;
40769         orig_conv.inner = (void*)(orig & (~1));
40770         orig_conv.is_owned = false;
40771         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40772         LDKRoute ret_var = Route_clone(&orig_conv);
40773         uint32_t ret_ref = 0;
40774         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40775         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40777         ret_ref = (uintptr_t)ret_var.inner;
40778         if (ret_var.is_owned) {
40779                 ret_ref |= 1;
40780         }
40781         return ret_ref;
40782 }
40783
40784 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint32_t o) {
40785         LDKRoute o_conv;
40786         o_conv.inner = (void*)(o & (~1));
40787         o_conv.is_owned = false;
40788         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40789         int64_t ret_conv = Route_hash(&o_conv);
40790         return ret_conv;
40791 }
40792
40793 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint32_t a, uint32_t b) {
40794         LDKRoute a_conv;
40795         a_conv.inner = (void*)(a & (~1));
40796         a_conv.is_owned = false;
40797         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40798         LDKRoute b_conv;
40799         b_conv.inner = (void*)(b & (~1));
40800         b_conv.is_owned = false;
40801         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40802         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
40803         return ret_conv;
40804 }
40805
40806 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint32_t this_arg) {
40807         LDKRoute this_arg_conv;
40808         this_arg_conv.inner = (void*)(this_arg & (~1));
40809         this_arg_conv.is_owned = false;
40810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40811         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
40812         return ret_conv;
40813 }
40814
40815 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint32_t this_arg) {
40816         LDKRoute this_arg_conv;
40817         this_arg_conv.inner = (void*)(this_arg & (~1));
40818         this_arg_conv.is_owned = false;
40819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40820         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
40821         return ret_conv;
40822 }
40823
40824 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint32_t obj) {
40825         LDKRoute obj_conv;
40826         obj_conv.inner = (void*)(obj & (~1));
40827         obj_conv.is_owned = false;
40828         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40829         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
40830         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40831         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40832         CVec_u8Z_free(ret_var);
40833         return ret_arr;
40834 }
40835
40836 uint32_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
40837         LDKu8slice ser_ref;
40838         ser_ref.datalen = ser->arr_len;
40839         ser_ref.data = ser->elems;
40840         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
40841         *ret_conv = Route_read(ser_ref);
40842         FREE(ser);
40843         return (uint32_t)ret_conv;
40844 }
40845
40846 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint32_t this_obj) {
40847         LDKRouteParameters this_obj_conv;
40848         this_obj_conv.inner = (void*)(this_obj & (~1));
40849         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40851         RouteParameters_free(this_obj_conv);
40852 }
40853
40854 uint32_t  __attribute__((export_name("TS_RouteParameters_get_payment_params"))) TS_RouteParameters_get_payment_params(uint32_t this_ptr) {
40855         LDKRouteParameters this_ptr_conv;
40856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40857         this_ptr_conv.is_owned = false;
40858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40859         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
40860         uint32_t ret_ref = 0;
40861         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40862         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40864         ret_ref = (uintptr_t)ret_var.inner;
40865         if (ret_var.is_owned) {
40866                 ret_ref |= 1;
40867         }
40868         return ret_ref;
40869 }
40870
40871 void  __attribute__((export_name("TS_RouteParameters_set_payment_params"))) TS_RouteParameters_set_payment_params(uint32_t this_ptr, uint32_t val) {
40872         LDKRouteParameters this_ptr_conv;
40873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40874         this_ptr_conv.is_owned = false;
40875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40876         LDKPaymentParameters val_conv;
40877         val_conv.inner = (void*)(val & (~1));
40878         val_conv.is_owned = (val & 1) || (val == 0);
40879         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40880         val_conv = PaymentParameters_clone(&val_conv);
40881         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
40882 }
40883
40884 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
40885         LDKRouteParameters this_ptr_conv;
40886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40887         this_ptr_conv.is_owned = false;
40888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40889         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
40890         return ret_conv;
40891 }
40892
40893 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
40894         LDKRouteParameters this_ptr_conv;
40895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40896         this_ptr_conv.is_owned = false;
40897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40898         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
40899 }
40900
40901 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
40902         LDKRouteParameters this_ptr_conv;
40903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40904         this_ptr_conv.is_owned = false;
40905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40906         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
40907         return ret_conv;
40908 }
40909
40910 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) {
40911         LDKRouteParameters this_ptr_conv;
40912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40913         this_ptr_conv.is_owned = false;
40914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40915         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
40916 }
40917
40918 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) {
40919         LDKPaymentParameters payment_params_arg_conv;
40920         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
40921         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
40922         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
40923         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
40924         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
40925         uint32_t ret_ref = 0;
40926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40929         ret_ref = (uintptr_t)ret_var.inner;
40930         if (ret_var.is_owned) {
40931                 ret_ref |= 1;
40932         }
40933         return ret_ref;
40934 }
40935
40936 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
40937         LDKRouteParameters ret_var = RouteParameters_clone(arg);
40938 uint32_t ret_ref = 0;
40939 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40940 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40941 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40942 ret_ref = (uintptr_t)ret_var.inner;
40943 if (ret_var.is_owned) {
40944         ret_ref |= 1;
40945 }
40946         return ret_ref;
40947 }
40948 uint32_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
40949         LDKRouteParameters arg_conv;
40950         arg_conv.inner = (void*)(arg & (~1));
40951         arg_conv.is_owned = false;
40952         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40953         uint32_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
40954         return ret_conv;
40955 }
40956
40957 uint32_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint32_t orig) {
40958         LDKRouteParameters orig_conv;
40959         orig_conv.inner = (void*)(orig & (~1));
40960         orig_conv.is_owned = false;
40961         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40962         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
40963         uint32_t ret_ref = 0;
40964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40967         ret_ref = (uintptr_t)ret_var.inner;
40968         if (ret_var.is_owned) {
40969                 ret_ref |= 1;
40970         }
40971         return ret_ref;
40972 }
40973
40974 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint32_t obj) {
40975         LDKRouteParameters obj_conv;
40976         obj_conv.inner = (void*)(obj & (~1));
40977         obj_conv.is_owned = false;
40978         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40979         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
40980         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40981         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40982         CVec_u8Z_free(ret_var);
40983         return ret_arr;
40984 }
40985
40986 uint32_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
40987         LDKu8slice ser_ref;
40988         ser_ref.datalen = ser->arr_len;
40989         ser_ref.data = ser->elems;
40990         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
40991         *ret_conv = RouteParameters_read(ser_ref);
40992         FREE(ser);
40993         return (uint32_t)ret_conv;
40994 }
40995
40996 void  __attribute__((export_name("TS_PaymentParameters_free"))) TS_PaymentParameters_free(uint32_t this_obj) {
40997         LDKPaymentParameters this_obj_conv;
40998         this_obj_conv.inner = (void*)(this_obj & (~1));
40999         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41001         PaymentParameters_free(this_obj_conv);
41002 }
41003
41004 int8_tArray  __attribute__((export_name("TS_PaymentParameters_get_payee_pubkey"))) TS_PaymentParameters_get_payee_pubkey(uint32_t this_ptr) {
41005         LDKPaymentParameters this_ptr_conv;
41006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41007         this_ptr_conv.is_owned = false;
41008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41009         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41010         memcpy(ret_arr->elems, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form, 33);
41011         return ret_arr;
41012 }
41013
41014 void  __attribute__((export_name("TS_PaymentParameters_set_payee_pubkey"))) TS_PaymentParameters_set_payee_pubkey(uint32_t this_ptr, int8_tArray val) {
41015         LDKPaymentParameters this_ptr_conv;
41016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41017         this_ptr_conv.is_owned = false;
41018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41019         LDKPublicKey val_ref;
41020         CHECK(val->arr_len == 33);
41021         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
41022         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
41023 }
41024
41025 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_features"))) TS_PaymentParameters_get_features(uint32_t this_ptr) {
41026         LDKPaymentParameters this_ptr_conv;
41027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41028         this_ptr_conv.is_owned = false;
41029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41030         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
41031         uint32_t ret_ref = 0;
41032         if ((uintptr_t)ret_var.inner > 4096) {
41033                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41034                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41036                 ret_ref = (uintptr_t)ret_var.inner;
41037                 if (ret_var.is_owned) {
41038                         ret_ref |= 1;
41039                 }
41040         }
41041         return ret_ref;
41042 }
41043
41044 void  __attribute__((export_name("TS_PaymentParameters_set_features"))) TS_PaymentParameters_set_features(uint32_t this_ptr, uint32_t val) {
41045         LDKPaymentParameters this_ptr_conv;
41046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41047         this_ptr_conv.is_owned = false;
41048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41049         LDKInvoiceFeatures val_conv;
41050         val_conv.inner = (void*)(val & (~1));
41051         val_conv.is_owned = (val & 1) || (val == 0);
41052         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41053         val_conv = InvoiceFeatures_clone(&val_conv);
41054         PaymentParameters_set_features(&this_ptr_conv, val_conv);
41055 }
41056
41057 uint32_tArray  __attribute__((export_name("TS_PaymentParameters_get_route_hints"))) TS_PaymentParameters_get_route_hints(uint32_t this_ptr) {
41058         LDKPaymentParameters this_ptr_conv;
41059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41060         this_ptr_conv.is_owned = false;
41061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41062         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
41063         uint32_tArray ret_arr = NULL;
41064         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41065         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41066         for (size_t l = 0; l < ret_var.datalen; l++) {
41067                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
41068                 uint32_t ret_conv_11_ref = 0;
41069                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41070                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41071                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
41072                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
41073                 if (ret_conv_11_var.is_owned) {
41074                         ret_conv_11_ref |= 1;
41075                 }
41076                 ret_arr_ptr[l] = ret_conv_11_ref;
41077         }
41078         
41079         FREE(ret_var.data);
41080         return ret_arr;
41081 }
41082
41083 void  __attribute__((export_name("TS_PaymentParameters_set_route_hints"))) TS_PaymentParameters_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
41084         LDKPaymentParameters this_ptr_conv;
41085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41086         this_ptr_conv.is_owned = false;
41087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41088         LDKCVec_RouteHintZ val_constr;
41089         val_constr.datalen = val->arr_len;
41090         if (val_constr.datalen > 0)
41091                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
41092         else
41093                 val_constr.data = NULL;
41094         uint32_t* val_vals = val->elems;
41095         for (size_t l = 0; l < val_constr.datalen; l++) {
41096                 uint32_t val_conv_11 = val_vals[l];
41097                 LDKRouteHint val_conv_11_conv;
41098                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
41099                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
41100                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
41101                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
41102                 val_constr.data[l] = val_conv_11_conv;
41103         }
41104         FREE(val);
41105         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
41106 }
41107
41108 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_expiry_time"))) TS_PaymentParameters_get_expiry_time(uint32_t this_ptr) {
41109         LDKPaymentParameters this_ptr_conv;
41110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41111         this_ptr_conv.is_owned = false;
41112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41113         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41114         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
41115         uint32_t ret_ref = (uintptr_t)ret_copy;
41116         return ret_ref;
41117 }
41118
41119 void  __attribute__((export_name("TS_PaymentParameters_set_expiry_time"))) TS_PaymentParameters_set_expiry_time(uint32_t this_ptr, uint32_t val) {
41120         LDKPaymentParameters this_ptr_conv;
41121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41122         this_ptr_conv.is_owned = false;
41123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41124         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
41125         CHECK_ACCESS(val_ptr);
41126         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
41127         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
41128         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
41129 }
41130
41131 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) {
41132         LDKPaymentParameters this_ptr_conv;
41133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41134         this_ptr_conv.is_owned = false;
41135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41136         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
41137         return ret_conv;
41138 }
41139
41140 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) {
41141         LDKPaymentParameters this_ptr_conv;
41142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41143         this_ptr_conv.is_owned = false;
41144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41145         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
41146 }
41147
41148 int8_t  __attribute__((export_name("TS_PaymentParameters_get_max_mpp_path_count"))) TS_PaymentParameters_get_max_mpp_path_count(uint32_t this_ptr) {
41149         LDKPaymentParameters this_ptr_conv;
41150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41151         this_ptr_conv.is_owned = false;
41152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41153         int8_t ret_conv = PaymentParameters_get_max_mpp_path_count(&this_ptr_conv);
41154         return ret_conv;
41155 }
41156
41157 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) {
41158         LDKPaymentParameters this_ptr_conv;
41159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41160         this_ptr_conv.is_owned = false;
41161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41162         PaymentParameters_set_max_mpp_path_count(&this_ptr_conv, val);
41163 }
41164
41165 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) {
41166         LDKPublicKey payee_pubkey_arg_ref;
41167         CHECK(payee_pubkey_arg->arr_len == 33);
41168         memcpy(payee_pubkey_arg_ref.compressed_form, payee_pubkey_arg->elems, 33); FREE(payee_pubkey_arg);
41169         LDKInvoiceFeatures features_arg_conv;
41170         features_arg_conv.inner = (void*)(features_arg & (~1));
41171         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
41172         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
41173         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
41174         LDKCVec_RouteHintZ route_hints_arg_constr;
41175         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
41176         if (route_hints_arg_constr.datalen > 0)
41177                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
41178         else
41179                 route_hints_arg_constr.data = NULL;
41180         uint32_t* route_hints_arg_vals = route_hints_arg->elems;
41181         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
41182                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
41183                 LDKRouteHint route_hints_arg_conv_11_conv;
41184                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
41185                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
41186                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
41187                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
41188                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
41189         }
41190         FREE(route_hints_arg);
41191         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
41192         CHECK_ACCESS(expiry_time_arg_ptr);
41193         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
41194         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
41195         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);
41196         uint32_t ret_ref = 0;
41197         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41198         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41200         ret_ref = (uintptr_t)ret_var.inner;
41201         if (ret_var.is_owned) {
41202                 ret_ref |= 1;
41203         }
41204         return ret_ref;
41205 }
41206
41207 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
41208         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
41209 uint32_t ret_ref = 0;
41210 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41211 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41212 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41213 ret_ref = (uintptr_t)ret_var.inner;
41214 if (ret_var.is_owned) {
41215         ret_ref |= 1;
41216 }
41217         return ret_ref;
41218 }
41219 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone_ptr"))) TS_PaymentParameters_clone_ptr(uint32_t arg) {
41220         LDKPaymentParameters arg_conv;
41221         arg_conv.inner = (void*)(arg & (~1));
41222         arg_conv.is_owned = false;
41223         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41224         uint32_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
41225         return ret_conv;
41226 }
41227
41228 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone"))) TS_PaymentParameters_clone(uint32_t orig) {
41229         LDKPaymentParameters orig_conv;
41230         orig_conv.inner = (void*)(orig & (~1));
41231         orig_conv.is_owned = false;
41232         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41233         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
41234         uint32_t ret_ref = 0;
41235         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41236         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41238         ret_ref = (uintptr_t)ret_var.inner;
41239         if (ret_var.is_owned) {
41240                 ret_ref |= 1;
41241         }
41242         return ret_ref;
41243 }
41244
41245 int64_t  __attribute__((export_name("TS_PaymentParameters_hash"))) TS_PaymentParameters_hash(uint32_t o) {
41246         LDKPaymentParameters o_conv;
41247         o_conv.inner = (void*)(o & (~1));
41248         o_conv.is_owned = false;
41249         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41250         int64_t ret_conv = PaymentParameters_hash(&o_conv);
41251         return ret_conv;
41252 }
41253
41254 jboolean  __attribute__((export_name("TS_PaymentParameters_eq"))) TS_PaymentParameters_eq(uint32_t a, uint32_t b) {
41255         LDKPaymentParameters a_conv;
41256         a_conv.inner = (void*)(a & (~1));
41257         a_conv.is_owned = false;
41258         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41259         LDKPaymentParameters b_conv;
41260         b_conv.inner = (void*)(b & (~1));
41261         b_conv.is_owned = false;
41262         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41263         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
41264         return ret_conv;
41265 }
41266
41267 int8_tArray  __attribute__((export_name("TS_PaymentParameters_write"))) TS_PaymentParameters_write(uint32_t obj) {
41268         LDKPaymentParameters obj_conv;
41269         obj_conv.inner = (void*)(obj & (~1));
41270         obj_conv.is_owned = false;
41271         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41272         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
41273         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41274         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41275         CVec_u8Z_free(ret_var);
41276         return ret_arr;
41277 }
41278
41279 uint32_t  __attribute__((export_name("TS_PaymentParameters_read"))) TS_PaymentParameters_read(int8_tArray ser) {
41280         LDKu8slice ser_ref;
41281         ser_ref.datalen = ser->arr_len;
41282         ser_ref.data = ser->elems;
41283         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
41284         *ret_conv = PaymentParameters_read(ser_ref);
41285         FREE(ser);
41286         return (uint32_t)ret_conv;
41287 }
41288
41289 uint32_t  __attribute__((export_name("TS_PaymentParameters_from_node_id"))) TS_PaymentParameters_from_node_id(int8_tArray payee_pubkey) {
41290         LDKPublicKey payee_pubkey_ref;
41291         CHECK(payee_pubkey->arr_len == 33);
41292         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
41293         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
41294         uint32_t ret_ref = 0;
41295         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41296         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41298         ret_ref = (uintptr_t)ret_var.inner;
41299         if (ret_var.is_owned) {
41300                 ret_ref |= 1;
41301         }
41302         return ret_ref;
41303 }
41304
41305 uint32_t  __attribute__((export_name("TS_PaymentParameters_for_keysend"))) TS_PaymentParameters_for_keysend(int8_tArray payee_pubkey) {
41306         LDKPublicKey payee_pubkey_ref;
41307         CHECK(payee_pubkey->arr_len == 33);
41308         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
41309         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
41310         uint32_t ret_ref = 0;
41311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41314         ret_ref = (uintptr_t)ret_var.inner;
41315         if (ret_var.is_owned) {
41316                 ret_ref |= 1;
41317         }
41318         return ret_ref;
41319 }
41320
41321 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint32_t this_obj) {
41322         LDKRouteHint this_obj_conv;
41323         this_obj_conv.inner = (void*)(this_obj & (~1));
41324         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41326         RouteHint_free(this_obj_conv);
41327 }
41328
41329 uint32_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint32_t this_ptr) {
41330         LDKRouteHint this_ptr_conv;
41331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41332         this_ptr_conv.is_owned = false;
41333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41334         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
41335         uint32_tArray ret_arr = NULL;
41336         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41337         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41338         for (size_t o = 0; o < ret_var.datalen; o++) {
41339                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
41340                 uint32_t ret_conv_14_ref = 0;
41341                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41342                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41343                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
41344                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
41345                 if (ret_conv_14_var.is_owned) {
41346                         ret_conv_14_ref |= 1;
41347                 }
41348                 ret_arr_ptr[o] = ret_conv_14_ref;
41349         }
41350         
41351         FREE(ret_var.data);
41352         return ret_arr;
41353 }
41354
41355 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
41356         LDKRouteHint this_ptr_conv;
41357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41358         this_ptr_conv.is_owned = false;
41359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41360         LDKCVec_RouteHintHopZ val_constr;
41361         val_constr.datalen = val->arr_len;
41362         if (val_constr.datalen > 0)
41363                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
41364         else
41365                 val_constr.data = NULL;
41366         uint32_t* val_vals = val->elems;
41367         for (size_t o = 0; o < val_constr.datalen; o++) {
41368                 uint32_t val_conv_14 = val_vals[o];
41369                 LDKRouteHintHop val_conv_14_conv;
41370                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
41371                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
41372                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
41373                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
41374                 val_constr.data[o] = val_conv_14_conv;
41375         }
41376         FREE(val);
41377         RouteHint_set_a(&this_ptr_conv, val_constr);
41378 }
41379
41380 uint32_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint32_tArray a_arg) {
41381         LDKCVec_RouteHintHopZ a_arg_constr;
41382         a_arg_constr.datalen = a_arg->arr_len;
41383         if (a_arg_constr.datalen > 0)
41384                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
41385         else
41386                 a_arg_constr.data = NULL;
41387         uint32_t* a_arg_vals = a_arg->elems;
41388         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
41389                 uint32_t a_arg_conv_14 = a_arg_vals[o];
41390                 LDKRouteHintHop a_arg_conv_14_conv;
41391                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
41392                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
41393                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
41394                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
41395                 a_arg_constr.data[o] = a_arg_conv_14_conv;
41396         }
41397         FREE(a_arg);
41398         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
41399         uint32_t ret_ref = 0;
41400         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41401         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41403         ret_ref = (uintptr_t)ret_var.inner;
41404         if (ret_var.is_owned) {
41405                 ret_ref |= 1;
41406         }
41407         return ret_ref;
41408 }
41409
41410 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
41411         LDKRouteHint ret_var = RouteHint_clone(arg);
41412 uint32_t ret_ref = 0;
41413 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41414 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41415 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41416 ret_ref = (uintptr_t)ret_var.inner;
41417 if (ret_var.is_owned) {
41418         ret_ref |= 1;
41419 }
41420         return ret_ref;
41421 }
41422 uint32_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint32_t arg) {
41423         LDKRouteHint arg_conv;
41424         arg_conv.inner = (void*)(arg & (~1));
41425         arg_conv.is_owned = false;
41426         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41427         uint32_t ret_conv = RouteHint_clone_ptr(&arg_conv);
41428         return ret_conv;
41429 }
41430
41431 uint32_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint32_t orig) {
41432         LDKRouteHint orig_conv;
41433         orig_conv.inner = (void*)(orig & (~1));
41434         orig_conv.is_owned = false;
41435         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41436         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
41437         uint32_t ret_ref = 0;
41438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41441         ret_ref = (uintptr_t)ret_var.inner;
41442         if (ret_var.is_owned) {
41443                 ret_ref |= 1;
41444         }
41445         return ret_ref;
41446 }
41447
41448 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint32_t o) {
41449         LDKRouteHint o_conv;
41450         o_conv.inner = (void*)(o & (~1));
41451         o_conv.is_owned = false;
41452         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41453         int64_t ret_conv = RouteHint_hash(&o_conv);
41454         return ret_conv;
41455 }
41456
41457 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
41458         LDKRouteHint a_conv;
41459         a_conv.inner = (void*)(a & (~1));
41460         a_conv.is_owned = false;
41461         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41462         LDKRouteHint b_conv;
41463         b_conv.inner = (void*)(b & (~1));
41464         b_conv.is_owned = false;
41465         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41466         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
41467         return ret_conv;
41468 }
41469
41470 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint32_t obj) {
41471         LDKRouteHint obj_conv;
41472         obj_conv.inner = (void*)(obj & (~1));
41473         obj_conv.is_owned = false;
41474         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41475         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
41476         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41477         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41478         CVec_u8Z_free(ret_var);
41479         return ret_arr;
41480 }
41481
41482 uint32_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
41483         LDKu8slice ser_ref;
41484         ser_ref.datalen = ser->arr_len;
41485         ser_ref.data = ser->elems;
41486         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
41487         *ret_conv = RouteHint_read(ser_ref);
41488         FREE(ser);
41489         return (uint32_t)ret_conv;
41490 }
41491
41492 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint32_t this_obj) {
41493         LDKRouteHintHop this_obj_conv;
41494         this_obj_conv.inner = (void*)(this_obj & (~1));
41495         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41497         RouteHintHop_free(this_obj_conv);
41498 }
41499
41500 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
41501         LDKRouteHintHop this_ptr_conv;
41502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41503         this_ptr_conv.is_owned = false;
41504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41505         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41506         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
41507         return ret_arr;
41508 }
41509
41510 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
41511         LDKRouteHintHop this_ptr_conv;
41512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41513         this_ptr_conv.is_owned = false;
41514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41515         LDKPublicKey val_ref;
41516         CHECK(val->arr_len == 33);
41517         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
41518         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
41519 }
41520
41521 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
41522         LDKRouteHintHop this_ptr_conv;
41523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41524         this_ptr_conv.is_owned = false;
41525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41526         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
41527         return ret_conv;
41528 }
41529
41530 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
41531         LDKRouteHintHop this_ptr_conv;
41532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41533         this_ptr_conv.is_owned = false;
41534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41535         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
41536 }
41537
41538 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
41539         LDKRouteHintHop this_ptr_conv;
41540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41541         this_ptr_conv.is_owned = false;
41542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41543         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
41544         uint32_t ret_ref = 0;
41545         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41546         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41548         ret_ref = (uintptr_t)ret_var.inner;
41549         if (ret_var.is_owned) {
41550                 ret_ref |= 1;
41551         }
41552         return ret_ref;
41553 }
41554
41555 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
41556         LDKRouteHintHop this_ptr_conv;
41557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41558         this_ptr_conv.is_owned = false;
41559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41560         LDKRoutingFees val_conv;
41561         val_conv.inner = (void*)(val & (~1));
41562         val_conv.is_owned = (val & 1) || (val == 0);
41563         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41564         val_conv = RoutingFees_clone(&val_conv);
41565         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
41566 }
41567
41568 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
41569         LDKRouteHintHop this_ptr_conv;
41570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41571         this_ptr_conv.is_owned = false;
41572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41573         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
41574         return ret_conv;
41575 }
41576
41577 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
41578         LDKRouteHintHop this_ptr_conv;
41579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41580         this_ptr_conv.is_owned = false;
41581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41582         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
41583 }
41584
41585 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
41586         LDKRouteHintHop this_ptr_conv;
41587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41588         this_ptr_conv.is_owned = false;
41589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41590         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41591         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
41592         uint32_t ret_ref = (uintptr_t)ret_copy;
41593         return ret_ref;
41594 }
41595
41596 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
41597         LDKRouteHintHop this_ptr_conv;
41598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41599         this_ptr_conv.is_owned = false;
41600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41601         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
41602         CHECK_ACCESS(val_ptr);
41603         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
41604         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
41605         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
41606 }
41607
41608 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
41609         LDKRouteHintHop this_ptr_conv;
41610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41611         this_ptr_conv.is_owned = false;
41612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41613         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41614         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
41615         uint32_t ret_ref = (uintptr_t)ret_copy;
41616         return ret_ref;
41617 }
41618
41619 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
41620         LDKRouteHintHop this_ptr_conv;
41621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41622         this_ptr_conv.is_owned = false;
41623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41624         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
41625         CHECK_ACCESS(val_ptr);
41626         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
41627         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
41628         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
41629 }
41630
41631 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) {
41632         LDKPublicKey src_node_id_arg_ref;
41633         CHECK(src_node_id_arg->arr_len == 33);
41634         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
41635         LDKRoutingFees fees_arg_conv;
41636         fees_arg_conv.inner = (void*)(fees_arg & (~1));
41637         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
41638         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
41639         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
41640         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
41641         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
41642         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
41643         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
41644         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
41645         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
41646         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
41647         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
41648         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);
41649         uint32_t ret_ref = 0;
41650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41653         ret_ref = (uintptr_t)ret_var.inner;
41654         if (ret_var.is_owned) {
41655                 ret_ref |= 1;
41656         }
41657         return ret_ref;
41658 }
41659
41660 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
41661         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
41662 uint32_t ret_ref = 0;
41663 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41664 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41665 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41666 ret_ref = (uintptr_t)ret_var.inner;
41667 if (ret_var.is_owned) {
41668         ret_ref |= 1;
41669 }
41670         return ret_ref;
41671 }
41672 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
41673         LDKRouteHintHop arg_conv;
41674         arg_conv.inner = (void*)(arg & (~1));
41675         arg_conv.is_owned = false;
41676         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41677         uint32_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
41678         return ret_conv;
41679 }
41680
41681 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint32_t orig) {
41682         LDKRouteHintHop orig_conv;
41683         orig_conv.inner = (void*)(orig & (~1));
41684         orig_conv.is_owned = false;
41685         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41686         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
41687         uint32_t ret_ref = 0;
41688         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41689         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41691         ret_ref = (uintptr_t)ret_var.inner;
41692         if (ret_var.is_owned) {
41693                 ret_ref |= 1;
41694         }
41695         return ret_ref;
41696 }
41697
41698 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint32_t o) {
41699         LDKRouteHintHop o_conv;
41700         o_conv.inner = (void*)(o & (~1));
41701         o_conv.is_owned = false;
41702         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41703         int64_t ret_conv = RouteHintHop_hash(&o_conv);
41704         return ret_conv;
41705 }
41706
41707 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
41708         LDKRouteHintHop a_conv;
41709         a_conv.inner = (void*)(a & (~1));
41710         a_conv.is_owned = false;
41711         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41712         LDKRouteHintHop b_conv;
41713         b_conv.inner = (void*)(b & (~1));
41714         b_conv.is_owned = false;
41715         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41716         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
41717         return ret_conv;
41718 }
41719
41720 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint32_t obj) {
41721         LDKRouteHintHop obj_conv;
41722         obj_conv.inner = (void*)(obj & (~1));
41723         obj_conv.is_owned = false;
41724         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41725         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
41726         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41727         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41728         CVec_u8Z_free(ret_var);
41729         return ret_arr;
41730 }
41731
41732 uint32_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
41733         LDKu8slice ser_ref;
41734         ser_ref.datalen = ser->arr_len;
41735         ser_ref.data = ser->elems;
41736         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
41737         *ret_conv = RouteHintHop_read(ser_ref);
41738         FREE(ser);
41739         return (uint32_t)ret_conv;
41740 }
41741
41742 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) {
41743         LDKPublicKey our_node_pubkey_ref;
41744         CHECK(our_node_pubkey->arr_len == 33);
41745         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
41746         LDKRouteParameters route_params_conv;
41747         route_params_conv.inner = (void*)(route_params & (~1));
41748         route_params_conv.is_owned = false;
41749         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
41750         LDKNetworkGraph network_graph_conv;
41751         network_graph_conv.inner = (void*)(network_graph & (~1));
41752         network_graph_conv.is_owned = false;
41753         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
41754         LDKCVec_ChannelDetailsZ first_hops_constr;
41755         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
41756         if (first_hops != 0) {
41757                 first_hops_constr.datalen = first_hops->arr_len;
41758                 if (first_hops_constr.datalen > 0)
41759                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
41760                 else
41761                         first_hops_constr.data = NULL;
41762                 uint32_t* first_hops_vals = first_hops->elems;
41763                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
41764                         uint32_t first_hops_conv_16 = first_hops_vals[q];
41765                         LDKChannelDetails first_hops_conv_16_conv;
41766                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
41767                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
41768                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
41769                         first_hops_constr.data[q] = first_hops_conv_16_conv;
41770                 }
41771                 FREE(first_hops);
41772                 first_hops_ptr = &first_hops_constr;
41773         }
41774         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
41775         CHECK_ACCESS(logger_ptr);
41776         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41777         if (logger_conv.free == LDKLogger_JCalls_free) {
41778                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41779                 LDKLogger_JCalls_cloned(&logger_conv);
41780         }
41781         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
41782         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
41783         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
41784         unsigned char random_seed_bytes_arr[32];
41785         CHECK(random_seed_bytes->arr_len == 32);
41786         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
41787         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
41788         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
41789         *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);
41790         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
41791         return (uint32_t)ret_conv;
41792 }
41793
41794 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) {
41795         LDKPublicKey our_node_pubkey_ref;
41796         CHECK(our_node_pubkey->arr_len == 33);
41797         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
41798         LDKCVec_PublicKeyZ hops_constr;
41799         hops_constr.datalen = hops->arr_len;
41800         if (hops_constr.datalen > 0)
41801                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
41802         else
41803                 hops_constr.data = NULL;
41804         int8_tArray* hops_vals = (void*) hops->elems;
41805         for (size_t m = 0; m < hops_constr.datalen; m++) {
41806                 int8_tArray hops_conv_12 = hops_vals[m];
41807                 LDKPublicKey hops_conv_12_ref;
41808                 CHECK(hops_conv_12->arr_len == 33);
41809                 memcpy(hops_conv_12_ref.compressed_form, hops_conv_12->elems, 33); FREE(hops_conv_12);
41810                 hops_constr.data[m] = hops_conv_12_ref;
41811         }
41812         FREE(hops);
41813         LDKRouteParameters route_params_conv;
41814         route_params_conv.inner = (void*)(route_params & (~1));
41815         route_params_conv.is_owned = false;
41816         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
41817         LDKNetworkGraph network_graph_conv;
41818         network_graph_conv.inner = (void*)(network_graph & (~1));
41819         network_graph_conv.is_owned = false;
41820         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
41821         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
41822         CHECK_ACCESS(logger_ptr);
41823         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41824         if (logger_conv.free == LDKLogger_JCalls_free) {
41825                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41826                 LDKLogger_JCalls_cloned(&logger_conv);
41827         }
41828         unsigned char random_seed_bytes_arr[32];
41829         CHECK(random_seed_bytes->arr_len == 32);
41830         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
41831         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
41832         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
41833         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
41834         return (uint32_t)ret_conv;
41835 }
41836
41837 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint32_t this_ptr) {
41838         if ((this_ptr & 1) != 0) return;
41839         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41840         CHECK_ACCESS(this_ptr_ptr);
41841         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
41842         FREE((void*)this_ptr);
41843         Score_free(this_ptr_conv);
41844 }
41845
41846 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint32_t this_ptr) {
41847         if ((this_ptr & 1) != 0) return;
41848         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41849         CHECK_ACCESS(this_ptr_ptr);
41850         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
41851         FREE((void*)this_ptr);
41852         LockableScore_free(this_ptr_conv);
41853 }
41854
41855 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
41856         LDKMultiThreadedLockableScore this_obj_conv;
41857         this_obj_conv.inner = (void*)(this_obj & (~1));
41858         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41860         MultiThreadedLockableScore_free(this_obj_conv);
41861 }
41862
41863 int8_tArray  __attribute__((export_name("TS_MultiThreadedLockableScore_write"))) TS_MultiThreadedLockableScore_write(uint32_t obj) {
41864         LDKMultiThreadedLockableScore obj_conv;
41865         obj_conv.inner = (void*)(obj & (~1));
41866         obj_conv.is_owned = false;
41867         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41868         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
41869         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41870         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41871         CVec_u8Z_free(ret_var);
41872         return ret_arr;
41873 }
41874
41875 uint32_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
41876         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
41877         CHECK_ACCESS(score_ptr);
41878         LDKScore score_conv = *(LDKScore*)(score_ptr);
41879         if (score_conv.free == LDKScore_JCalls_free) {
41880                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41881                 LDKScore_JCalls_cloned(&score_conv);
41882         }
41883         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
41884         uint32_t ret_ref = 0;
41885         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41886         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41888         ret_ref = (uintptr_t)ret_var.inner;
41889         if (ret_var.is_owned) {
41890                 ret_ref |= 1;
41891         }
41892         return ret_ref;
41893 }
41894
41895 void  __attribute__((export_name("TS_ChannelUsage_free"))) TS_ChannelUsage_free(uint32_t this_obj) {
41896         LDKChannelUsage this_obj_conv;
41897         this_obj_conv.inner = (void*)(this_obj & (~1));
41898         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41900         ChannelUsage_free(this_obj_conv);
41901 }
41902
41903 int64_t  __attribute__((export_name("TS_ChannelUsage_get_amount_msat"))) TS_ChannelUsage_get_amount_msat(uint32_t this_ptr) {
41904         LDKChannelUsage this_ptr_conv;
41905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41906         this_ptr_conv.is_owned = false;
41907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41908         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
41909         return ret_conv;
41910 }
41911
41912 void  __attribute__((export_name("TS_ChannelUsage_set_amount_msat"))) TS_ChannelUsage_set_amount_msat(uint32_t this_ptr, int64_t val) {
41913         LDKChannelUsage this_ptr_conv;
41914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41915         this_ptr_conv.is_owned = false;
41916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41917         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
41918 }
41919
41920 int64_t  __attribute__((export_name("TS_ChannelUsage_get_inflight_htlc_msat"))) TS_ChannelUsage_get_inflight_htlc_msat(uint32_t this_ptr) {
41921         LDKChannelUsage this_ptr_conv;
41922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41923         this_ptr_conv.is_owned = false;
41924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41925         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
41926         return ret_conv;
41927 }
41928
41929 void  __attribute__((export_name("TS_ChannelUsage_set_inflight_htlc_msat"))) TS_ChannelUsage_set_inflight_htlc_msat(uint32_t this_ptr, int64_t val) {
41930         LDKChannelUsage this_ptr_conv;
41931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41932         this_ptr_conv.is_owned = false;
41933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41934         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
41935 }
41936
41937 uint32_t  __attribute__((export_name("TS_ChannelUsage_get_effective_capacity"))) TS_ChannelUsage_get_effective_capacity(uint32_t this_ptr) {
41938         LDKChannelUsage this_ptr_conv;
41939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41940         this_ptr_conv.is_owned = false;
41941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41942         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
41943         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
41944         uint32_t ret_ref = (uintptr_t)ret_copy;
41945         return ret_ref;
41946 }
41947
41948 void  __attribute__((export_name("TS_ChannelUsage_set_effective_capacity"))) TS_ChannelUsage_set_effective_capacity(uint32_t this_ptr, uint32_t val) {
41949         LDKChannelUsage this_ptr_conv;
41950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41951         this_ptr_conv.is_owned = false;
41952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41953         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
41954         CHECK_ACCESS(val_ptr);
41955         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
41956         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)val) & ~1));
41957         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
41958 }
41959
41960 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) {
41961         void* effective_capacity_arg_ptr = (void*)(((uintptr_t)effective_capacity_arg) & ~1);
41962         CHECK_ACCESS(effective_capacity_arg_ptr);
41963         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
41964         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)effective_capacity_arg) & ~1));
41965         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
41966         uint32_t ret_ref = 0;
41967         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41968         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41970         ret_ref = (uintptr_t)ret_var.inner;
41971         if (ret_var.is_owned) {
41972                 ret_ref |= 1;
41973         }
41974         return ret_ref;
41975 }
41976
41977 static inline uintptr_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
41978         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
41979 uint32_t ret_ref = 0;
41980 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41981 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41982 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41983 ret_ref = (uintptr_t)ret_var.inner;
41984 if (ret_var.is_owned) {
41985         ret_ref |= 1;
41986 }
41987         return ret_ref;
41988 }
41989 uint32_t  __attribute__((export_name("TS_ChannelUsage_clone_ptr"))) TS_ChannelUsage_clone_ptr(uint32_t arg) {
41990         LDKChannelUsage arg_conv;
41991         arg_conv.inner = (void*)(arg & (~1));
41992         arg_conv.is_owned = false;
41993         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41994         uint32_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
41995         return ret_conv;
41996 }
41997
41998 uint32_t  __attribute__((export_name("TS_ChannelUsage_clone"))) TS_ChannelUsage_clone(uint32_t orig) {
41999         LDKChannelUsage orig_conv;
42000         orig_conv.inner = (void*)(orig & (~1));
42001         orig_conv.is_owned = false;
42002         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42003         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
42004         uint32_t ret_ref = 0;
42005         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42006         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42008         ret_ref = (uintptr_t)ret_var.inner;
42009         if (ret_var.is_owned) {
42010                 ret_ref |= 1;
42011         }
42012         return ret_ref;
42013 }
42014
42015 void  __attribute__((export_name("TS_FixedPenaltyScorer_free"))) TS_FixedPenaltyScorer_free(uint32_t this_obj) {
42016         LDKFixedPenaltyScorer this_obj_conv;
42017         this_obj_conv.inner = (void*)(this_obj & (~1));
42018         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42020         FixedPenaltyScorer_free(this_obj_conv);
42021 }
42022
42023 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
42024         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
42025 uint32_t ret_ref = 0;
42026 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42027 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42028 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42029 ret_ref = (uintptr_t)ret_var.inner;
42030 if (ret_var.is_owned) {
42031         ret_ref |= 1;
42032 }
42033         return ret_ref;
42034 }
42035 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone_ptr"))) TS_FixedPenaltyScorer_clone_ptr(uint32_t arg) {
42036         LDKFixedPenaltyScorer arg_conv;
42037         arg_conv.inner = (void*)(arg & (~1));
42038         arg_conv.is_owned = false;
42039         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42040         uint32_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
42041         return ret_conv;
42042 }
42043
42044 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone"))) TS_FixedPenaltyScorer_clone(uint32_t orig) {
42045         LDKFixedPenaltyScorer orig_conv;
42046         orig_conv.inner = (void*)(orig & (~1));
42047         orig_conv.is_owned = false;
42048         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42049         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
42050         uint32_t ret_ref = 0;
42051         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42052         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42054         ret_ref = (uintptr_t)ret_var.inner;
42055         if (ret_var.is_owned) {
42056                 ret_ref |= 1;
42057         }
42058         return ret_ref;
42059 }
42060
42061 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_with_penalty"))) TS_FixedPenaltyScorer_with_penalty(int64_t penalty_msat) {
42062         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
42063         uint32_t ret_ref = 0;
42064         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42065         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42067         ret_ref = (uintptr_t)ret_var.inner;
42068         if (ret_var.is_owned) {
42069                 ret_ref |= 1;
42070         }
42071         return ret_ref;
42072 }
42073
42074 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_as_Score"))) TS_FixedPenaltyScorer_as_Score(uint32_t this_arg) {
42075         LDKFixedPenaltyScorer this_arg_conv;
42076         this_arg_conv.inner = (void*)(this_arg & (~1));
42077         this_arg_conv.is_owned = false;
42078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42079         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
42080         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
42081         return (uint32_t)ret_ret;
42082 }
42083
42084 int8_tArray  __attribute__((export_name("TS_FixedPenaltyScorer_write"))) TS_FixedPenaltyScorer_write(uint32_t obj) {
42085         LDKFixedPenaltyScorer obj_conv;
42086         obj_conv.inner = (void*)(obj & (~1));
42087         obj_conv.is_owned = false;
42088         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42089         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
42090         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42091         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42092         CVec_u8Z_free(ret_var);
42093         return ret_arr;
42094 }
42095
42096 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_read"))) TS_FixedPenaltyScorer_read(int8_tArray ser, int64_t arg) {
42097         LDKu8slice ser_ref;
42098         ser_ref.datalen = ser->arr_len;
42099         ser_ref.data = ser->elems;
42100         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
42101         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
42102         FREE(ser);
42103         return (uint32_t)ret_conv;
42104 }
42105
42106 void  __attribute__((export_name("TS_ProbabilisticScorer_free"))) TS_ProbabilisticScorer_free(uint32_t this_obj) {
42107         LDKProbabilisticScorer this_obj_conv;
42108         this_obj_conv.inner = (void*)(this_obj & (~1));
42109         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42111         ProbabilisticScorer_free(this_obj_conv);
42112 }
42113
42114 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_free"))) TS_ProbabilisticScoringParameters_free(uint32_t this_obj) {
42115         LDKProbabilisticScoringParameters this_obj_conv;
42116         this_obj_conv.inner = (void*)(this_obj & (~1));
42117         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42119         ProbabilisticScoringParameters_free(this_obj_conv);
42120 }
42121
42122 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_base_penalty_msat"))) TS_ProbabilisticScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
42123         LDKProbabilisticScoringParameters this_ptr_conv;
42124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42125         this_ptr_conv.is_owned = false;
42126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42127         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
42128         return ret_conv;
42129 }
42130
42131 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_base_penalty_msat"))) TS_ProbabilisticScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
42132         LDKProbabilisticScoringParameters this_ptr_conv;
42133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42134         this_ptr_conv.is_owned = false;
42135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42136         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
42137 }
42138
42139 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(uint32_t this_ptr) {
42140         LDKProbabilisticScoringParameters this_ptr_conv;
42141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42142         this_ptr_conv.is_owned = false;
42143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42144         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
42145         return ret_conv;
42146 }
42147
42148 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) {
42149         LDKProbabilisticScoringParameters this_ptr_conv;
42150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42151         this_ptr_conv.is_owned = false;
42152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42153         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
42154 }
42155
42156 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life(uint32_t this_ptr) {
42157         LDKProbabilisticScoringParameters this_ptr_conv;
42158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42159         this_ptr_conv.is_owned = false;
42160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42161         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
42162         return ret_conv;
42163 }
42164
42165 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) {
42166         LDKProbabilisticScoringParameters this_ptr_conv;
42167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42168         this_ptr_conv.is_owned = false;
42169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42170         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
42171 }
42172
42173 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(uint32_t this_ptr) {
42174         LDKProbabilisticScoringParameters this_ptr_conv;
42175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42176         this_ptr_conv.is_owned = false;
42177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42178         int64_t ret_conv = ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(&this_ptr_conv);
42179         return ret_conv;
42180 }
42181
42182 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) {
42183         LDKProbabilisticScoringParameters this_ptr_conv;
42184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42185         this_ptr_conv.is_owned = false;
42186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42187         ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(&this_ptr_conv, val);
42188 }
42189
42190 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_anti_probing_penalty_msat"))) TS_ProbabilisticScoringParameters_get_anti_probing_penalty_msat(uint32_t this_ptr) {
42191         LDKProbabilisticScoringParameters this_ptr_conv;
42192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42193         this_ptr_conv.is_owned = false;
42194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42195         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
42196         return ret_conv;
42197 }
42198
42199 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) {
42200         LDKProbabilisticScoringParameters this_ptr_conv;
42201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42202         this_ptr_conv.is_owned = false;
42203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42204         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
42205 }
42206
42207 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
42208         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
42209 uint32_t ret_ref = 0;
42210 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42211 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42212 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42213 ret_ref = (uintptr_t)ret_var.inner;
42214 if (ret_var.is_owned) {
42215         ret_ref |= 1;
42216 }
42217         return ret_ref;
42218 }
42219 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone_ptr"))) TS_ProbabilisticScoringParameters_clone_ptr(uint32_t arg) {
42220         LDKProbabilisticScoringParameters arg_conv;
42221         arg_conv.inner = (void*)(arg & (~1));
42222         arg_conv.is_owned = false;
42223         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42224         uint32_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
42225         return ret_conv;
42226 }
42227
42228 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone"))) TS_ProbabilisticScoringParameters_clone(uint32_t orig) {
42229         LDKProbabilisticScoringParameters orig_conv;
42230         orig_conv.inner = (void*)(orig & (~1));
42231         orig_conv.is_owned = false;
42232         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42233         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
42234         uint32_t ret_ref = 0;
42235         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42236         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42238         ret_ref = (uintptr_t)ret_var.inner;
42239         if (ret_var.is_owned) {
42240                 ret_ref |= 1;
42241         }
42242         return ret_ref;
42243 }
42244
42245 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_new"))) TS_ProbabilisticScorer_new(uint32_t params, uint32_t network_graph, uint32_t logger) {
42246         LDKProbabilisticScoringParameters params_conv;
42247         params_conv.inner = (void*)(params & (~1));
42248         params_conv.is_owned = (params & 1) || (params == 0);
42249         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
42250         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
42251         LDKNetworkGraph network_graph_conv;
42252         network_graph_conv.inner = (void*)(network_graph & (~1));
42253         network_graph_conv.is_owned = false;
42254         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42255         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42256         CHECK_ACCESS(logger_ptr);
42257         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42258         if (logger_conv.free == LDKLogger_JCalls_free) {
42259                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42260                 LDKLogger_JCalls_cloned(&logger_conv);
42261         }
42262         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
42263         uint32_t ret_ref = 0;
42264         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42265         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42267         ret_ref = (uintptr_t)ret_var.inner;
42268         if (ret_var.is_owned) {
42269                 ret_ref |= 1;
42270         }
42271         return ret_ref;
42272 }
42273
42274 void  __attribute__((export_name("TS_ProbabilisticScorer_debug_log_liquidity_stats"))) TS_ProbabilisticScorer_debug_log_liquidity_stats(uint32_t this_arg) {
42275         LDKProbabilisticScorer this_arg_conv;
42276         this_arg_conv.inner = (void*)(this_arg & (~1));
42277         this_arg_conv.is_owned = false;
42278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42279         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
42280 }
42281
42282 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) {
42283         LDKProbabilisticScorer this_arg_conv;
42284         this_arg_conv.inner = (void*)(this_arg & (~1));
42285         this_arg_conv.is_owned = false;
42286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42287         LDKNodeId target_conv;
42288         target_conv.inner = (void*)(target & (~1));
42289         target_conv.is_owned = false;
42290         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
42291         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
42292         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
42293         uint32_t ret_ref = (uintptr_t)ret_copy;
42294         return ret_ref;
42295 }
42296
42297 void  __attribute__((export_name("TS_ProbabilisticScorer_add_banned"))) TS_ProbabilisticScorer_add_banned(uint32_t this_arg, uint32_t node_id) {
42298         LDKProbabilisticScorer this_arg_conv;
42299         this_arg_conv.inner = (void*)(this_arg & (~1));
42300         this_arg_conv.is_owned = false;
42301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42302         LDKNodeId node_id_conv;
42303         node_id_conv.inner = (void*)(node_id & (~1));
42304         node_id_conv.is_owned = false;
42305         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
42306         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
42307 }
42308
42309 void  __attribute__((export_name("TS_ProbabilisticScorer_remove_banned"))) TS_ProbabilisticScorer_remove_banned(uint32_t this_arg, uint32_t node_id) {
42310         LDKProbabilisticScorer this_arg_conv;
42311         this_arg_conv.inner = (void*)(this_arg & (~1));
42312         this_arg_conv.is_owned = false;
42313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42314         LDKNodeId node_id_conv;
42315         node_id_conv.inner = (void*)(node_id & (~1));
42316         node_id_conv.is_owned = false;
42317         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
42318         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
42319 }
42320
42321 void  __attribute__((export_name("TS_ProbabilisticScorer_clear_banned"))) TS_ProbabilisticScorer_clear_banned(uint32_t this_arg) {
42322         LDKProbabilisticScorer this_arg_conv;
42323         this_arg_conv.inner = (void*)(this_arg & (~1));
42324         this_arg_conv.is_owned = false;
42325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42326         ProbabilisticScorer_clear_banned(&this_arg_conv);
42327 }
42328
42329 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_add_banned_from_list"))) TS_ProbabilisticScoringParameters_add_banned_from_list(uint32_t this_arg, uint32_tArray node_ids) {
42330         LDKProbabilisticScoringParameters this_arg_conv;
42331         this_arg_conv.inner = (void*)(this_arg & (~1));
42332         this_arg_conv.is_owned = false;
42333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42334         LDKCVec_NodeIdZ node_ids_constr;
42335         node_ids_constr.datalen = node_ids->arr_len;
42336         if (node_ids_constr.datalen > 0)
42337                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
42338         else
42339                 node_ids_constr.data = NULL;
42340         uint32_t* node_ids_vals = node_ids->elems;
42341         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
42342                 uint32_t node_ids_conv_8 = node_ids_vals[i];
42343                 LDKNodeId node_ids_conv_8_conv;
42344                 node_ids_conv_8_conv.inner = (void*)(node_ids_conv_8 & (~1));
42345                 node_ids_conv_8_conv.is_owned = (node_ids_conv_8 & 1) || (node_ids_conv_8 == 0);
42346                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
42347                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
42348                 node_ids_constr.data[i] = node_ids_conv_8_conv;
42349         }
42350         FREE(node_ids);
42351         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
42352 }
42353
42354 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_default"))) TS_ProbabilisticScoringParameters_default() {
42355         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
42356         uint32_t ret_ref = 0;
42357         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42358         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42360         ret_ref = (uintptr_t)ret_var.inner;
42361         if (ret_var.is_owned) {
42362                 ret_ref |= 1;
42363         }
42364         return ret_ref;
42365 }
42366
42367 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_as_Score"))) TS_ProbabilisticScorer_as_Score(uint32_t this_arg) {
42368         LDKProbabilisticScorer this_arg_conv;
42369         this_arg_conv.inner = (void*)(this_arg & (~1));
42370         this_arg_conv.is_owned = false;
42371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42372         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
42373         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
42374         return (uint32_t)ret_ret;
42375 }
42376
42377 int8_tArray  __attribute__((export_name("TS_ProbabilisticScorer_write"))) TS_ProbabilisticScorer_write(uint32_t obj) {
42378         LDKProbabilisticScorer obj_conv;
42379         obj_conv.inner = (void*)(obj & (~1));
42380         obj_conv.is_owned = false;
42381         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42382         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
42383         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42384         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42385         CVec_u8Z_free(ret_var);
42386         return ret_arr;
42387 }
42388
42389 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) {
42390         LDKu8slice ser_ref;
42391         ser_ref.datalen = ser->arr_len;
42392         ser_ref.data = ser->elems;
42393         LDKProbabilisticScoringParameters arg_a_conv;
42394         arg_a_conv.inner = (void*)(arg_a & (~1));
42395         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
42396         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
42397         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
42398         LDKNetworkGraph arg_b_conv;
42399         arg_b_conv.inner = (void*)(arg_b & (~1));
42400         arg_b_conv.is_owned = false;
42401         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
42402         void* arg_c_ptr = (void*)(((uintptr_t)arg_c) & ~1);
42403         CHECK_ACCESS(arg_c_ptr);
42404         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
42405         if (arg_c_conv.free == LDKLogger_JCalls_free) {
42406                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42407                 LDKLogger_JCalls_cloned(&arg_c_conv);
42408         }
42409         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
42410         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
42411         FREE(ser);
42412         return (uint32_t)ret_conv;
42413 }
42414
42415 void  __attribute__((export_name("TS_ParseError_free"))) TS_ParseError_free(uint32_t this_ptr) {
42416         if ((this_ptr & 1) != 0) return;
42417         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42418         CHECK_ACCESS(this_ptr_ptr);
42419         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
42420         FREE((void*)this_ptr);
42421         ParseError_free(this_ptr_conv);
42422 }
42423
42424 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
42425         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42426         *ret_copy = ParseError_clone(arg);
42427 uint32_t ret_ref = (uintptr_t)ret_copy;
42428         return ret_ref;
42429 }
42430 uint32_t  __attribute__((export_name("TS_ParseError_clone_ptr"))) TS_ParseError_clone_ptr(uint32_t arg) {
42431         LDKParseError* arg_conv = (LDKParseError*)arg;
42432         uint32_t ret_conv = ParseError_clone_ptr(arg_conv);
42433         return ret_conv;
42434 }
42435
42436 uint32_t  __attribute__((export_name("TS_ParseError_clone"))) TS_ParseError_clone(uint32_t orig) {
42437         LDKParseError* orig_conv = (LDKParseError*)orig;
42438         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42439         *ret_copy = ParseError_clone(orig_conv);
42440         uint32_t ret_ref = (uintptr_t)ret_copy;
42441         return ret_ref;
42442 }
42443
42444 uint32_t  __attribute__((export_name("TS_ParseError_bech32_error"))) TS_ParseError_bech32_error(uint32_t a) {
42445         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
42446         CHECK_ACCESS(a_ptr);
42447         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
42448         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
42449         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42450         *ret_copy = ParseError_bech32_error(a_conv);
42451         uint32_t ret_ref = (uintptr_t)ret_copy;
42452         return ret_ref;
42453 }
42454
42455 uint32_t  __attribute__((export_name("TS_ParseError_parse_amount_error"))) TS_ParseError_parse_amount_error(int32_t a) {
42456         
42457         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42458         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
42459         uint32_t ret_ref = (uintptr_t)ret_copy;
42460         return ret_ref;
42461 }
42462
42463 uint32_t  __attribute__((export_name("TS_ParseError_malformed_signature"))) TS_ParseError_malformed_signature(uint32_t a) {
42464         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_js(a);
42465         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42466         *ret_copy = ParseError_malformed_signature(a_conv);
42467         uint32_t ret_ref = (uintptr_t)ret_copy;
42468         return ret_ref;
42469 }
42470
42471 uint32_t  __attribute__((export_name("TS_ParseError_bad_prefix"))) TS_ParseError_bad_prefix() {
42472         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42473         *ret_copy = ParseError_bad_prefix();
42474         uint32_t ret_ref = (uintptr_t)ret_copy;
42475         return ret_ref;
42476 }
42477
42478 uint32_t  __attribute__((export_name("TS_ParseError_unknown_currency"))) TS_ParseError_unknown_currency() {
42479         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42480         *ret_copy = ParseError_unknown_currency();
42481         uint32_t ret_ref = (uintptr_t)ret_copy;
42482         return ret_ref;
42483 }
42484
42485 uint32_t  __attribute__((export_name("TS_ParseError_unknown_si_prefix"))) TS_ParseError_unknown_si_prefix() {
42486         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42487         *ret_copy = ParseError_unknown_si_prefix();
42488         uint32_t ret_ref = (uintptr_t)ret_copy;
42489         return ret_ref;
42490 }
42491
42492 uint32_t  __attribute__((export_name("TS_ParseError_malformed_hrp"))) TS_ParseError_malformed_hrp() {
42493         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42494         *ret_copy = ParseError_malformed_hrp();
42495         uint32_t ret_ref = (uintptr_t)ret_copy;
42496         return ret_ref;
42497 }
42498
42499 uint32_t  __attribute__((export_name("TS_ParseError_too_short_data_part"))) TS_ParseError_too_short_data_part() {
42500         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42501         *ret_copy = ParseError_too_short_data_part();
42502         uint32_t ret_ref = (uintptr_t)ret_copy;
42503         return ret_ref;
42504 }
42505
42506 uint32_t  __attribute__((export_name("TS_ParseError_unexpected_end_of_tagged_fields"))) TS_ParseError_unexpected_end_of_tagged_fields() {
42507         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42508         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
42509         uint32_t ret_ref = (uintptr_t)ret_copy;
42510         return ret_ref;
42511 }
42512
42513 uint32_t  __attribute__((export_name("TS_ParseError_description_decode_error"))) TS_ParseError_description_decode_error(int32_t a) {
42514         
42515         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42516         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
42517         uint32_t ret_ref = (uintptr_t)ret_copy;
42518         return ret_ref;
42519 }
42520
42521 uint32_t  __attribute__((export_name("TS_ParseError_padding_error"))) TS_ParseError_padding_error() {
42522         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42523         *ret_copy = ParseError_padding_error();
42524         uint32_t ret_ref = (uintptr_t)ret_copy;
42525         return ret_ref;
42526 }
42527
42528 uint32_t  __attribute__((export_name("TS_ParseError_integer_overflow_error"))) TS_ParseError_integer_overflow_error() {
42529         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42530         *ret_copy = ParseError_integer_overflow_error();
42531         uint32_t ret_ref = (uintptr_t)ret_copy;
42532         return ret_ref;
42533 }
42534
42535 uint32_t  __attribute__((export_name("TS_ParseError_invalid_seg_wit_program_length"))) TS_ParseError_invalid_seg_wit_program_length() {
42536         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42537         *ret_copy = ParseError_invalid_seg_wit_program_length();
42538         uint32_t ret_ref = (uintptr_t)ret_copy;
42539         return ret_ref;
42540 }
42541
42542 uint32_t  __attribute__((export_name("TS_ParseError_invalid_pub_key_hash_length"))) TS_ParseError_invalid_pub_key_hash_length() {
42543         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42544         *ret_copy = ParseError_invalid_pub_key_hash_length();
42545         uint32_t ret_ref = (uintptr_t)ret_copy;
42546         return ret_ref;
42547 }
42548
42549 uint32_t  __attribute__((export_name("TS_ParseError_invalid_script_hash_length"))) TS_ParseError_invalid_script_hash_length() {
42550         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42551         *ret_copy = ParseError_invalid_script_hash_length();
42552         uint32_t ret_ref = (uintptr_t)ret_copy;
42553         return ret_ref;
42554 }
42555
42556 uint32_t  __attribute__((export_name("TS_ParseError_invalid_recovery_id"))) TS_ParseError_invalid_recovery_id() {
42557         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42558         *ret_copy = ParseError_invalid_recovery_id();
42559         uint32_t ret_ref = (uintptr_t)ret_copy;
42560         return ret_ref;
42561 }
42562
42563 uint32_t  __attribute__((export_name("TS_ParseError_invalid_slice_length"))) TS_ParseError_invalid_slice_length(jstring a) {
42564         LDKStr a_conv = str_ref_to_owned_c(a);
42565         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42566         *ret_copy = ParseError_invalid_slice_length(a_conv);
42567         uint32_t ret_ref = (uintptr_t)ret_copy;
42568         return ret_ref;
42569 }
42570
42571 uint32_t  __attribute__((export_name("TS_ParseError_skip"))) TS_ParseError_skip() {
42572         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
42573         *ret_copy = ParseError_skip();
42574         uint32_t ret_ref = (uintptr_t)ret_copy;
42575         return ret_ref;
42576 }
42577
42578 void  __attribute__((export_name("TS_ParseOrSemanticError_free"))) TS_ParseOrSemanticError_free(uint32_t this_ptr) {
42579         if ((this_ptr & 1) != 0) return;
42580         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42581         CHECK_ACCESS(this_ptr_ptr);
42582         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
42583         FREE((void*)this_ptr);
42584         ParseOrSemanticError_free(this_ptr_conv);
42585 }
42586
42587 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
42588         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
42589         *ret_copy = ParseOrSemanticError_clone(arg);
42590 uint32_t ret_ref = (uintptr_t)ret_copy;
42591         return ret_ref;
42592 }
42593 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone_ptr"))) TS_ParseOrSemanticError_clone_ptr(uint32_t arg) {
42594         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
42595         uint32_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
42596         return ret_conv;
42597 }
42598
42599 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone"))) TS_ParseOrSemanticError_clone(uint32_t orig) {
42600         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
42601         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
42602         *ret_copy = ParseOrSemanticError_clone(orig_conv);
42603         uint32_t ret_ref = (uintptr_t)ret_copy;
42604         return ret_ref;
42605 }
42606
42607 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_parse_error"))) TS_ParseOrSemanticError_parse_error(uint32_t a) {
42608         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
42609         CHECK_ACCESS(a_ptr);
42610         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
42611         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
42612         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
42613         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
42614         uint32_t ret_ref = (uintptr_t)ret_copy;
42615         return ret_ref;
42616 }
42617
42618 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_semantic_error"))) TS_ParseOrSemanticError_semantic_error(uint32_t a) {
42619         LDKSemanticError a_conv = LDKSemanticError_from_js(a);
42620         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
42621         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
42622         uint32_t ret_ref = (uintptr_t)ret_copy;
42623         return ret_ref;
42624 }
42625
42626 void  __attribute__((export_name("TS_Invoice_free"))) TS_Invoice_free(uint32_t this_obj) {
42627         LDKInvoice this_obj_conv;
42628         this_obj_conv.inner = (void*)(this_obj & (~1));
42629         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42631         Invoice_free(this_obj_conv);
42632 }
42633
42634 jboolean  __attribute__((export_name("TS_Invoice_eq"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
42635         LDKInvoice a_conv;
42636         a_conv.inner = (void*)(a & (~1));
42637         a_conv.is_owned = false;
42638         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42639         LDKInvoice b_conv;
42640         b_conv.inner = (void*)(b & (~1));
42641         b_conv.is_owned = false;
42642         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42643         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
42644         return ret_conv;
42645 }
42646
42647 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
42648         LDKInvoice ret_var = Invoice_clone(arg);
42649 uint32_t ret_ref = 0;
42650 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42651 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42652 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42653 ret_ref = (uintptr_t)ret_var.inner;
42654 if (ret_var.is_owned) {
42655         ret_ref |= 1;
42656 }
42657         return ret_ref;
42658 }
42659 uint32_t  __attribute__((export_name("TS_Invoice_clone_ptr"))) TS_Invoice_clone_ptr(uint32_t arg) {
42660         LDKInvoice arg_conv;
42661         arg_conv.inner = (void*)(arg & (~1));
42662         arg_conv.is_owned = false;
42663         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42664         uint32_t ret_conv = Invoice_clone_ptr(&arg_conv);
42665         return ret_conv;
42666 }
42667
42668 uint32_t  __attribute__((export_name("TS_Invoice_clone"))) TS_Invoice_clone(uint32_t orig) {
42669         LDKInvoice orig_conv;
42670         orig_conv.inner = (void*)(orig & (~1));
42671         orig_conv.is_owned = false;
42672         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42673         LDKInvoice ret_var = Invoice_clone(&orig_conv);
42674         uint32_t ret_ref = 0;
42675         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42676         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42678         ret_ref = (uintptr_t)ret_var.inner;
42679         if (ret_var.is_owned) {
42680                 ret_ref |= 1;
42681         }
42682         return ret_ref;
42683 }
42684
42685 void  __attribute__((export_name("TS_SignedRawInvoice_free"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
42686         LDKSignedRawInvoice this_obj_conv;
42687         this_obj_conv.inner = (void*)(this_obj & (~1));
42688         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42690         SignedRawInvoice_free(this_obj_conv);
42691 }
42692
42693 jboolean  __attribute__((export_name("TS_SignedRawInvoice_eq"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
42694         LDKSignedRawInvoice a_conv;
42695         a_conv.inner = (void*)(a & (~1));
42696         a_conv.is_owned = false;
42697         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42698         LDKSignedRawInvoice b_conv;
42699         b_conv.inner = (void*)(b & (~1));
42700         b_conv.is_owned = false;
42701         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42702         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
42703         return ret_conv;
42704 }
42705
42706 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
42707         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
42708 uint32_t ret_ref = 0;
42709 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42710 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42711 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42712 ret_ref = (uintptr_t)ret_var.inner;
42713 if (ret_var.is_owned) {
42714         ret_ref |= 1;
42715 }
42716         return ret_ref;
42717 }
42718 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone_ptr"))) TS_SignedRawInvoice_clone_ptr(uint32_t arg) {
42719         LDKSignedRawInvoice arg_conv;
42720         arg_conv.inner = (void*)(arg & (~1));
42721         arg_conv.is_owned = false;
42722         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42723         uint32_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
42724         return ret_conv;
42725 }
42726
42727 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone"))) TS_SignedRawInvoice_clone(uint32_t orig) {
42728         LDKSignedRawInvoice orig_conv;
42729         orig_conv.inner = (void*)(orig & (~1));
42730         orig_conv.is_owned = false;
42731         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42732         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
42733         uint32_t ret_ref = 0;
42734         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42735         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42737         ret_ref = (uintptr_t)ret_var.inner;
42738         if (ret_var.is_owned) {
42739                 ret_ref |= 1;
42740         }
42741         return ret_ref;
42742 }
42743
42744 void  __attribute__((export_name("TS_RawInvoice_free"))) TS_RawInvoice_free(uint32_t this_obj) {
42745         LDKRawInvoice this_obj_conv;
42746         this_obj_conv.inner = (void*)(this_obj & (~1));
42747         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42749         RawInvoice_free(this_obj_conv);
42750 }
42751
42752 uint32_t  __attribute__((export_name("TS_RawInvoice_get_data"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
42753         LDKRawInvoice this_ptr_conv;
42754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42755         this_ptr_conv.is_owned = false;
42756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42757         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
42758         uint32_t ret_ref = 0;
42759         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42760         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42762         ret_ref = (uintptr_t)ret_var.inner;
42763         if (ret_var.is_owned) {
42764                 ret_ref |= 1;
42765         }
42766         return ret_ref;
42767 }
42768
42769 void  __attribute__((export_name("TS_RawInvoice_set_data"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
42770         LDKRawInvoice this_ptr_conv;
42771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42772         this_ptr_conv.is_owned = false;
42773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42774         LDKRawDataPart val_conv;
42775         val_conv.inner = (void*)(val & (~1));
42776         val_conv.is_owned = (val & 1) || (val == 0);
42777         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42778         val_conv = RawDataPart_clone(&val_conv);
42779         RawInvoice_set_data(&this_ptr_conv, val_conv);
42780 }
42781
42782 jboolean  __attribute__((export_name("TS_RawInvoice_eq"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
42783         LDKRawInvoice a_conv;
42784         a_conv.inner = (void*)(a & (~1));
42785         a_conv.is_owned = false;
42786         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42787         LDKRawInvoice b_conv;
42788         b_conv.inner = (void*)(b & (~1));
42789         b_conv.is_owned = false;
42790         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42791         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
42792         return ret_conv;
42793 }
42794
42795 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
42796         LDKRawInvoice ret_var = RawInvoice_clone(arg);
42797 uint32_t ret_ref = 0;
42798 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42799 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42800 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42801 ret_ref = (uintptr_t)ret_var.inner;
42802 if (ret_var.is_owned) {
42803         ret_ref |= 1;
42804 }
42805         return ret_ref;
42806 }
42807 uint32_t  __attribute__((export_name("TS_RawInvoice_clone_ptr"))) TS_RawInvoice_clone_ptr(uint32_t arg) {
42808         LDKRawInvoice arg_conv;
42809         arg_conv.inner = (void*)(arg & (~1));
42810         arg_conv.is_owned = false;
42811         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42812         uint32_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
42813         return ret_conv;
42814 }
42815
42816 uint32_t  __attribute__((export_name("TS_RawInvoice_clone"))) TS_RawInvoice_clone(uint32_t orig) {
42817         LDKRawInvoice orig_conv;
42818         orig_conv.inner = (void*)(orig & (~1));
42819         orig_conv.is_owned = false;
42820         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42821         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
42822         uint32_t ret_ref = 0;
42823         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42824         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42826         ret_ref = (uintptr_t)ret_var.inner;
42827         if (ret_var.is_owned) {
42828                 ret_ref |= 1;
42829         }
42830         return ret_ref;
42831 }
42832
42833 void  __attribute__((export_name("TS_RawDataPart_free"))) TS_RawDataPart_free(uint32_t this_obj) {
42834         LDKRawDataPart this_obj_conv;
42835         this_obj_conv.inner = (void*)(this_obj & (~1));
42836         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42838         RawDataPart_free(this_obj_conv);
42839 }
42840
42841 uint32_t  __attribute__((export_name("TS_RawDataPart_get_timestamp"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
42842         LDKRawDataPart this_ptr_conv;
42843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42844         this_ptr_conv.is_owned = false;
42845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42846         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
42847         uint32_t ret_ref = 0;
42848         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42849         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42850         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42851         ret_ref = (uintptr_t)ret_var.inner;
42852         if (ret_var.is_owned) {
42853                 ret_ref |= 1;
42854         }
42855         return ret_ref;
42856 }
42857
42858 void  __attribute__((export_name("TS_RawDataPart_set_timestamp"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
42859         LDKRawDataPart this_ptr_conv;
42860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42861         this_ptr_conv.is_owned = false;
42862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42863         LDKPositiveTimestamp val_conv;
42864         val_conv.inner = (void*)(val & (~1));
42865         val_conv.is_owned = (val & 1) || (val == 0);
42866         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42867         val_conv = PositiveTimestamp_clone(&val_conv);
42868         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
42869 }
42870
42871 jboolean  __attribute__((export_name("TS_RawDataPart_eq"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
42872         LDKRawDataPart a_conv;
42873         a_conv.inner = (void*)(a & (~1));
42874         a_conv.is_owned = false;
42875         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42876         LDKRawDataPart b_conv;
42877         b_conv.inner = (void*)(b & (~1));
42878         b_conv.is_owned = false;
42879         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42880         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
42881         return ret_conv;
42882 }
42883
42884 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
42885         LDKRawDataPart ret_var = RawDataPart_clone(arg);
42886 uint32_t ret_ref = 0;
42887 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42888 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42889 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42890 ret_ref = (uintptr_t)ret_var.inner;
42891 if (ret_var.is_owned) {
42892         ret_ref |= 1;
42893 }
42894         return ret_ref;
42895 }
42896 uint32_t  __attribute__((export_name("TS_RawDataPart_clone_ptr"))) TS_RawDataPart_clone_ptr(uint32_t arg) {
42897         LDKRawDataPart arg_conv;
42898         arg_conv.inner = (void*)(arg & (~1));
42899         arg_conv.is_owned = false;
42900         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42901         uint32_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
42902         return ret_conv;
42903 }
42904
42905 uint32_t  __attribute__((export_name("TS_RawDataPart_clone"))) TS_RawDataPart_clone(uint32_t orig) {
42906         LDKRawDataPart orig_conv;
42907         orig_conv.inner = (void*)(orig & (~1));
42908         orig_conv.is_owned = false;
42909         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42910         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
42911         uint32_t ret_ref = 0;
42912         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42913         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42915         ret_ref = (uintptr_t)ret_var.inner;
42916         if (ret_var.is_owned) {
42917                 ret_ref |= 1;
42918         }
42919         return ret_ref;
42920 }
42921
42922 void  __attribute__((export_name("TS_PositiveTimestamp_free"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
42923         LDKPositiveTimestamp this_obj_conv;
42924         this_obj_conv.inner = (void*)(this_obj & (~1));
42925         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42927         PositiveTimestamp_free(this_obj_conv);
42928 }
42929
42930 jboolean  __attribute__((export_name("TS_PositiveTimestamp_eq"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
42931         LDKPositiveTimestamp a_conv;
42932         a_conv.inner = (void*)(a & (~1));
42933         a_conv.is_owned = false;
42934         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42935         LDKPositiveTimestamp b_conv;
42936         b_conv.inner = (void*)(b & (~1));
42937         b_conv.is_owned = false;
42938         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42939         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
42940         return ret_conv;
42941 }
42942
42943 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
42944         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
42945 uint32_t ret_ref = 0;
42946 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42947 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42948 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42949 ret_ref = (uintptr_t)ret_var.inner;
42950 if (ret_var.is_owned) {
42951         ret_ref |= 1;
42952 }
42953         return ret_ref;
42954 }
42955 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone_ptr"))) TS_PositiveTimestamp_clone_ptr(uint32_t arg) {
42956         LDKPositiveTimestamp arg_conv;
42957         arg_conv.inner = (void*)(arg & (~1));
42958         arg_conv.is_owned = false;
42959         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42960         uint32_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
42961         return ret_conv;
42962 }
42963
42964 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone"))) TS_PositiveTimestamp_clone(uint32_t orig) {
42965         LDKPositiveTimestamp orig_conv;
42966         orig_conv.inner = (void*)(orig & (~1));
42967         orig_conv.is_owned = false;
42968         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42969         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
42970         uint32_t ret_ref = 0;
42971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42974         ret_ref = (uintptr_t)ret_var.inner;
42975         if (ret_var.is_owned) {
42976                 ret_ref |= 1;
42977         }
42978         return ret_ref;
42979 }
42980
42981 uint32_t  __attribute__((export_name("TS_SiPrefix_clone"))) TS_SiPrefix_clone(uint32_t orig) {
42982         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
42983         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
42984         return ret_conv;
42985 }
42986
42987 uint32_t  __attribute__((export_name("TS_SiPrefix_milli"))) TS_SiPrefix_milli() {
42988         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
42989         return ret_conv;
42990 }
42991
42992 uint32_t  __attribute__((export_name("TS_SiPrefix_micro"))) TS_SiPrefix_micro() {
42993         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
42994         return ret_conv;
42995 }
42996
42997 uint32_t  __attribute__((export_name("TS_SiPrefix_nano"))) TS_SiPrefix_nano() {
42998         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
42999         return ret_conv;
43000 }
43001
43002 uint32_t  __attribute__((export_name("TS_SiPrefix_pico"))) TS_SiPrefix_pico() {
43003         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
43004         return ret_conv;
43005 }
43006
43007 jboolean  __attribute__((export_name("TS_SiPrefix_eq"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
43008         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
43009         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
43010         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
43011         return ret_conv;
43012 }
43013
43014 int64_t  __attribute__((export_name("TS_SiPrefix_multiplier"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
43015         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
43016         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
43017         return ret_conv;
43018 }
43019
43020 uint32_t  __attribute__((export_name("TS_Currency_clone"))) TS_Currency_clone(uint32_t orig) {
43021         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
43022         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
43023         return ret_conv;
43024 }
43025
43026 uint32_t  __attribute__((export_name("TS_Currency_bitcoin"))) TS_Currency_bitcoin() {
43027         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
43028         return ret_conv;
43029 }
43030
43031 uint32_t  __attribute__((export_name("TS_Currency_bitcoin_testnet"))) TS_Currency_bitcoin_testnet() {
43032         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
43033         return ret_conv;
43034 }
43035
43036 uint32_t  __attribute__((export_name("TS_Currency_regtest"))) TS_Currency_regtest() {
43037         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
43038         return ret_conv;
43039 }
43040
43041 uint32_t  __attribute__((export_name("TS_Currency_simnet"))) TS_Currency_simnet() {
43042         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
43043         return ret_conv;
43044 }
43045
43046 uint32_t  __attribute__((export_name("TS_Currency_signet"))) TS_Currency_signet() {
43047         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
43048         return ret_conv;
43049 }
43050
43051 int64_t  __attribute__((export_name("TS_Currency_hash"))) TS_Currency_hash(uint32_t o) {
43052         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
43053         int64_t ret_conv = Currency_hash(o_conv);
43054         return ret_conv;
43055 }
43056
43057 jboolean  __attribute__((export_name("TS_Currency_eq"))) TS_Currency_eq(uint32_t a, uint32_t b) {
43058         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
43059         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
43060         jboolean ret_conv = Currency_eq(a_conv, b_conv);
43061         return ret_conv;
43062 }
43063
43064 void  __attribute__((export_name("TS_Sha256_free"))) TS_Sha256_free(uint32_t this_obj) {
43065         LDKSha256 this_obj_conv;
43066         this_obj_conv.inner = (void*)(this_obj & (~1));
43067         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43069         Sha256_free(this_obj_conv);
43070 }
43071
43072 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
43073         LDKSha256 ret_var = Sha256_clone(arg);
43074 uint32_t ret_ref = 0;
43075 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43076 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43077 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43078 ret_ref = (uintptr_t)ret_var.inner;
43079 if (ret_var.is_owned) {
43080         ret_ref |= 1;
43081 }
43082         return ret_ref;
43083 }
43084 uint32_t  __attribute__((export_name("TS_Sha256_clone_ptr"))) TS_Sha256_clone_ptr(uint32_t arg) {
43085         LDKSha256 arg_conv;
43086         arg_conv.inner = (void*)(arg & (~1));
43087         arg_conv.is_owned = false;
43088         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43089         uint32_t ret_conv = Sha256_clone_ptr(&arg_conv);
43090         return ret_conv;
43091 }
43092
43093 uint32_t  __attribute__((export_name("TS_Sha256_clone"))) TS_Sha256_clone(uint32_t orig) {
43094         LDKSha256 orig_conv;
43095         orig_conv.inner = (void*)(orig & (~1));
43096         orig_conv.is_owned = false;
43097         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43098         LDKSha256 ret_var = Sha256_clone(&orig_conv);
43099         uint32_t ret_ref = 0;
43100         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43101         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43103         ret_ref = (uintptr_t)ret_var.inner;
43104         if (ret_var.is_owned) {
43105                 ret_ref |= 1;
43106         }
43107         return ret_ref;
43108 }
43109
43110 int64_t  __attribute__((export_name("TS_Sha256_hash"))) TS_Sha256_hash(uint32_t o) {
43111         LDKSha256 o_conv;
43112         o_conv.inner = (void*)(o & (~1));
43113         o_conv.is_owned = false;
43114         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43115         int64_t ret_conv = Sha256_hash(&o_conv);
43116         return ret_conv;
43117 }
43118
43119 jboolean  __attribute__((export_name("TS_Sha256_eq"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
43120         LDKSha256 a_conv;
43121         a_conv.inner = (void*)(a & (~1));
43122         a_conv.is_owned = false;
43123         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43124         LDKSha256 b_conv;
43125         b_conv.inner = (void*)(b & (~1));
43126         b_conv.is_owned = false;
43127         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43128         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
43129         return ret_conv;
43130 }
43131
43132 void  __attribute__((export_name("TS_Description_free"))) TS_Description_free(uint32_t this_obj) {
43133         LDKDescription this_obj_conv;
43134         this_obj_conv.inner = (void*)(this_obj & (~1));
43135         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43137         Description_free(this_obj_conv);
43138 }
43139
43140 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
43141         LDKDescription ret_var = Description_clone(arg);
43142 uint32_t ret_ref = 0;
43143 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43144 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43145 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43146 ret_ref = (uintptr_t)ret_var.inner;
43147 if (ret_var.is_owned) {
43148         ret_ref |= 1;
43149 }
43150         return ret_ref;
43151 }
43152 uint32_t  __attribute__((export_name("TS_Description_clone_ptr"))) TS_Description_clone_ptr(uint32_t arg) {
43153         LDKDescription arg_conv;
43154         arg_conv.inner = (void*)(arg & (~1));
43155         arg_conv.is_owned = false;
43156         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43157         uint32_t ret_conv = Description_clone_ptr(&arg_conv);
43158         return ret_conv;
43159 }
43160
43161 uint32_t  __attribute__((export_name("TS_Description_clone"))) TS_Description_clone(uint32_t orig) {
43162         LDKDescription orig_conv;
43163         orig_conv.inner = (void*)(orig & (~1));
43164         orig_conv.is_owned = false;
43165         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43166         LDKDescription ret_var = Description_clone(&orig_conv);
43167         uint32_t ret_ref = 0;
43168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43171         ret_ref = (uintptr_t)ret_var.inner;
43172         if (ret_var.is_owned) {
43173                 ret_ref |= 1;
43174         }
43175         return ret_ref;
43176 }
43177
43178 int64_t  __attribute__((export_name("TS_Description_hash"))) TS_Description_hash(uint32_t o) {
43179         LDKDescription o_conv;
43180         o_conv.inner = (void*)(o & (~1));
43181         o_conv.is_owned = false;
43182         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43183         int64_t ret_conv = Description_hash(&o_conv);
43184         return ret_conv;
43185 }
43186
43187 jboolean  __attribute__((export_name("TS_Description_eq"))) TS_Description_eq(uint32_t a, uint32_t b) {
43188         LDKDescription a_conv;
43189         a_conv.inner = (void*)(a & (~1));
43190         a_conv.is_owned = false;
43191         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43192         LDKDescription b_conv;
43193         b_conv.inner = (void*)(b & (~1));
43194         b_conv.is_owned = false;
43195         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43196         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
43197         return ret_conv;
43198 }
43199
43200 void  __attribute__((export_name("TS_PayeePubKey_free"))) TS_PayeePubKey_free(uint32_t this_obj) {
43201         LDKPayeePubKey this_obj_conv;
43202         this_obj_conv.inner = (void*)(this_obj & (~1));
43203         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43205         PayeePubKey_free(this_obj_conv);
43206 }
43207
43208 int8_tArray  __attribute__((export_name("TS_PayeePubKey_get_a"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
43209         LDKPayeePubKey this_ptr_conv;
43210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43211         this_ptr_conv.is_owned = false;
43212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43213         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
43214         memcpy(ret_arr->elems, PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
43215         return ret_arr;
43216 }
43217
43218 void  __attribute__((export_name("TS_PayeePubKey_set_a"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
43219         LDKPayeePubKey this_ptr_conv;
43220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43221         this_ptr_conv.is_owned = false;
43222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43223         LDKPublicKey val_ref;
43224         CHECK(val->arr_len == 33);
43225         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
43226         PayeePubKey_set_a(&this_ptr_conv, val_ref);
43227 }
43228
43229 uint32_t  __attribute__((export_name("TS_PayeePubKey_new"))) TS_PayeePubKey_new(int8_tArray a_arg) {
43230         LDKPublicKey a_arg_ref;
43231         CHECK(a_arg->arr_len == 33);
43232         memcpy(a_arg_ref.compressed_form, a_arg->elems, 33); FREE(a_arg);
43233         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
43234         uint32_t ret_ref = 0;
43235         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43236         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43238         ret_ref = (uintptr_t)ret_var.inner;
43239         if (ret_var.is_owned) {
43240                 ret_ref |= 1;
43241         }
43242         return ret_ref;
43243 }
43244
43245 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
43246         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
43247 uint32_t ret_ref = 0;
43248 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43249 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43250 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43251 ret_ref = (uintptr_t)ret_var.inner;
43252 if (ret_var.is_owned) {
43253         ret_ref |= 1;
43254 }
43255         return ret_ref;
43256 }
43257 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone_ptr"))) TS_PayeePubKey_clone_ptr(uint32_t arg) {
43258         LDKPayeePubKey arg_conv;
43259         arg_conv.inner = (void*)(arg & (~1));
43260         arg_conv.is_owned = false;
43261         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43262         uint32_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
43263         return ret_conv;
43264 }
43265
43266 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone"))) TS_PayeePubKey_clone(uint32_t orig) {
43267         LDKPayeePubKey orig_conv;
43268         orig_conv.inner = (void*)(orig & (~1));
43269         orig_conv.is_owned = false;
43270         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43271         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
43272         uint32_t ret_ref = 0;
43273         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43274         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43276         ret_ref = (uintptr_t)ret_var.inner;
43277         if (ret_var.is_owned) {
43278                 ret_ref |= 1;
43279         }
43280         return ret_ref;
43281 }
43282
43283 int64_t  __attribute__((export_name("TS_PayeePubKey_hash"))) TS_PayeePubKey_hash(uint32_t o) {
43284         LDKPayeePubKey o_conv;
43285         o_conv.inner = (void*)(o & (~1));
43286         o_conv.is_owned = false;
43287         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43288         int64_t ret_conv = PayeePubKey_hash(&o_conv);
43289         return ret_conv;
43290 }
43291
43292 jboolean  __attribute__((export_name("TS_PayeePubKey_eq"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
43293         LDKPayeePubKey a_conv;
43294         a_conv.inner = (void*)(a & (~1));
43295         a_conv.is_owned = false;
43296         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43297         LDKPayeePubKey b_conv;
43298         b_conv.inner = (void*)(b & (~1));
43299         b_conv.is_owned = false;
43300         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43301         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
43302         return ret_conv;
43303 }
43304
43305 void  __attribute__((export_name("TS_ExpiryTime_free"))) TS_ExpiryTime_free(uint32_t this_obj) {
43306         LDKExpiryTime this_obj_conv;
43307         this_obj_conv.inner = (void*)(this_obj & (~1));
43308         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43310         ExpiryTime_free(this_obj_conv);
43311 }
43312
43313 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
43314         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
43315 uint32_t ret_ref = 0;
43316 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43317 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43318 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43319 ret_ref = (uintptr_t)ret_var.inner;
43320 if (ret_var.is_owned) {
43321         ret_ref |= 1;
43322 }
43323         return ret_ref;
43324 }
43325 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone_ptr"))) TS_ExpiryTime_clone_ptr(uint32_t arg) {
43326         LDKExpiryTime arg_conv;
43327         arg_conv.inner = (void*)(arg & (~1));
43328         arg_conv.is_owned = false;
43329         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43330         uint32_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
43331         return ret_conv;
43332 }
43333
43334 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone"))) TS_ExpiryTime_clone(uint32_t orig) {
43335         LDKExpiryTime orig_conv;
43336         orig_conv.inner = (void*)(orig & (~1));
43337         orig_conv.is_owned = false;
43338         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43339         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
43340         uint32_t ret_ref = 0;
43341         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43342         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43344         ret_ref = (uintptr_t)ret_var.inner;
43345         if (ret_var.is_owned) {
43346                 ret_ref |= 1;
43347         }
43348         return ret_ref;
43349 }
43350
43351 int64_t  __attribute__((export_name("TS_ExpiryTime_hash"))) TS_ExpiryTime_hash(uint32_t o) {
43352         LDKExpiryTime o_conv;
43353         o_conv.inner = (void*)(o & (~1));
43354         o_conv.is_owned = false;
43355         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43356         int64_t ret_conv = ExpiryTime_hash(&o_conv);
43357         return ret_conv;
43358 }
43359
43360 jboolean  __attribute__((export_name("TS_ExpiryTime_eq"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
43361         LDKExpiryTime a_conv;
43362         a_conv.inner = (void*)(a & (~1));
43363         a_conv.is_owned = false;
43364         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43365         LDKExpiryTime b_conv;
43366         b_conv.inner = (void*)(b & (~1));
43367         b_conv.is_owned = false;
43368         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43369         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
43370         return ret_conv;
43371 }
43372
43373 void  __attribute__((export_name("TS_MinFinalCltvExpiry_free"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
43374         LDKMinFinalCltvExpiry this_obj_conv;
43375         this_obj_conv.inner = (void*)(this_obj & (~1));
43376         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43378         MinFinalCltvExpiry_free(this_obj_conv);
43379 }
43380
43381 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_get_a"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
43382         LDKMinFinalCltvExpiry this_ptr_conv;
43383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43384         this_ptr_conv.is_owned = false;
43385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43386         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
43387         return ret_conv;
43388 }
43389
43390 void  __attribute__((export_name("TS_MinFinalCltvExpiry_set_a"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
43391         LDKMinFinalCltvExpiry this_ptr_conv;
43392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43393         this_ptr_conv.is_owned = false;
43394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43395         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
43396 }
43397
43398 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_new"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
43399         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
43400         uint32_t ret_ref = 0;
43401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43404         ret_ref = (uintptr_t)ret_var.inner;
43405         if (ret_var.is_owned) {
43406                 ret_ref |= 1;
43407         }
43408         return ret_ref;
43409 }
43410
43411 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
43412         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
43413 uint32_t ret_ref = 0;
43414 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43415 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43416 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43417 ret_ref = (uintptr_t)ret_var.inner;
43418 if (ret_var.is_owned) {
43419         ret_ref |= 1;
43420 }
43421         return ret_ref;
43422 }
43423 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone_ptr"))) TS_MinFinalCltvExpiry_clone_ptr(uint32_t arg) {
43424         LDKMinFinalCltvExpiry arg_conv;
43425         arg_conv.inner = (void*)(arg & (~1));
43426         arg_conv.is_owned = false;
43427         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43428         uint32_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
43429         return ret_conv;
43430 }
43431
43432 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
43433         LDKMinFinalCltvExpiry orig_conv;
43434         orig_conv.inner = (void*)(orig & (~1));
43435         orig_conv.is_owned = false;
43436         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43437         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
43438         uint32_t ret_ref = 0;
43439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43442         ret_ref = (uintptr_t)ret_var.inner;
43443         if (ret_var.is_owned) {
43444                 ret_ref |= 1;
43445         }
43446         return ret_ref;
43447 }
43448
43449 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_hash"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
43450         LDKMinFinalCltvExpiry o_conv;
43451         o_conv.inner = (void*)(o & (~1));
43452         o_conv.is_owned = false;
43453         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43454         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
43455         return ret_conv;
43456 }
43457
43458 jboolean  __attribute__((export_name("TS_MinFinalCltvExpiry_eq"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
43459         LDKMinFinalCltvExpiry a_conv;
43460         a_conv.inner = (void*)(a & (~1));
43461         a_conv.is_owned = false;
43462         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43463         LDKMinFinalCltvExpiry b_conv;
43464         b_conv.inner = (void*)(b & (~1));
43465         b_conv.is_owned = false;
43466         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43467         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
43468         return ret_conv;
43469 }
43470
43471 void  __attribute__((export_name("TS_Fallback_free"))) TS_Fallback_free(uint32_t this_ptr) {
43472         if ((this_ptr & 1) != 0) return;
43473         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43474         CHECK_ACCESS(this_ptr_ptr);
43475         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
43476         FREE((void*)this_ptr);
43477         Fallback_free(this_ptr_conv);
43478 }
43479
43480 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
43481         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43482         *ret_copy = Fallback_clone(arg);
43483 uint32_t ret_ref = (uintptr_t)ret_copy;
43484         return ret_ref;
43485 }
43486 uint32_t  __attribute__((export_name("TS_Fallback_clone_ptr"))) TS_Fallback_clone_ptr(uint32_t arg) {
43487         LDKFallback* arg_conv = (LDKFallback*)arg;
43488         uint32_t ret_conv = Fallback_clone_ptr(arg_conv);
43489         return ret_conv;
43490 }
43491
43492 uint32_t  __attribute__((export_name("TS_Fallback_clone"))) TS_Fallback_clone(uint32_t orig) {
43493         LDKFallback* orig_conv = (LDKFallback*)orig;
43494         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43495         *ret_copy = Fallback_clone(orig_conv);
43496         uint32_t ret_ref = (uintptr_t)ret_copy;
43497         return ret_ref;
43498 }
43499
43500 uint32_t  __attribute__((export_name("TS_Fallback_seg_wit_program"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
43501         
43502         LDKCVec_u8Z program_ref;
43503         program_ref.datalen = program->arr_len;
43504         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
43505         memcpy(program_ref.data, program->elems, program_ref.datalen); FREE(program);
43506         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43507         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
43508         uint32_t ret_ref = (uintptr_t)ret_copy;
43509         return ret_ref;
43510 }
43511
43512 uint32_t  __attribute__((export_name("TS_Fallback_pub_key_hash"))) TS_Fallback_pub_key_hash(int8_tArray a) {
43513         LDKTwentyBytes a_ref;
43514         CHECK(a->arr_len == 20);
43515         memcpy(a_ref.data, a->elems, 20); FREE(a);
43516         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43517         *ret_copy = Fallback_pub_key_hash(a_ref);
43518         uint32_t ret_ref = (uintptr_t)ret_copy;
43519         return ret_ref;
43520 }
43521
43522 uint32_t  __attribute__((export_name("TS_Fallback_script_hash"))) TS_Fallback_script_hash(int8_tArray a) {
43523         LDKTwentyBytes a_ref;
43524         CHECK(a->arr_len == 20);
43525         memcpy(a_ref.data, a->elems, 20); FREE(a);
43526         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
43527         *ret_copy = Fallback_script_hash(a_ref);
43528         uint32_t ret_ref = (uintptr_t)ret_copy;
43529         return ret_ref;
43530 }
43531
43532 int64_t  __attribute__((export_name("TS_Fallback_hash"))) TS_Fallback_hash(uint32_t o) {
43533         LDKFallback* o_conv = (LDKFallback*)o;
43534         int64_t ret_conv = Fallback_hash(o_conv);
43535         return ret_conv;
43536 }
43537
43538 jboolean  __attribute__((export_name("TS_Fallback_eq"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
43539         LDKFallback* a_conv = (LDKFallback*)a;
43540         LDKFallback* b_conv = (LDKFallback*)b;
43541         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
43542         return ret_conv;
43543 }
43544
43545 void  __attribute__((export_name("TS_InvoiceSignature_free"))) TS_InvoiceSignature_free(uint32_t this_obj) {
43546         LDKInvoiceSignature this_obj_conv;
43547         this_obj_conv.inner = (void*)(this_obj & (~1));
43548         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43550         InvoiceSignature_free(this_obj_conv);
43551 }
43552
43553 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
43554         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
43555 uint32_t ret_ref = 0;
43556 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43557 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43558 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43559 ret_ref = (uintptr_t)ret_var.inner;
43560 if (ret_var.is_owned) {
43561         ret_ref |= 1;
43562 }
43563         return ret_ref;
43564 }
43565 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone_ptr"))) TS_InvoiceSignature_clone_ptr(uint32_t arg) {
43566         LDKInvoiceSignature arg_conv;
43567         arg_conv.inner = (void*)(arg & (~1));
43568         arg_conv.is_owned = false;
43569         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43570         uint32_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
43571         return ret_conv;
43572 }
43573
43574 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone"))) TS_InvoiceSignature_clone(uint32_t orig) {
43575         LDKInvoiceSignature orig_conv;
43576         orig_conv.inner = (void*)(orig & (~1));
43577         orig_conv.is_owned = false;
43578         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43579         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
43580         uint32_t ret_ref = 0;
43581         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43582         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43584         ret_ref = (uintptr_t)ret_var.inner;
43585         if (ret_var.is_owned) {
43586                 ret_ref |= 1;
43587         }
43588         return ret_ref;
43589 }
43590
43591 jboolean  __attribute__((export_name("TS_InvoiceSignature_eq"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
43592         LDKInvoiceSignature a_conv;
43593         a_conv.inner = (void*)(a & (~1));
43594         a_conv.is_owned = false;
43595         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43596         LDKInvoiceSignature b_conv;
43597         b_conv.inner = (void*)(b & (~1));
43598         b_conv.is_owned = false;
43599         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43600         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
43601         return ret_conv;
43602 }
43603
43604 void  __attribute__((export_name("TS_PrivateRoute_free"))) TS_PrivateRoute_free(uint32_t this_obj) {
43605         LDKPrivateRoute this_obj_conv;
43606         this_obj_conv.inner = (void*)(this_obj & (~1));
43607         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43609         PrivateRoute_free(this_obj_conv);
43610 }
43611
43612 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
43613         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
43614 uint32_t ret_ref = 0;
43615 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43616 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43617 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43618 ret_ref = (uintptr_t)ret_var.inner;
43619 if (ret_var.is_owned) {
43620         ret_ref |= 1;
43621 }
43622         return ret_ref;
43623 }
43624 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone_ptr"))) TS_PrivateRoute_clone_ptr(uint32_t arg) {
43625         LDKPrivateRoute arg_conv;
43626         arg_conv.inner = (void*)(arg & (~1));
43627         arg_conv.is_owned = false;
43628         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43629         uint32_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
43630         return ret_conv;
43631 }
43632
43633 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone"))) TS_PrivateRoute_clone(uint32_t orig) {
43634         LDKPrivateRoute orig_conv;
43635         orig_conv.inner = (void*)(orig & (~1));
43636         orig_conv.is_owned = false;
43637         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43638         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
43639         uint32_t ret_ref = 0;
43640         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43641         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43643         ret_ref = (uintptr_t)ret_var.inner;
43644         if (ret_var.is_owned) {
43645                 ret_ref |= 1;
43646         }
43647         return ret_ref;
43648 }
43649
43650 int64_t  __attribute__((export_name("TS_PrivateRoute_hash"))) TS_PrivateRoute_hash(uint32_t o) {
43651         LDKPrivateRoute o_conv;
43652         o_conv.inner = (void*)(o & (~1));
43653         o_conv.is_owned = false;
43654         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43655         int64_t ret_conv = PrivateRoute_hash(&o_conv);
43656         return ret_conv;
43657 }
43658
43659 jboolean  __attribute__((export_name("TS_PrivateRoute_eq"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
43660         LDKPrivateRoute a_conv;
43661         a_conv.inner = (void*)(a & (~1));
43662         a_conv.is_owned = false;
43663         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43664         LDKPrivateRoute b_conv;
43665         b_conv.inner = (void*)(b & (~1));
43666         b_conv.is_owned = false;
43667         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43668         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
43669         return ret_conv;
43670 }
43671
43672 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_into_parts"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
43673         LDKSignedRawInvoice this_arg_conv;
43674         this_arg_conv.inner = (void*)(this_arg & (~1));
43675         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
43676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43677         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
43678         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
43679         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
43680         return ((uint32_t)ret_conv);
43681 }
43682
43683 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_raw_invoice"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
43684         LDKSignedRawInvoice this_arg_conv;
43685         this_arg_conv.inner = (void*)(this_arg & (~1));
43686         this_arg_conv.is_owned = false;
43687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43688         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
43689         uint32_t ret_ref = 0;
43690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43693         ret_ref = (uintptr_t)ret_var.inner;
43694         if (ret_var.is_owned) {
43695                 ret_ref |= 1;
43696         }
43697         return ret_ref;
43698 }
43699
43700 int8_tArray  __attribute__((export_name("TS_SignedRawInvoice_hash"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
43701         LDKSignedRawInvoice this_arg_conv;
43702         this_arg_conv.inner = (void*)(this_arg & (~1));
43703         this_arg_conv.is_owned = false;
43704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43705         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
43706         memcpy(ret_arr->elems, *SignedRawInvoice_hash(&this_arg_conv), 32);
43707         return ret_arr;
43708 }
43709
43710 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_signature"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
43711         LDKSignedRawInvoice this_arg_conv;
43712         this_arg_conv.inner = (void*)(this_arg & (~1));
43713         this_arg_conv.is_owned = false;
43714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43715         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
43716         uint32_t ret_ref = 0;
43717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43720         ret_ref = (uintptr_t)ret_var.inner;
43721         if (ret_var.is_owned) {
43722                 ret_ref |= 1;
43723         }
43724         return ret_ref;
43725 }
43726
43727 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_recover_payee_pub_key"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
43728         LDKSignedRawInvoice this_arg_conv;
43729         this_arg_conv.inner = (void*)(this_arg & (~1));
43730         this_arg_conv.is_owned = false;
43731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43732         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
43733         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
43734         return (uint32_t)ret_conv;
43735 }
43736
43737 jboolean  __attribute__((export_name("TS_SignedRawInvoice_check_signature"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
43738         LDKSignedRawInvoice this_arg_conv;
43739         this_arg_conv.inner = (void*)(this_arg & (~1));
43740         this_arg_conv.is_owned = false;
43741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43742         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
43743         return ret_conv;
43744 }
43745
43746 int8_tArray  __attribute__((export_name("TS_RawInvoice_hash"))) TS_RawInvoice_hash(uint32_t this_arg) {
43747         LDKRawInvoice this_arg_conv;
43748         this_arg_conv.inner = (void*)(this_arg & (~1));
43749         this_arg_conv.is_owned = false;
43750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43751         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
43752         memcpy(ret_arr->elems, RawInvoice_hash(&this_arg_conv).data, 32);
43753         return ret_arr;
43754 }
43755
43756 uint32_t  __attribute__((export_name("TS_RawInvoice_payment_hash"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
43757         LDKRawInvoice this_arg_conv;
43758         this_arg_conv.inner = (void*)(this_arg & (~1));
43759         this_arg_conv.is_owned = false;
43760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43761         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
43762         uint32_t ret_ref = 0;
43763         if ((uintptr_t)ret_var.inner > 4096) {
43764                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43765                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43767                 ret_ref = (uintptr_t)ret_var.inner;
43768                 if (ret_var.is_owned) {
43769                         ret_ref |= 1;
43770                 }
43771         }
43772         return ret_ref;
43773 }
43774
43775 uint32_t  __attribute__((export_name("TS_RawInvoice_description"))) TS_RawInvoice_description(uint32_t this_arg) {
43776         LDKRawInvoice this_arg_conv;
43777         this_arg_conv.inner = (void*)(this_arg & (~1));
43778         this_arg_conv.is_owned = false;
43779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43780         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
43781         uint32_t ret_ref = 0;
43782         if ((uintptr_t)ret_var.inner > 4096) {
43783                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43784                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43786                 ret_ref = (uintptr_t)ret_var.inner;
43787                 if (ret_var.is_owned) {
43788                         ret_ref |= 1;
43789                 }
43790         }
43791         return ret_ref;
43792 }
43793
43794 uint32_t  __attribute__((export_name("TS_RawInvoice_payee_pub_key"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
43795         LDKRawInvoice this_arg_conv;
43796         this_arg_conv.inner = (void*)(this_arg & (~1));
43797         this_arg_conv.is_owned = false;
43798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43799         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
43800         uint32_t ret_ref = 0;
43801         if ((uintptr_t)ret_var.inner > 4096) {
43802                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43803                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43805                 ret_ref = (uintptr_t)ret_var.inner;
43806                 if (ret_var.is_owned) {
43807                         ret_ref |= 1;
43808                 }
43809         }
43810         return ret_ref;
43811 }
43812
43813 uint32_t  __attribute__((export_name("TS_RawInvoice_description_hash"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
43814         LDKRawInvoice this_arg_conv;
43815         this_arg_conv.inner = (void*)(this_arg & (~1));
43816         this_arg_conv.is_owned = false;
43817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43818         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
43819         uint32_t ret_ref = 0;
43820         if ((uintptr_t)ret_var.inner > 4096) {
43821                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43822                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43824                 ret_ref = (uintptr_t)ret_var.inner;
43825                 if (ret_var.is_owned) {
43826                         ret_ref |= 1;
43827                 }
43828         }
43829         return ret_ref;
43830 }
43831
43832 uint32_t  __attribute__((export_name("TS_RawInvoice_expiry_time"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
43833         LDKRawInvoice this_arg_conv;
43834         this_arg_conv.inner = (void*)(this_arg & (~1));
43835         this_arg_conv.is_owned = false;
43836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43837         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
43838         uint32_t ret_ref = 0;
43839         if ((uintptr_t)ret_var.inner > 4096) {
43840                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43841                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43843                 ret_ref = (uintptr_t)ret_var.inner;
43844                 if (ret_var.is_owned) {
43845                         ret_ref |= 1;
43846                 }
43847         }
43848         return ret_ref;
43849 }
43850
43851 uint32_t  __attribute__((export_name("TS_RawInvoice_min_final_cltv_expiry"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
43852         LDKRawInvoice this_arg_conv;
43853         this_arg_conv.inner = (void*)(this_arg & (~1));
43854         this_arg_conv.is_owned = false;
43855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43856         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
43857         uint32_t ret_ref = 0;
43858         if ((uintptr_t)ret_var.inner > 4096) {
43859                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43860                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43862                 ret_ref = (uintptr_t)ret_var.inner;
43863                 if (ret_var.is_owned) {
43864                         ret_ref |= 1;
43865                 }
43866         }
43867         return ret_ref;
43868 }
43869
43870 int8_tArray  __attribute__((export_name("TS_RawInvoice_payment_secret"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
43871         LDKRawInvoice this_arg_conv;
43872         this_arg_conv.inner = (void*)(this_arg & (~1));
43873         this_arg_conv.is_owned = false;
43874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43875         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
43876         memcpy(ret_arr->elems, RawInvoice_payment_secret(&this_arg_conv).data, 32);
43877         return ret_arr;
43878 }
43879
43880 uint32_t  __attribute__((export_name("TS_RawInvoice_features"))) TS_RawInvoice_features(uint32_t this_arg) {
43881         LDKRawInvoice this_arg_conv;
43882         this_arg_conv.inner = (void*)(this_arg & (~1));
43883         this_arg_conv.is_owned = false;
43884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43885         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
43886         uint32_t ret_ref = 0;
43887         if ((uintptr_t)ret_var.inner > 4096) {
43888                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43889                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43891                 ret_ref = (uintptr_t)ret_var.inner;
43892                 if (ret_var.is_owned) {
43893                         ret_ref |= 1;
43894                 }
43895         }
43896         return ret_ref;
43897 }
43898
43899 uint32_tArray  __attribute__((export_name("TS_RawInvoice_private_routes"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
43900         LDKRawInvoice this_arg_conv;
43901         this_arg_conv.inner = (void*)(this_arg & (~1));
43902         this_arg_conv.is_owned = false;
43903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43904         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
43905         uint32_tArray ret_arr = NULL;
43906         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
43907         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
43908         for (size_t o = 0; o < ret_var.datalen; o++) {
43909                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
43910                 uint32_t ret_conv_14_ref = 0;
43911                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43912                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43913                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
43914                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
43915                 if (ret_conv_14_var.is_owned) {
43916                         ret_conv_14_ref |= 1;
43917                 }
43918                 ret_arr_ptr[o] = ret_conv_14_ref;
43919         }
43920         
43921         FREE(ret_var.data);
43922         return ret_arr;
43923 }
43924
43925 uint32_t  __attribute__((export_name("TS_RawInvoice_amount_pico_btc"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
43926         LDKRawInvoice this_arg_conv;
43927         this_arg_conv.inner = (void*)(this_arg & (~1));
43928         this_arg_conv.is_owned = false;
43929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43930         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
43931         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
43932         uint32_t ret_ref = (uintptr_t)ret_copy;
43933         return ret_ref;
43934 }
43935
43936 uint32_t  __attribute__((export_name("TS_RawInvoice_currency"))) TS_RawInvoice_currency(uint32_t this_arg) {
43937         LDKRawInvoice this_arg_conv;
43938         this_arg_conv.inner = (void*)(this_arg & (~1));
43939         this_arg_conv.is_owned = false;
43940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43941         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
43942         return ret_conv;
43943 }
43944
43945 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_unix_timestamp"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
43946         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
43947         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
43948         return (uint32_t)ret_conv;
43949 }
43950
43951 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_duration_since_epoch"))) TS_PositiveTimestamp_from_duration_since_epoch(int64_t duration) {
43952         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
43953         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
43954         return (uint32_t)ret_conv;
43955 }
43956
43957 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_unix_timestamp"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
43958         LDKPositiveTimestamp this_arg_conv;
43959         this_arg_conv.inner = (void*)(this_arg & (~1));
43960         this_arg_conv.is_owned = false;
43961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43962         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
43963         return ret_conv;
43964 }
43965
43966 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_duration_since_epoch"))) TS_PositiveTimestamp_as_duration_since_epoch(uint32_t this_arg) {
43967         LDKPositiveTimestamp this_arg_conv;
43968         this_arg_conv.inner = (void*)(this_arg & (~1));
43969         this_arg_conv.is_owned = false;
43970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43971         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
43972         return ret_conv;
43973 }
43974
43975 uint32_t  __attribute__((export_name("TS_Invoice_into_signed_raw"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
43976         LDKInvoice this_arg_conv;
43977         this_arg_conv.inner = (void*)(this_arg & (~1));
43978         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
43979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43980         this_arg_conv = Invoice_clone(&this_arg_conv);
43981         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
43982         uint32_t ret_ref = 0;
43983         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43984         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43986         ret_ref = (uintptr_t)ret_var.inner;
43987         if (ret_var.is_owned) {
43988                 ret_ref |= 1;
43989         }
43990         return ret_ref;
43991 }
43992
43993 uint32_t  __attribute__((export_name("TS_Invoice_check_signature"))) TS_Invoice_check_signature(uint32_t this_arg) {
43994         LDKInvoice this_arg_conv;
43995         this_arg_conv.inner = (void*)(this_arg & (~1));
43996         this_arg_conv.is_owned = false;
43997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43998         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
43999         *ret_conv = Invoice_check_signature(&this_arg_conv);
44000         return (uint32_t)ret_conv;
44001 }
44002
44003 uint32_t  __attribute__((export_name("TS_Invoice_from_signed"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
44004         LDKSignedRawInvoice signed_invoice_conv;
44005         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
44006         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
44007         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
44008         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
44009         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
44010         *ret_conv = Invoice_from_signed(signed_invoice_conv);
44011         return (uint32_t)ret_conv;
44012 }
44013
44014 int64_t  __attribute__((export_name("TS_Invoice_duration_since_epoch"))) TS_Invoice_duration_since_epoch(uint32_t this_arg) {
44015         LDKInvoice this_arg_conv;
44016         this_arg_conv.inner = (void*)(this_arg & (~1));
44017         this_arg_conv.is_owned = false;
44018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44019         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
44020         return ret_conv;
44021 }
44022
44023 int8_tArray  __attribute__((export_name("TS_Invoice_payment_hash"))) TS_Invoice_payment_hash(uint32_t this_arg) {
44024         LDKInvoice this_arg_conv;
44025         this_arg_conv.inner = (void*)(this_arg & (~1));
44026         this_arg_conv.is_owned = false;
44027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44028         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44029         memcpy(ret_arr->elems, *Invoice_payment_hash(&this_arg_conv), 32);
44030         return ret_arr;
44031 }
44032
44033 int8_tArray  __attribute__((export_name("TS_Invoice_payee_pub_key"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
44034         LDKInvoice this_arg_conv;
44035         this_arg_conv.inner = (void*)(this_arg & (~1));
44036         this_arg_conv.is_owned = false;
44037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44038         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
44039         memcpy(ret_arr->elems, Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
44040         return ret_arr;
44041 }
44042
44043 int8_tArray  __attribute__((export_name("TS_Invoice_payment_secret"))) TS_Invoice_payment_secret(uint32_t this_arg) {
44044         LDKInvoice this_arg_conv;
44045         this_arg_conv.inner = (void*)(this_arg & (~1));
44046         this_arg_conv.is_owned = false;
44047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44048         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44049         memcpy(ret_arr->elems, *Invoice_payment_secret(&this_arg_conv), 32);
44050         return ret_arr;
44051 }
44052
44053 uint32_t  __attribute__((export_name("TS_Invoice_features"))) TS_Invoice_features(uint32_t this_arg) {
44054         LDKInvoice this_arg_conv;
44055         this_arg_conv.inner = (void*)(this_arg & (~1));
44056         this_arg_conv.is_owned = false;
44057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44058         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
44059         uint32_t ret_ref = 0;
44060         if ((uintptr_t)ret_var.inner > 4096) {
44061                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44062                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44064                 ret_ref = (uintptr_t)ret_var.inner;
44065                 if (ret_var.is_owned) {
44066                         ret_ref |= 1;
44067                 }
44068         }
44069         return ret_ref;
44070 }
44071
44072 int8_tArray  __attribute__((export_name("TS_Invoice_recover_payee_pub_key"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
44073         LDKInvoice this_arg_conv;
44074         this_arg_conv.inner = (void*)(this_arg & (~1));
44075         this_arg_conv.is_owned = false;
44076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44077         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
44078         memcpy(ret_arr->elems, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
44079         return ret_arr;
44080 }
44081
44082 int64_t  __attribute__((export_name("TS_Invoice_expiry_time"))) TS_Invoice_expiry_time(uint32_t this_arg) {
44083         LDKInvoice this_arg_conv;
44084         this_arg_conv.inner = (void*)(this_arg & (~1));
44085         this_arg_conv.is_owned = false;
44086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44087         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
44088         return ret_conv;
44089 }
44090
44091 jboolean  __attribute__((export_name("TS_Invoice_would_expire"))) TS_Invoice_would_expire(uint32_t this_arg, int64_t at_time) {
44092         LDKInvoice this_arg_conv;
44093         this_arg_conv.inner = (void*)(this_arg & (~1));
44094         this_arg_conv.is_owned = false;
44095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44096         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
44097         return ret_conv;
44098 }
44099
44100 int64_t  __attribute__((export_name("TS_Invoice_min_final_cltv_expiry"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
44101         LDKInvoice this_arg_conv;
44102         this_arg_conv.inner = (void*)(this_arg & (~1));
44103         this_arg_conv.is_owned = false;
44104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44105         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
44106         return ret_conv;
44107 }
44108
44109 uint32_tArray  __attribute__((export_name("TS_Invoice_private_routes"))) TS_Invoice_private_routes(uint32_t this_arg) {
44110         LDKInvoice this_arg_conv;
44111         this_arg_conv.inner = (void*)(this_arg & (~1));
44112         this_arg_conv.is_owned = false;
44113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44114         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
44115         uint32_tArray ret_arr = NULL;
44116         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
44117         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
44118         for (size_t o = 0; o < ret_var.datalen; o++) {
44119                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
44120                 uint32_t ret_conv_14_ref = 0;
44121                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44122                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44123                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
44124                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
44125                 if (ret_conv_14_var.is_owned) {
44126                         ret_conv_14_ref |= 1;
44127                 }
44128                 ret_arr_ptr[o] = ret_conv_14_ref;
44129         }
44130         
44131         FREE(ret_var.data);
44132         return ret_arr;
44133 }
44134
44135 uint32_tArray  __attribute__((export_name("TS_Invoice_route_hints"))) TS_Invoice_route_hints(uint32_t this_arg) {
44136         LDKInvoice this_arg_conv;
44137         this_arg_conv.inner = (void*)(this_arg & (~1));
44138         this_arg_conv.is_owned = false;
44139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44140         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
44141         uint32_tArray ret_arr = NULL;
44142         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
44143         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
44144         for (size_t l = 0; l < ret_var.datalen; l++) {
44145                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
44146                 uint32_t ret_conv_11_ref = 0;
44147                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44148                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44149                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
44150                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
44151                 if (ret_conv_11_var.is_owned) {
44152                         ret_conv_11_ref |= 1;
44153                 }
44154                 ret_arr_ptr[l] = ret_conv_11_ref;
44155         }
44156         
44157         FREE(ret_var.data);
44158         return ret_arr;
44159 }
44160
44161 uint32_t  __attribute__((export_name("TS_Invoice_currency"))) TS_Invoice_currency(uint32_t this_arg) {
44162         LDKInvoice this_arg_conv;
44163         this_arg_conv.inner = (void*)(this_arg & (~1));
44164         this_arg_conv.is_owned = false;
44165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44166         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
44167         return ret_conv;
44168 }
44169
44170 uint32_t  __attribute__((export_name("TS_Invoice_amount_milli_satoshis"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
44171         LDKInvoice this_arg_conv;
44172         this_arg_conv.inner = (void*)(this_arg & (~1));
44173         this_arg_conv.is_owned = false;
44174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44175         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
44176         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
44177         uint32_t ret_ref = (uintptr_t)ret_copy;
44178         return ret_ref;
44179 }
44180
44181 uint32_t  __attribute__((export_name("TS_Description_new"))) TS_Description_new(jstring description) {
44182         LDKStr description_conv = str_ref_to_owned_c(description);
44183         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
44184         *ret_conv = Description_new(description_conv);
44185         return (uint32_t)ret_conv;
44186 }
44187
44188 jstring  __attribute__((export_name("TS_Description_into_inner"))) TS_Description_into_inner(uint32_t this_arg) {
44189         LDKDescription this_arg_conv;
44190         this_arg_conv.inner = (void*)(this_arg & (~1));
44191         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44193         this_arg_conv = Description_clone(&this_arg_conv);
44194         LDKStr ret_str = Description_into_inner(this_arg_conv);
44195         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44196         Str_free(ret_str);
44197         return ret_conv;
44198 }
44199
44200 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_seconds"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
44201         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
44202         uint32_t ret_ref = 0;
44203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44204         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44206         ret_ref = (uintptr_t)ret_var.inner;
44207         if (ret_var.is_owned) {
44208                 ret_ref |= 1;
44209         }
44210         return ret_ref;
44211 }
44212
44213 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_duration"))) TS_ExpiryTime_from_duration(int64_t duration) {
44214         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
44215         uint32_t ret_ref = 0;
44216         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44217         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44219         ret_ref = (uintptr_t)ret_var.inner;
44220         if (ret_var.is_owned) {
44221                 ret_ref |= 1;
44222         }
44223         return ret_ref;
44224 }
44225
44226 int64_t  __attribute__((export_name("TS_ExpiryTime_as_seconds"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
44227         LDKExpiryTime this_arg_conv;
44228         this_arg_conv.inner = (void*)(this_arg & (~1));
44229         this_arg_conv.is_owned = false;
44230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44231         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
44232         return ret_conv;
44233 }
44234
44235 int64_t  __attribute__((export_name("TS_ExpiryTime_as_duration"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
44236         LDKExpiryTime this_arg_conv;
44237         this_arg_conv.inner = (void*)(this_arg & (~1));
44238         this_arg_conv.is_owned = false;
44239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44240         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
44241         return ret_conv;
44242 }
44243
44244 uint32_t  __attribute__((export_name("TS_PrivateRoute_new"))) TS_PrivateRoute_new(uint32_t hops) {
44245         LDKRouteHint hops_conv;
44246         hops_conv.inner = (void*)(hops & (~1));
44247         hops_conv.is_owned = (hops & 1) || (hops == 0);
44248         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
44249         hops_conv = RouteHint_clone(&hops_conv);
44250         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
44251         *ret_conv = PrivateRoute_new(hops_conv);
44252         return (uint32_t)ret_conv;
44253 }
44254
44255 uint32_t  __attribute__((export_name("TS_PrivateRoute_into_inner"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
44256         LDKPrivateRoute this_arg_conv;
44257         this_arg_conv.inner = (void*)(this_arg & (~1));
44258         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44260         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
44261         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
44262         uint32_t ret_ref = 0;
44263         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44264         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44266         ret_ref = (uintptr_t)ret_var.inner;
44267         if (ret_var.is_owned) {
44268                 ret_ref |= 1;
44269         }
44270         return ret_ref;
44271 }
44272
44273 uint32_t  __attribute__((export_name("TS_CreationError_clone"))) TS_CreationError_clone(uint32_t orig) {
44274         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
44275         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
44276         return ret_conv;
44277 }
44278
44279 uint32_t  __attribute__((export_name("TS_CreationError_description_too_long"))) TS_CreationError_description_too_long() {
44280         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
44281         return ret_conv;
44282 }
44283
44284 uint32_t  __attribute__((export_name("TS_CreationError_route_too_long"))) TS_CreationError_route_too_long() {
44285         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
44286         return ret_conv;
44287 }
44288
44289 uint32_t  __attribute__((export_name("TS_CreationError_timestamp_out_of_bounds"))) TS_CreationError_timestamp_out_of_bounds() {
44290         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
44291         return ret_conv;
44292 }
44293
44294 uint32_t  __attribute__((export_name("TS_CreationError_invalid_amount"))) TS_CreationError_invalid_amount() {
44295         uint32_t ret_conv = LDKCreationError_to_js(CreationError_invalid_amount());
44296         return ret_conv;
44297 }
44298
44299 uint32_t  __attribute__((export_name("TS_CreationError_missing_route_hints"))) TS_CreationError_missing_route_hints() {
44300         uint32_t ret_conv = LDKCreationError_to_js(CreationError_missing_route_hints());
44301         return ret_conv;
44302 }
44303
44304 jboolean  __attribute__((export_name("TS_CreationError_eq"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
44305         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
44306         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
44307         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
44308         return ret_conv;
44309 }
44310
44311 jstring  __attribute__((export_name("TS_CreationError_to_str"))) TS_CreationError_to_str(uint32_t o) {
44312         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
44313         LDKStr ret_str = CreationError_to_str(o_conv);
44314         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44315         Str_free(ret_str);
44316         return ret_conv;
44317 }
44318
44319 uint32_t  __attribute__((export_name("TS_SemanticError_clone"))) TS_SemanticError_clone(uint32_t orig) {
44320         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
44321         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
44322         return ret_conv;
44323 }
44324
44325 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_hash"))) TS_SemanticError_no_payment_hash() {
44326         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
44327         return ret_conv;
44328 }
44329
44330 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_hashes"))) TS_SemanticError_multiple_payment_hashes() {
44331         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
44332         return ret_conv;
44333 }
44334
44335 uint32_t  __attribute__((export_name("TS_SemanticError_no_description"))) TS_SemanticError_no_description() {
44336         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
44337         return ret_conv;
44338 }
44339
44340 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_descriptions"))) TS_SemanticError_multiple_descriptions() {
44341         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
44342         return ret_conv;
44343 }
44344
44345 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_secret"))) TS_SemanticError_no_payment_secret() {
44346         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
44347         return ret_conv;
44348 }
44349
44350 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_secrets"))) TS_SemanticError_multiple_payment_secrets() {
44351         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
44352         return ret_conv;
44353 }
44354
44355 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_features"))) TS_SemanticError_invalid_features() {
44356         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
44357         return ret_conv;
44358 }
44359
44360 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_recovery_id"))) TS_SemanticError_invalid_recovery_id() {
44361         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
44362         return ret_conv;
44363 }
44364
44365 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_signature"))) TS_SemanticError_invalid_signature() {
44366         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
44367         return ret_conv;
44368 }
44369
44370 uint32_t  __attribute__((export_name("TS_SemanticError_imprecise_amount"))) TS_SemanticError_imprecise_amount() {
44371         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
44372         return ret_conv;
44373 }
44374
44375 jboolean  __attribute__((export_name("TS_SemanticError_eq"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
44376         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
44377         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
44378         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
44379         return ret_conv;
44380 }
44381
44382 jstring  __attribute__((export_name("TS_SemanticError_to_str"))) TS_SemanticError_to_str(uint32_t o) {
44383         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
44384         LDKStr ret_str = SemanticError_to_str(o_conv);
44385         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44386         Str_free(ret_str);
44387         return ret_conv;
44388 }
44389
44390 void  __attribute__((export_name("TS_SignOrCreationError_free"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
44391         if ((this_ptr & 1) != 0) return;
44392         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44393         CHECK_ACCESS(this_ptr_ptr);
44394         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
44395         FREE((void*)this_ptr);
44396         SignOrCreationError_free(this_ptr_conv);
44397 }
44398
44399 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
44400         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
44401         *ret_copy = SignOrCreationError_clone(arg);
44402 uint32_t ret_ref = (uintptr_t)ret_copy;
44403         return ret_ref;
44404 }
44405 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone_ptr"))) TS_SignOrCreationError_clone_ptr(uint32_t arg) {
44406         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
44407         uint32_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
44408         return ret_conv;
44409 }
44410
44411 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone"))) TS_SignOrCreationError_clone(uint32_t orig) {
44412         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
44413         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
44414         *ret_copy = SignOrCreationError_clone(orig_conv);
44415         uint32_t ret_ref = (uintptr_t)ret_copy;
44416         return ret_ref;
44417 }
44418
44419 uint32_t  __attribute__((export_name("TS_SignOrCreationError_sign_error"))) TS_SignOrCreationError_sign_error() {
44420         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
44421         *ret_copy = SignOrCreationError_sign_error();
44422         uint32_t ret_ref = (uintptr_t)ret_copy;
44423         return ret_ref;
44424 }
44425
44426 uint32_t  __attribute__((export_name("TS_SignOrCreationError_creation_error"))) TS_SignOrCreationError_creation_error(uint32_t a) {
44427         LDKCreationError a_conv = LDKCreationError_from_js(a);
44428         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
44429         *ret_copy = SignOrCreationError_creation_error(a_conv);
44430         uint32_t ret_ref = (uintptr_t)ret_copy;
44431         return ret_ref;
44432 }
44433
44434 jboolean  __attribute__((export_name("TS_SignOrCreationError_eq"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
44435         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
44436         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
44437         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
44438         return ret_conv;
44439 }
44440
44441 jstring  __attribute__((export_name("TS_SignOrCreationError_to_str"))) TS_SignOrCreationError_to_str(uint32_t o) {
44442         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
44443         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
44444         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44445         Str_free(ret_str);
44446         return ret_conv;
44447 }
44448
44449 void  __attribute__((export_name("TS_InvoicePayer_free"))) TS_InvoicePayer_free(uint32_t this_obj) {
44450         LDKInvoicePayer this_obj_conv;
44451         this_obj_conv.inner = (void*)(this_obj & (~1));
44452         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44454         InvoicePayer_free(this_obj_conv);
44455 }
44456
44457 void  __attribute__((export_name("TS_Payer_free"))) TS_Payer_free(uint32_t this_ptr) {
44458         if ((this_ptr & 1) != 0) return;
44459         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44460         CHECK_ACCESS(this_ptr_ptr);
44461         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
44462         FREE((void*)this_ptr);
44463         Payer_free(this_ptr_conv);
44464 }
44465
44466 void  __attribute__((export_name("TS_Router_free"))) TS_Router_free(uint32_t this_ptr) {
44467         if ((this_ptr & 1) != 0) return;
44468         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44469         CHECK_ACCESS(this_ptr_ptr);
44470         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
44471         FREE((void*)this_ptr);
44472         Router_free(this_ptr_conv);
44473 }
44474
44475 void  __attribute__((export_name("TS_Retry_free"))) TS_Retry_free(uint32_t this_ptr) {
44476         if ((this_ptr & 1) != 0) return;
44477         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44478         CHECK_ACCESS(this_ptr_ptr);
44479         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
44480         FREE((void*)this_ptr);
44481         Retry_free(this_ptr_conv);
44482 }
44483
44484 static inline uintptr_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
44485         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
44486         *ret_copy = Retry_clone(arg);
44487 uint32_t ret_ref = (uintptr_t)ret_copy;
44488         return ret_ref;
44489 }
44490 uint32_t  __attribute__((export_name("TS_Retry_clone_ptr"))) TS_Retry_clone_ptr(uint32_t arg) {
44491         LDKRetry* arg_conv = (LDKRetry*)arg;
44492         uint32_t ret_conv = Retry_clone_ptr(arg_conv);
44493         return ret_conv;
44494 }
44495
44496 uint32_t  __attribute__((export_name("TS_Retry_clone"))) TS_Retry_clone(uint32_t orig) {
44497         LDKRetry* orig_conv = (LDKRetry*)orig;
44498         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
44499         *ret_copy = Retry_clone(orig_conv);
44500         uint32_t ret_ref = (uintptr_t)ret_copy;
44501         return ret_ref;
44502 }
44503
44504 uint32_t  __attribute__((export_name("TS_Retry_attempts"))) TS_Retry_attempts(uint32_t a) {
44505         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
44506         *ret_copy = Retry_attempts(a);
44507         uint32_t ret_ref = (uintptr_t)ret_copy;
44508         return ret_ref;
44509 }
44510
44511 jboolean  __attribute__((export_name("TS_Retry_eq"))) TS_Retry_eq(uint32_t a, uint32_t b) {
44512         LDKRetry* a_conv = (LDKRetry*)a;
44513         LDKRetry* b_conv = (LDKRetry*)b;
44514         jboolean ret_conv = Retry_eq(a_conv, b_conv);
44515         return ret_conv;
44516 }
44517
44518 int64_t  __attribute__((export_name("TS_Retry_hash"))) TS_Retry_hash(uint32_t o) {
44519         LDKRetry* o_conv = (LDKRetry*)o;
44520         int64_t ret_conv = Retry_hash(o_conv);
44521         return ret_conv;
44522 }
44523
44524 void  __attribute__((export_name("TS_PaymentError_free"))) TS_PaymentError_free(uint32_t this_ptr) {
44525         if ((this_ptr & 1) != 0) return;
44526         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44527         CHECK_ACCESS(this_ptr_ptr);
44528         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
44529         FREE((void*)this_ptr);
44530         PaymentError_free(this_ptr_conv);
44531 }
44532
44533 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
44534         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
44535         *ret_copy = PaymentError_clone(arg);
44536 uint32_t ret_ref = (uintptr_t)ret_copy;
44537         return ret_ref;
44538 }
44539 uint32_t  __attribute__((export_name("TS_PaymentError_clone_ptr"))) TS_PaymentError_clone_ptr(uint32_t arg) {
44540         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
44541         uint32_t ret_conv = PaymentError_clone_ptr(arg_conv);
44542         return ret_conv;
44543 }
44544
44545 uint32_t  __attribute__((export_name("TS_PaymentError_clone"))) TS_PaymentError_clone(uint32_t orig) {
44546         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
44547         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
44548         *ret_copy = PaymentError_clone(orig_conv);
44549         uint32_t ret_ref = (uintptr_t)ret_copy;
44550         return ret_ref;
44551 }
44552
44553 uint32_t  __attribute__((export_name("TS_PaymentError_invoice"))) TS_PaymentError_invoice(jstring a) {
44554         LDKStr a_conv = str_ref_to_owned_c(a);
44555         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
44556         *ret_copy = PaymentError_invoice(a_conv);
44557         uint32_t ret_ref = (uintptr_t)ret_copy;
44558         return ret_ref;
44559 }
44560
44561 uint32_t  __attribute__((export_name("TS_PaymentError_routing"))) TS_PaymentError_routing(uint32_t a) {
44562         LDKLightningError a_conv;
44563         a_conv.inner = (void*)(a & (~1));
44564         a_conv.is_owned = (a & 1) || (a == 0);
44565         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44566         a_conv = LightningError_clone(&a_conv);
44567         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
44568         *ret_copy = PaymentError_routing(a_conv);
44569         uint32_t ret_ref = (uintptr_t)ret_copy;
44570         return ret_ref;
44571 }
44572
44573 uint32_t  __attribute__((export_name("TS_PaymentError_sending"))) TS_PaymentError_sending(uint32_t a) {
44574         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
44575         CHECK_ACCESS(a_ptr);
44576         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
44577         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
44578         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
44579         *ret_copy = PaymentError_sending(a_conv);
44580         uint32_t ret_ref = (uintptr_t)ret_copy;
44581         return ret_ref;
44582 }
44583
44584 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) {
44585         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
44586         CHECK_ACCESS(payer_ptr);
44587         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
44588         if (payer_conv.free == LDKPayer_JCalls_free) {
44589                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44590                 LDKPayer_JCalls_cloned(&payer_conv);
44591         }
44592         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
44593         CHECK_ACCESS(router_ptr);
44594         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
44595         if (router_conv.free == LDKRouter_JCalls_free) {
44596                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44597                 LDKRouter_JCalls_cloned(&router_conv);
44598         }
44599         LDKMultiThreadedLockableScore scorer_conv;
44600         scorer_conv.inner = (void*)(scorer & (~1));
44601         scorer_conv.is_owned = false;
44602         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
44603         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
44604         CHECK_ACCESS(logger_ptr);
44605         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
44606         if (logger_conv.free == LDKLogger_JCalls_free) {
44607                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44608                 LDKLogger_JCalls_cloned(&logger_conv);
44609         }
44610         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
44611         CHECK_ACCESS(event_handler_ptr);
44612         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
44613         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
44614                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44615                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
44616         }
44617         void* retry_ptr = (void*)(((uintptr_t)retry) & ~1);
44618         CHECK_ACCESS(retry_ptr);
44619         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
44620         retry_conv = Retry_clone((LDKRetry*)(((uintptr_t)retry) & ~1));
44621         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_conv);
44622         uint32_t ret_ref = 0;
44623         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44624         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44626         ret_ref = (uintptr_t)ret_var.inner;
44627         if (ret_var.is_owned) {
44628                 ret_ref |= 1;
44629         }
44630         return ret_ref;
44631 }
44632
44633 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_invoice"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
44634         LDKInvoicePayer this_arg_conv;
44635         this_arg_conv.inner = (void*)(this_arg & (~1));
44636         this_arg_conv.is_owned = false;
44637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44638         LDKInvoice invoice_conv;
44639         invoice_conv.inner = (void*)(invoice & (~1));
44640         invoice_conv.is_owned = false;
44641         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
44642         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
44643         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
44644         return (uint32_t)ret_conv;
44645 }
44646
44647 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) {
44648         LDKInvoicePayer this_arg_conv;
44649         this_arg_conv.inner = (void*)(this_arg & (~1));
44650         this_arg_conv.is_owned = false;
44651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44652         LDKInvoice invoice_conv;
44653         invoice_conv.inner = (void*)(invoice & (~1));
44654         invoice_conv.is_owned = false;
44655         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
44656         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
44657         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
44658         return (uint32_t)ret_conv;
44659 }
44660
44661 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) {
44662         LDKInvoicePayer this_arg_conv;
44663         this_arg_conv.inner = (void*)(this_arg & (~1));
44664         this_arg_conv.is_owned = false;
44665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44666         LDKPublicKey pubkey_ref;
44667         CHECK(pubkey->arr_len == 33);
44668         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
44669         LDKThirtyTwoBytes payment_preimage_ref;
44670         CHECK(payment_preimage->arr_len == 32);
44671         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
44672         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
44673         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
44674         return (uint32_t)ret_conv;
44675 }
44676
44677 void  __attribute__((export_name("TS_InvoicePayer_remove_cached_payment"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
44678         LDKInvoicePayer this_arg_conv;
44679         this_arg_conv.inner = (void*)(this_arg & (~1));
44680         this_arg_conv.is_owned = false;
44681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44682         unsigned char payment_hash_arr[32];
44683         CHECK(payment_hash->arr_len == 32);
44684         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
44685         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
44686         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
44687 }
44688
44689 uint32_t  __attribute__((export_name("TS_InvoicePayer_as_EventHandler"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
44690         LDKInvoicePayer this_arg_conv;
44691         this_arg_conv.inner = (void*)(this_arg & (~1));
44692         this_arg_conv.is_owned = false;
44693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44694         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
44695         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
44696         return (uint32_t)ret_ret;
44697 }
44698
44699 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) {
44700         LDKChannelManager channelmanager_conv;
44701         channelmanager_conv.inner = (void*)(channelmanager & (~1));
44702         channelmanager_conv.is_owned = false;
44703         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
44704         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
44705         CHECK_ACCESS(keys_manager_ptr);
44706         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
44707         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
44708                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44709                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
44710         }
44711         LDKCurrency network_conv = LDKCurrency_from_js(network);
44712         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
44713         CHECK_ACCESS(amt_msat_ptr);
44714         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
44715         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
44716         LDKSha256 description_hash_conv;
44717         description_hash_conv.inner = (void*)(description_hash & (~1));
44718         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
44719         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
44720         description_hash_conv = Sha256_clone(&description_hash_conv);
44721         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
44722         *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);
44723         return (uint32_t)ret_conv;
44724 }
44725
44726 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) {
44727         LDKChannelManager channelmanager_conv;
44728         channelmanager_conv.inner = (void*)(channelmanager & (~1));
44729         channelmanager_conv.is_owned = false;
44730         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
44731         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
44732         CHECK_ACCESS(keys_manager_ptr);
44733         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
44734         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
44735                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44736                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
44737         }
44738         LDKCurrency network_conv = LDKCurrency_from_js(network);
44739         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
44740         CHECK_ACCESS(amt_msat_ptr);
44741         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
44742         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
44743         LDKStr description_conv = str_ref_to_owned_c(description);
44744         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
44745         *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);
44746         return (uint32_t)ret_conv;
44747 }
44748
44749 void  __attribute__((export_name("TS_DefaultRouter_free"))) TS_DefaultRouter_free(uint32_t this_obj) {
44750         LDKDefaultRouter this_obj_conv;
44751         this_obj_conv.inner = (void*)(this_obj & (~1));
44752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44754         DefaultRouter_free(this_obj_conv);
44755 }
44756
44757 uint32_t  __attribute__((export_name("TS_DefaultRouter_new"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger, int8_tArray random_seed_bytes) {
44758         LDKNetworkGraph network_graph_conv;
44759         network_graph_conv.inner = (void*)(network_graph & (~1));
44760         network_graph_conv.is_owned = false;
44761         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
44762         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
44763         CHECK_ACCESS(logger_ptr);
44764         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
44765         if (logger_conv.free == LDKLogger_JCalls_free) {
44766                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44767                 LDKLogger_JCalls_cloned(&logger_conv);
44768         }
44769         LDKThirtyTwoBytes random_seed_bytes_ref;
44770         CHECK(random_seed_bytes->arr_len == 32);
44771         memcpy(random_seed_bytes_ref.data, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
44772         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
44773         uint32_t ret_ref = 0;
44774         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44775         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44777         ret_ref = (uintptr_t)ret_var.inner;
44778         if (ret_var.is_owned) {
44779                 ret_ref |= 1;
44780         }
44781         return ret_ref;
44782 }
44783
44784 uint32_t  __attribute__((export_name("TS_DefaultRouter_as_Router"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
44785         LDKDefaultRouter this_arg_conv;
44786         this_arg_conv.inner = (void*)(this_arg & (~1));
44787         this_arg_conv.is_owned = false;
44788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44789         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
44790         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
44791         return (uint32_t)ret_ret;
44792 }
44793
44794 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Payer"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
44795         LDKChannelManager this_arg_conv;
44796         this_arg_conv.inner = (void*)(this_arg & (~1));
44797         this_arg_conv.is_owned = false;
44798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44799         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
44800         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
44801         return (uint32_t)ret_ret;
44802 }
44803
44804 uint32_t  __attribute__((export_name("TS_SiPrefix_from_str"))) TS_SiPrefix_from_str(jstring s) {
44805         LDKStr s_conv = str_ref_to_owned_c(s);
44806         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
44807         *ret_conv = SiPrefix_from_str(s_conv);
44808         return (uint32_t)ret_conv;
44809 }
44810
44811 uint32_t  __attribute__((export_name("TS_Invoice_from_str"))) TS_Invoice_from_str(jstring s) {
44812         LDKStr s_conv = str_ref_to_owned_c(s);
44813         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
44814         *ret_conv = Invoice_from_str(s_conv);
44815         return (uint32_t)ret_conv;
44816 }
44817
44818 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_from_str"))) TS_SignedRawInvoice_from_str(jstring s) {
44819         LDKStr s_conv = str_ref_to_owned_c(s);
44820         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
44821         *ret_conv = SignedRawInvoice_from_str(s_conv);
44822         return (uint32_t)ret_conv;
44823 }
44824
44825 jstring  __attribute__((export_name("TS_ParseError_to_str"))) TS_ParseError_to_str(uint32_t o) {
44826         LDKParseError* o_conv = (LDKParseError*)o;
44827         LDKStr ret_str = ParseError_to_str(o_conv);
44828         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44829         Str_free(ret_str);
44830         return ret_conv;
44831 }
44832
44833 jstring  __attribute__((export_name("TS_ParseOrSemanticError_to_str"))) TS_ParseOrSemanticError_to_str(uint32_t o) {
44834         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
44835         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
44836         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44837         Str_free(ret_str);
44838         return ret_conv;
44839 }
44840
44841 jstring  __attribute__((export_name("TS_Invoice_to_str"))) TS_Invoice_to_str(uint32_t o) {
44842         LDKInvoice o_conv;
44843         o_conv.inner = (void*)(o & (~1));
44844         o_conv.is_owned = false;
44845         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44846         LDKStr ret_str = Invoice_to_str(&o_conv);
44847         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44848         Str_free(ret_str);
44849         return ret_conv;
44850 }
44851
44852 jstring  __attribute__((export_name("TS_SignedRawInvoice_to_str"))) TS_SignedRawInvoice_to_str(uint32_t o) {
44853         LDKSignedRawInvoice o_conv;
44854         o_conv.inner = (void*)(o & (~1));
44855         o_conv.is_owned = false;
44856         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44857         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
44858         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44859         Str_free(ret_str);
44860         return ret_conv;
44861 }
44862
44863 jstring  __attribute__((export_name("TS_Currency_to_str"))) TS_Currency_to_str(uint32_t o) {
44864         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
44865         LDKStr ret_str = Currency_to_str(o_conv);
44866         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44867         Str_free(ret_str);
44868         return ret_conv;
44869 }
44870
44871 jstring  __attribute__((export_name("TS_SiPrefix_to_str"))) TS_SiPrefix_to_str(uint32_t o) {
44872         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
44873         LDKStr ret_str = SiPrefix_to_str(o_conv);
44874         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44875         Str_free(ret_str);
44876         return ret_conv;
44877 }
44878