Update auto-generated bindings
[ldk-java] / ts / bindings.c.body
1 #include "js-wasm.h"
2 #include <stdatomic.h>
3 #include <lightning.h>
4
5 // These should be provided...somehow...
6 void *memset(void *s, int c, size_t n);
7 void *memcpy(void *dest, const void *src, size_t n);
8 int memcmp(const void *s1, const void *s2, size_t n);
9
10 void __attribute__((noreturn)) abort(void);
11 static inline void assert(bool expression) {
12         if (!expression) { abort(); }
13 }
14
15 void *malloc(size_t size);
16 void free(void *ptr);
17
18 #define MALLOC(a, _) malloc(a)
19 #define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
20 #define DO_ASSERT(a) (void)(a)
21 #define CHECK(a)
22 #define CHECK_ACCESS(p)
23 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
24
25 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
26 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
27 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
28 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
29
30 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
31
32 typedef uint32_t int64_tArray;
33 typedef uint32_t int8_tArray;
34 typedef uint32_t uint32_tArray;
35 typedef uint32_t ptrArray;
36 typedef uint32_t jstring;
37
38 static inline uint32_t init_arr(size_t arr_len, size_t elem_size, const char *type_desc) {
39         uint32_t *elems = (uint32_t*)MALLOC(arr_len * elem_size + 4, type_desc);
40         elems[0] = arr_len;
41         return (uint32_t)elems;
42 }
43
44 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
45         char* err_buf = MALLOC(len + 4, "str conv buf");
46         *((uint32_t*)err_buf) = len;
47         memcpy(err_buf + 4, chars, len);
48         return (uint32_t) err_buf;
49 }
50 static inline LDKStr str_ref_to_owned_c(jstring str) {
51         uint32_t *str_len = (uint32_t*)str;
52         char* newchars = MALLOC(*str_len + 1, "String chars");
53         memcpy(newchars, (const char*)(str + 4), *str_len);
54         newchars[*str_len] = 0;
55         LDKStr res= {
56                 .chars = newchars,
57                 .len = *str_len,
58                 .chars_is_owned = true
59         };
60         return res;
61 }
62
63 typedef bool jboolean;
64
65 uint32_t __attribute__((visibility("default"))) TS_malloc(uint32_t size) {
66         return (uint32_t)MALLOC(size, "JS-Called malloc");
67 }
68 void __attribute__((visibility("default"))) TS_free(uint32_t ptr) {
69         FREE((void*)ptr);
70 }
71 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
72 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
73         switch (ord) {
74                 case 0: return LDKAccessError_UnknownChain;
75                 case 1: return LDKAccessError_UnknownTx;
76         }
77         abort();
78 }
79 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
80         switch (val) {
81                 case LDKAccessError_UnknownChain: return 0;
82                 case LDKAccessError_UnknownTx: return 1;
83                 default: abort();
84         }
85 }
86 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
87         switch (ord) {
88                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
89                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
90         }
91         abort();
92 }
93 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
94         switch (val) {
95                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
96                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
97                 default: abort();
98         }
99 }
100 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
101         switch (ord) {
102                 case 0: return LDKConfirmationTarget_Background;
103                 case 1: return LDKConfirmationTarget_Normal;
104                 case 2: return LDKConfirmationTarget_HighPriority;
105         }
106         abort();
107 }
108 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
109         switch (val) {
110                 case LDKConfirmationTarget_Background: return 0;
111                 case LDKConfirmationTarget_Normal: return 1;
112                 case LDKConfirmationTarget_HighPriority: return 2;
113                 default: abort();
114         }
115 }
116 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
117         switch (ord) {
118                 case 0: return LDKCreationError_DescriptionTooLong;
119                 case 1: return LDKCreationError_RouteTooLong;
120                 case 2: return LDKCreationError_TimestampOutOfBounds;
121                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
122         }
123         abort();
124 }
125 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
126         switch (val) {
127                 case LDKCreationError_DescriptionTooLong: return 0;
128                 case LDKCreationError_RouteTooLong: return 1;
129                 case LDKCreationError_TimestampOutOfBounds: return 2;
130                 case LDKCreationError_ExpiryTimeOutOfBounds: return 3;
131                 default: abort();
132         }
133 }
134 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
135         switch (ord) {
136                 case 0: return LDKCurrency_Bitcoin;
137                 case 1: return LDKCurrency_BitcoinTestnet;
138                 case 2: return LDKCurrency_Regtest;
139                 case 3: return LDKCurrency_Simnet;
140                 case 4: return LDKCurrency_Signet;
141         }
142         abort();
143 }
144 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
145         switch (val) {
146                 case LDKCurrency_Bitcoin: return 0;
147                 case LDKCurrency_BitcoinTestnet: return 1;
148                 case LDKCurrency_Regtest: return 2;
149                 case LDKCurrency_Simnet: return 3;
150                 case LDKCurrency_Signet: return 4;
151                 default: abort();
152         }
153 }
154 static inline LDKIOError LDKIOError_from_js(int32_t ord) {
155         switch (ord) {
156                 case 0: return LDKIOError_NotFound;
157                 case 1: return LDKIOError_PermissionDenied;
158                 case 2: return LDKIOError_ConnectionRefused;
159                 case 3: return LDKIOError_ConnectionReset;
160                 case 4: return LDKIOError_ConnectionAborted;
161                 case 5: return LDKIOError_NotConnected;
162                 case 6: return LDKIOError_AddrInUse;
163                 case 7: return LDKIOError_AddrNotAvailable;
164                 case 8: return LDKIOError_BrokenPipe;
165                 case 9: return LDKIOError_AlreadyExists;
166                 case 10: return LDKIOError_WouldBlock;
167                 case 11: return LDKIOError_InvalidInput;
168                 case 12: return LDKIOError_InvalidData;
169                 case 13: return LDKIOError_TimedOut;
170                 case 14: return LDKIOError_WriteZero;
171                 case 15: return LDKIOError_Interrupted;
172                 case 16: return LDKIOError_Other;
173                 case 17: return LDKIOError_UnexpectedEof;
174         }
175         abort();
176 }
177 static inline int32_t LDKIOError_to_js(LDKIOError val) {
178         switch (val) {
179                 case LDKIOError_NotFound: return 0;
180                 case LDKIOError_PermissionDenied: return 1;
181                 case LDKIOError_ConnectionRefused: return 2;
182                 case LDKIOError_ConnectionReset: return 3;
183                 case LDKIOError_ConnectionAborted: return 4;
184                 case LDKIOError_NotConnected: return 5;
185                 case LDKIOError_AddrInUse: return 6;
186                 case LDKIOError_AddrNotAvailable: return 7;
187                 case LDKIOError_BrokenPipe: return 8;
188                 case LDKIOError_AlreadyExists: return 9;
189                 case LDKIOError_WouldBlock: return 10;
190                 case LDKIOError_InvalidInput: return 11;
191                 case LDKIOError_InvalidData: return 12;
192                 case LDKIOError_TimedOut: return 13;
193                 case LDKIOError_WriteZero: return 14;
194                 case LDKIOError_Interrupted: return 15;
195                 case LDKIOError_Other: return 16;
196                 case LDKIOError_UnexpectedEof: return 17;
197                 default: abort();
198         }
199 }
200 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
201         switch (ord) {
202                 case 0: return LDKLevel_Trace;
203                 case 1: return LDKLevel_Debug;
204                 case 2: return LDKLevel_Info;
205                 case 3: return LDKLevel_Warn;
206                 case 4: return LDKLevel_Error;
207         }
208         abort();
209 }
210 static inline int32_t LDKLevel_to_js(LDKLevel val) {
211         switch (val) {
212                 case LDKLevel_Trace: return 0;
213                 case LDKLevel_Debug: return 1;
214                 case LDKLevel_Info: return 2;
215                 case LDKLevel_Warn: return 3;
216                 case LDKLevel_Error: return 4;
217                 default: abort();
218         }
219 }
220 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
221         switch (ord) {
222                 case 0: return LDKNetwork_Bitcoin;
223                 case 1: return LDKNetwork_Testnet;
224                 case 2: return LDKNetwork_Regtest;
225                 case 3: return LDKNetwork_Signet;
226         }
227         abort();
228 }
229 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
230         switch (val) {
231                 case LDKNetwork_Bitcoin: return 0;
232                 case LDKNetwork_Testnet: return 1;
233                 case LDKNetwork_Regtest: return 2;
234                 case LDKNetwork_Signet: return 3;
235                 default: abort();
236         }
237 }
238 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
239         switch (ord) {
240                 case 0: return LDKSecp256k1Error_IncorrectSignature;
241                 case 1: return LDKSecp256k1Error_InvalidMessage;
242                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
243                 case 3: return LDKSecp256k1Error_InvalidSignature;
244                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
245                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
246                 case 6: return LDKSecp256k1Error_InvalidTweak;
247                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
248                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
249         }
250         abort();
251 }
252 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
253         switch (val) {
254                 case LDKSecp256k1Error_IncorrectSignature: return 0;
255                 case LDKSecp256k1Error_InvalidMessage: return 1;
256                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
257                 case LDKSecp256k1Error_InvalidSignature: return 3;
258                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
259                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
260                 case LDKSecp256k1Error_InvalidTweak: return 6;
261                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
262                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
263                 default: abort();
264         }
265 }
266 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
267         switch (ord) {
268                 case 0: return LDKSemanticError_NoPaymentHash;
269                 case 1: return LDKSemanticError_MultiplePaymentHashes;
270                 case 2: return LDKSemanticError_NoDescription;
271                 case 3: return LDKSemanticError_MultipleDescriptions;
272                 case 4: return LDKSemanticError_NoPaymentSecret;
273                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
274                 case 6: return LDKSemanticError_InvalidFeatures;
275                 case 7: return LDKSemanticError_InvalidRecoveryId;
276                 case 8: return LDKSemanticError_InvalidSignature;
277                 case 9: return LDKSemanticError_ImpreciseAmount;
278         }
279         abort();
280 }
281 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
282         switch (val) {
283                 case LDKSemanticError_NoPaymentHash: return 0;
284                 case LDKSemanticError_MultiplePaymentHashes: return 1;
285                 case LDKSemanticError_NoDescription: return 2;
286                 case LDKSemanticError_MultipleDescriptions: return 3;
287                 case LDKSemanticError_NoPaymentSecret: return 4;
288                 case LDKSemanticError_MultiplePaymentSecrets: return 5;
289                 case LDKSemanticError_InvalidFeatures: return 6;
290                 case LDKSemanticError_InvalidRecoveryId: return 7;
291                 case LDKSemanticError_InvalidSignature: return 8;
292                 case LDKSemanticError_ImpreciseAmount: return 9;
293                 default: abort();
294         }
295 }
296 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
297         switch (ord) {
298                 case 0: return LDKSiPrefix_Milli;
299                 case 1: return LDKSiPrefix_Micro;
300                 case 2: return LDKSiPrefix_Nano;
301                 case 3: return LDKSiPrefix_Pico;
302         }
303         abort();
304 }
305 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
306         switch (val) {
307                 case LDKSiPrefix_Milli: return 0;
308                 case LDKSiPrefix_Micro: return 1;
309                 case LDKSiPrefix_Nano: return 2;
310                 case LDKSiPrefix_Pico: return 3;
311                 default: abort();
312         }
313 }
314 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
315         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
316         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
317         return ret;
318 }
319 struct LDKCVec_u8Z TxOut_get_script_pubkey (struct LDKTxOut* thing) {   return CVec_u8Z_clone(&thing->script_pubkey);}int8_tArray  __attribute__((visibility("default"))) TS_TxOut_get_script_pubkey(uint32_t thing) {
320         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
321         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
322         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
323         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
324         CVec_u8Z_free(ret_var);
325         return ret_arr;
326 }
327
328 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}int64_t  __attribute__((visibility("default"))) TS_TxOut_get_value(uint32_t thing) {
329         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
330         int64_t ret_val = TxOut_get_value(thing_conv);
331         return ret_val;
332 }
333
334 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_ok(uint32_t arg) {
335         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
336         CHECK(val->result_ok);
337         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
338         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).bytes, 32);
339         return res_arr;
340 }
341 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_err(uint32_t arg) {
342         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
343         CHECK(!val->result_ok);
344         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
345         return err_conv;
346 }
347 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_ok(uint32_t arg) {
348         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
349         CHECK(val->result_ok);
350         int8_tArray res_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
351         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compressed_form, 33);
352         return res_arr;
353 }
354 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_err(uint32_t arg) {
355         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
356         CHECK(!val->result_ok);
357         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
358         return err_conv;
359 }
360 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t arg) {
361         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
362         CHECK(val->result_ok);
363         LDKTxCreationKeys res_var = (*val->contents.result);
364         uint64_t res_ref = 0;
365         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
366         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
367         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
368         res_ref = (uint64_t)res_var.inner & ~1;
369         return res_ref;
370 }
371 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t arg) {
372         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
373         CHECK(!val->result_ok);
374         LDKDecodeError err_var = (*val->contents.err);
375         uint64_t err_ref = 0;
376         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
377         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
378         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
379         err_ref = (uint64_t)err_var.inner & ~1;
380         return err_ref;
381 }
382 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t arg) {
383         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
384         CHECK(val->result_ok);
385         LDKChannelPublicKeys res_var = (*val->contents.result);
386         uint64_t res_ref = 0;
387         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
388         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
389         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
390         res_ref = (uint64_t)res_var.inner & ~1;
391         return res_ref;
392 }
393 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t arg) {
394         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
395         CHECK(!val->result_ok);
396         LDKDecodeError err_var = (*val->contents.err);
397         uint64_t err_ref = 0;
398         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
399         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
400         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
401         err_ref = (uint64_t)err_var.inner & ~1;
402         return err_ref;
403 }
404 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_ok(uint32_t arg) {
405         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
406         CHECK(val->result_ok);
407         LDKTxCreationKeys res_var = (*val->contents.result);
408         uint64_t res_ref = 0;
409         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
410         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
411         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
412         res_ref = (uint64_t)res_var.inner & ~1;
413         return res_ref;
414 }
415 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_err(uint32_t arg) {
416         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
417         CHECK(!val->result_ok);
418         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
419         return err_conv;
420 }
421 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u32Z_ref_from_ptr(uint32_t ptr) {
422         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
423         switch(obj->tag) {
424                 case LDKCOption_u32Z_Some: {
425                         return 0 /* LDKCOption_u32Z - Some */; (void) obj->some;
426                 }
427                 case LDKCOption_u32Z_None: {
428                         return 0 /* LDKCOption_u32Z - None */;
429                 }
430                 default: abort();
431         }
432 }
433 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t arg) {
434         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
435         CHECK(val->result_ok);
436         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
437         uint64_t res_ref = 0;
438         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
439         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
440         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
441         res_ref = (uint64_t)res_var.inner & ~1;
442         return res_ref;
443 }
444 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t arg) {
445         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
446         CHECK(!val->result_ok);
447         LDKDecodeError err_var = (*val->contents.err);
448         uint64_t err_ref = 0;
449         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
450         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
451         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
452         err_ref = (uint64_t)err_var.inner & ~1;
453         return err_ref;
454 }
455 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
456         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
457         CHECK(val->result_ok);
458         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
459         uint64_t res_ref = 0;
460         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
461         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
462         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
463         res_ref = (uint64_t)res_var.inner & ~1;
464         return res_ref;
465 }
466 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
467         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
468         CHECK(!val->result_ok);
469         LDKDecodeError err_var = (*val->contents.err);
470         uint64_t err_ref = 0;
471         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
472         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
473         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
474         err_ref = (uint64_t)err_var.inner & ~1;
475         return err_ref;
476 }
477 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
478         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
479         CHECK(val->result_ok);
480         LDKChannelTransactionParameters res_var = (*val->contents.result);
481         uint64_t res_ref = 0;
482         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
483         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
484         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
485         res_ref = (uint64_t)res_var.inner & ~1;
486         return res_ref;
487 }
488 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
489         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
490         CHECK(!val->result_ok);
491         LDKDecodeError err_var = (*val->contents.err);
492         uint64_t err_ref = 0;
493         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
494         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
495         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
496         err_ref = (uint64_t)err_var.inner & ~1;
497         return err_ref;
498 }
499 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
500         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
501         CHECK(val->result_ok);
502         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
503         uint64_t res_ref = 0;
504         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
505         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
506         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
507         res_ref = (uint64_t)res_var.inner & ~1;
508         return res_ref;
509 }
510 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
511         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
512         CHECK(!val->result_ok);
513         LDKDecodeError err_var = (*val->contents.err);
514         uint64_t err_ref = 0;
515         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
516         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
517         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
518         err_ref = (uint64_t)err_var.inner & ~1;
519         return err_ref;
520 }
521 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
522         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
523         CHECK(val->result_ok);
524         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
525         uint64_t res_ref = 0;
526         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
527         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
528         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
529         res_ref = (uint64_t)res_var.inner & ~1;
530         return res_ref;
531 }
532 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
533         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
534         CHECK(!val->result_ok);
535         LDKDecodeError err_var = (*val->contents.err);
536         uint64_t err_ref = 0;
537         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
538         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
539         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
540         err_ref = (uint64_t)err_var.inner & ~1;
541         return err_ref;
542 }
543 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t arg) {
544         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
545         CHECK(val->result_ok);
546         LDKTrustedClosingTransaction res_var = (*val->contents.result);
547         uint64_t res_ref = 0;
548         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
549         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
550         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
551         res_ref = (uint64_t)res_var.inner & ~1;
552         return res_ref;
553 }
554 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_get_err(uint32_t arg) {
555         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
556         CHECK(!val->result_ok);
557         return *val->contents.err;
558 }
559 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
560         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
561         CHECK(val->result_ok);
562         LDKCommitmentTransaction res_var = (*val->contents.result);
563         uint64_t res_ref = 0;
564         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
565         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
566         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
567         res_ref = (uint64_t)res_var.inner & ~1;
568         return res_ref;
569 }
570 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
571         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
572         CHECK(!val->result_ok);
573         LDKDecodeError err_var = (*val->contents.err);
574         uint64_t err_ref = 0;
575         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
576         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
577         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
578         err_ref = (uint64_t)err_var.inner & ~1;
579         return err_ref;
580 }
581 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t arg) {
582         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
583         CHECK(val->result_ok);
584         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
585         uint64_t res_ref = 0;
586         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
587         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
588         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
589         res_ref = (uint64_t)res_var.inner & ~1;
590         return res_ref;
591 }
592 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
593         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
594         CHECK(!val->result_ok);
595         return *val->contents.err;
596 }
597 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_ok(uint32_t arg) {
598         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
599         CHECK(val->result_ok);
600         LDKCVec_SignatureZ res_var = (*val->contents.result);
601         ptrArray res_arr = NULL;
602         res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
603         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
604         for (size_t m = 0; m < res_var.datalen; m++) {
605                 int8_tArray res_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
606                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_var.data[m].compact_form, 64);
607                 res_arr_ptr[m] = res_conv_12_arr;
608         }
609         
610         return res_arr;
611 }
612 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
613         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
614         CHECK(!val->result_ok);
615         return *val->contents.err;
616 }
617 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t arg) {
618         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
619         CHECK(val->result_ok);
620         LDKShutdownScript res_var = (*val->contents.result);
621         uint64_t res_ref = 0;
622         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
623         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
624         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
625         res_ref = (uint64_t)res_var.inner & ~1;
626         return res_ref;
627 }
628 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t arg) {
629         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
630         CHECK(!val->result_ok);
631         LDKDecodeError err_var = (*val->contents.err);
632         uint64_t err_ref = 0;
633         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
634         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
635         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
636         err_ref = (uint64_t)err_var.inner & ~1;
637         return err_ref;
638 }
639 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t arg) {
640         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
641         CHECK(val->result_ok);
642         LDKShutdownScript res_var = (*val->contents.result);
643         uint64_t res_ref = 0;
644         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
645         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
646         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
647         res_ref = (uint64_t)res_var.inner & ~1;
648         return res_ref;
649 }
650 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t arg) {
651         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
652         CHECK(!val->result_ok);
653         LDKInvalidShutdownScript err_var = (*val->contents.err);
654         uint64_t err_ref = 0;
655         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
656         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
657         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
658         err_ref = (uint64_t)err_var.inner & ~1;
659         return err_ref;
660 }
661 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_ok(uint32_t arg) {
662         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
663         CHECK(val->result_ok);
664         return *val->contents.result;
665 }
666 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_err(uint32_t arg) {
667         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
668         CHECK(!val->result_ok);
669         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
670         return err_conv;
671 }
672 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_ok(uint32_t arg) {
673         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
674         CHECK(val->result_ok);
675         LDKRouteHop res_var = (*val->contents.result);
676         uint64_t res_ref = 0;
677         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
678         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
679         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
680         res_ref = (uint64_t)res_var.inner & ~1;
681         return res_ref;
682 }
683 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_err(uint32_t arg) {
684         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
685         CHECK(!val->result_ok);
686         LDKDecodeError err_var = (*val->contents.err);
687         uint64_t err_ref = 0;
688         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
689         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
690         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
691         err_ref = (uint64_t)err_var.inner & ~1;
692         return err_ref;
693 }
694 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
695         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
696         for (size_t i = 0; i < ret.datalen; i++) {
697                 ret.data[i] = RouteHop_clone(&orig->data[i]);
698         }
699         return ret;
700 }
701 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
702         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
703         for (size_t i = 0; i < ret.datalen; i++) {
704                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
705         }
706         return ret;
707 }
708 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
709         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
710         CHECK(val->result_ok);
711         LDKRoute res_var = (*val->contents.result);
712         uint64_t res_ref = 0;
713         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
714         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
715         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
716         res_ref = (uint64_t)res_var.inner & ~1;
717         return res_ref;
718 }
719 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
720         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
721         CHECK(!val->result_ok);
722         LDKDecodeError err_var = (*val->contents.err);
723         uint64_t err_ref = 0;
724         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
725         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
726         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
727         err_ref = (uint64_t)err_var.inner & ~1;
728         return err_ref;
729 }
730 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteParametersDecodeErrorZ_get_ok(uint32_t arg) {
731         LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
732         CHECK(val->result_ok);
733         LDKRouteParameters res_var = (*val->contents.result);
734         uint64_t res_ref = 0;
735         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
736         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
737         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
738         res_ref = (uint64_t)res_var.inner & ~1;
739         return res_ref;
740 }
741 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteParametersDecodeErrorZ_get_err(uint32_t arg) {
742         LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
743         CHECK(!val->result_ok);
744         LDKDecodeError err_var = (*val->contents.err);
745         uint64_t err_ref = 0;
746         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
747         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
748         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
749         err_ref = (uint64_t)err_var.inner & ~1;
750         return err_ref;
751 }
752 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
753         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
754         for (size_t i = 0; i < ret.datalen; i++) {
755                 ret.data[i] = RouteHint_clone(&orig->data[i]);
756         }
757         return ret;
758 }
759 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(uint32_t ptr) {
760         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
761         switch(obj->tag) {
762                 case LDKCOption_u64Z_Some: {
763                         return 0 /* LDKCOption_u64Z - Some */; (void) obj->some;
764                 }
765                 case LDKCOption_u64Z_None: {
766                         return 0 /* LDKCOption_u64Z - None */;
767                 }
768                 default: abort();
769         }
770 }
771 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeeDecodeErrorZ_get_ok(uint32_t arg) {
772         LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
773         CHECK(val->result_ok);
774         LDKPayee res_var = (*val->contents.result);
775         uint64_t res_ref = 0;
776         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
777         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
778         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
779         res_ref = (uint64_t)res_var.inner & ~1;
780         return res_ref;
781 }
782 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeeDecodeErrorZ_get_err(uint32_t arg) {
783         LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
784         CHECK(!val->result_ok);
785         LDKDecodeError err_var = (*val->contents.err);
786         uint64_t err_ref = 0;
787         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
788         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
789         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
790         err_ref = (uint64_t)err_var.inner & ~1;
791         return err_ref;
792 }
793 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
794         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
795         for (size_t i = 0; i < ret.datalen; i++) {
796                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
797         }
798         return ret;
799 }
800 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintDecodeErrorZ_get_ok(uint32_t arg) {
801         LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
802         CHECK(val->result_ok);
803         LDKRouteHint res_var = (*val->contents.result);
804         uint64_t res_ref = 0;
805         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
806         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
807         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
808         res_ref = (uint64_t)res_var.inner & ~1;
809         return res_ref;
810 }
811 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintDecodeErrorZ_get_err(uint32_t arg) {
812         LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
813         CHECK(!val->result_ok);
814         LDKDecodeError err_var = (*val->contents.err);
815         uint64_t err_ref = 0;
816         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
817         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
818         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
819         err_ref = (uint64_t)err_var.inner & ~1;
820         return err_ref;
821 }
822 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t arg) {
823         LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
824         CHECK(val->result_ok);
825         LDKRouteHintHop res_var = (*val->contents.result);
826         uint64_t res_ref = 0;
827         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
828         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
829         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
830         res_ref = (uint64_t)res_var.inner & ~1;
831         return res_ref;
832 }
833 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintHopDecodeErrorZ_get_err(uint32_t arg) {
834         LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
835         CHECK(!val->result_ok);
836         LDKDecodeError err_var = (*val->contents.err);
837         uint64_t err_ref = 0;
838         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
839         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
840         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
841         err_ref = (uint64_t)err_var.inner & ~1;
842         return err_ref;
843 }
844 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
845         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
846         for (size_t i = 0; i < ret.datalen; i++) {
847                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
848         }
849         return ret;
850 }
851 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
852         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
853         CHECK(val->result_ok);
854         LDKRoute res_var = (*val->contents.result);
855         uint64_t res_ref = 0;
856         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
857         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
858         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
859         res_ref = (uint64_t)res_var.inner & ~1;
860         return res_ref;
861 }
862 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
863         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
864         CHECK(!val->result_ok);
865         LDKLightningError err_var = (*val->contents.err);
866         uint64_t err_ref = 0;
867         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
868         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
869         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
870         err_ref = (uint64_t)err_var.inner & ~1;
871         return err_ref;
872 }
873 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
874         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
875         CHECK(val->result_ok);
876         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
877         return (uint64_t)res_ref;
878 }
879 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
880         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
881         CHECK(!val->result_ok);
882         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
883         return err_conv;
884 }
885 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
886         return tuple->a;
887 }
888 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t tuple) {
889         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
890         int64_t ret_val = C2Tuple_usizeTransactionZ_get_a(tuple_conv);
891         return ret_val;
892 }
893
894 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
895         return tuple->b;
896 }
897 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t tuple) {
898         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
899         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(tuple_conv);
900         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
901         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
902         Transaction_free(ret_var);
903         return ret_arr;
904 }
905
906 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
907         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
908         for (size_t i = 0; i < ret.datalen; i++) {
909                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
910         }
911         return ret;
912 }
913 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
914         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
915         for (size_t i = 0; i < ret.datalen; i++) {
916                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
917         }
918         return ret;
919 }
920 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
921         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
922         CHECK(val->result_ok);
923         return *val->contents.result;
924 }
925 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
926         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
927         CHECK(!val->result_ok);
928         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
929         return err_conv;
930 }
931 uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(uint32_t ptr) {
932         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
933         switch(obj->tag) {
934                 case LDKMonitorEvent_HTLCEvent: {
935                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
936                         uint64_t htlc_event_ref = 0;
937                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
938                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
939                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
940                         htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
941                         return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref;
942                 }
943                 case LDKMonitorEvent_CommitmentTxConfirmed: {
944                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
945                         uint64_t commitment_tx_confirmed_ref = 0;
946                         CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
947                         CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
948                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
949                         commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1;
950                         return 0 /* LDKMonitorEvent - CommitmentTxConfirmed */; (void) commitment_tx_confirmed_ref;
951                 }
952                 case LDKMonitorEvent_UpdateCompleted: {
953                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
954                         uint64_t funding_txo_ref = 0;
955                         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
956                         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
957                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
958                         funding_txo_ref = (uint64_t)funding_txo_var.inner & ~1;
959                         return 0 /* LDKMonitorEvent - UpdateCompleted */; (void) funding_txo_ref; (void) obj->update_completed.monitor_update_id;
960                 }
961                 case LDKMonitorEvent_UpdateFailed: {
962                         LDKOutPoint update_failed_var = obj->update_failed;
963                         uint64_t update_failed_ref = 0;
964                         CHECK((((uint64_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
965                         CHECK((((uint64_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
966                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
967                         update_failed_ref = (uint64_t)update_failed_var.inner & ~1;
968                         return 0 /* LDKMonitorEvent - UpdateFailed */; (void) update_failed_ref;
969                 }
970                 default: abort();
971         }
972 }
973 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
974         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
975         for (size_t i = 0; i < ret.datalen; i++) {
976                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
977         }
978         return ret;
979 }
980 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ref_from_ptr(uint32_t ptr) {
981         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
982         switch(obj->tag) {
983                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
984                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
985                         *some_conv = obj->some;
986                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
987                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - Some */; (void) ((uint64_t)some_conv);
988                 }
989                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
990                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - None */;
991                 }
992                 default: abort();
993         }
994 }
995 uint32_t __attribute__((visibility("default"))) TS_LDKClosureReason_ref_from_ptr(uint32_t ptr) {
996         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
997         switch(obj->tag) {
998                 case LDKClosureReason_CounterpartyForceClosed: {
999                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1000                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1001                         return 0 /* LDKClosureReason - CounterpartyForceClosed */; (void) peer_msg_conv;
1002                 }
1003                 case LDKClosureReason_HolderForceClosed: {
1004                         return 0 /* LDKClosureReason - HolderForceClosed */;
1005                 }
1006                 case LDKClosureReason_CooperativeClosure: {
1007                         return 0 /* LDKClosureReason - CooperativeClosure */;
1008                 }
1009                 case LDKClosureReason_CommitmentTxConfirmed: {
1010                         return 0 /* LDKClosureReason - CommitmentTxConfirmed */;
1011                 }
1012                 case LDKClosureReason_ProcessingError: {
1013                         LDKStr err_str = obj->processing_error.err;
1014                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1015                         return 0 /* LDKClosureReason - ProcessingError */; (void) err_conv;
1016                 }
1017                 case LDKClosureReason_DisconnectedPeer: {
1018                         return 0 /* LDKClosureReason - DisconnectedPeer */;
1019                 }
1020                 case LDKClosureReason_OutdatedChannelManager: {
1021                         return 0 /* LDKClosureReason - OutdatedChannelManager */;
1022                 }
1023                 default: abort();
1024         }
1025 }
1026 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_ClosureReasonZ_ref_from_ptr(uint32_t ptr) {
1027         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1028         switch(obj->tag) {
1029                 case LDKCOption_ClosureReasonZ_Some: {
1030                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1031                         return 0 /* LDKCOption_ClosureReasonZ - Some */; (void) some_ref;
1032                 }
1033                 case LDKCOption_ClosureReasonZ_None: {
1034                         return 0 /* LDKCOption_ClosureReasonZ - None */;
1035                 }
1036                 default: abort();
1037         }
1038 }
1039 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t arg) {
1040         LDKCResult_COption_ClosureReasonZDecodeErrorZ *val = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
1041         CHECK(val->result_ok);
1042         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1043         return res_ref;
1044 }
1045 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t arg) {
1046         LDKCResult_COption_ClosureReasonZDecodeErrorZ *val = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
1047         CHECK(!val->result_ok);
1048         LDKDecodeError err_var = (*val->contents.err);
1049         uint64_t err_ref = 0;
1050         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1051         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1052         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1053         err_ref = (uint64_t)err_var.inner & ~1;
1054         return err_ref;
1055 }
1056 uint32_t __attribute__((visibility("default"))) TS_LDKNetworkUpdate_ref_from_ptr(uint32_t ptr) {
1057         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1058         switch(obj->tag) {
1059                 case LDKNetworkUpdate_ChannelUpdateMessage: {
1060                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1061                         uint64_t msg_ref = 0;
1062                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1063                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1064                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1065                         msg_ref = (uint64_t)msg_var.inner & ~1;
1066                         return 0 /* LDKNetworkUpdate - ChannelUpdateMessage */; (void) msg_ref;
1067                 }
1068                 case LDKNetworkUpdate_ChannelClosed: {
1069                         return 0 /* LDKNetworkUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
1070                 }
1071                 case LDKNetworkUpdate_NodeFailure: {
1072                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1073                         memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
1074                         return 0 /* LDKNetworkUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
1075                 }
1076                 default: abort();
1077         }
1078 }
1079 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_NetworkUpdateZ_ref_from_ptr(uint32_t ptr) {
1080         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1081         switch(obj->tag) {
1082                 case LDKCOption_NetworkUpdateZ_Some: {
1083                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1084                         return 0 /* LDKCOption_NetworkUpdateZ - Some */; (void) some_ref;
1085                 }
1086                 case LDKCOption_NetworkUpdateZ_None: {
1087                         return 0 /* LDKCOption_NetworkUpdateZ - None */;
1088                 }
1089                 default: abort();
1090         }
1091 }
1092 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
1093         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1094         switch(obj->tag) {
1095                 case LDKSpendableOutputDescriptor_StaticOutput: {
1096                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1097                         uint64_t outpoint_ref = 0;
1098                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1099                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1100                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1101                         outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1102                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1103                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (uint64_t)output_ref;
1104                 }
1105                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1106                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1107                         uint64_t delayed_payment_output_ref = 0;
1108                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1109                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1110                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1111                         delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1112                         return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */; (void) delayed_payment_output_ref;
1113                 }
1114                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1115                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1116                         uint64_t static_payment_output_ref = 0;
1117                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1118                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1119                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1120                         static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1121                         return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */; (void) static_payment_output_ref;
1122                 }
1123                 default: abort();
1124         }
1125 }
1126 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1127         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1128         for (size_t i = 0; i < ret.datalen; i++) {
1129                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1130         }
1131         return ret;
1132 }
1133 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentPurpose_ref_from_ptr(uint32_t ptr) {
1134         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1135         switch(obj->tag) {
1136                 case LDKPaymentPurpose_InvoicePayment: {
1137                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1138                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->invoice_payment.payment_preimage.data, 32);
1139                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1140                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->invoice_payment.payment_secret.data, 32);
1141                         return 0 /* LDKPaymentPurpose - InvoicePayment */; (void) payment_preimage_arr; (void) payment_secret_arr; (void) obj->invoice_payment.user_payment_id;
1142                 }
1143                 case LDKPaymentPurpose_SpontaneousPayment: {
1144                         int8_tArray spontaneous_payment_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1145                         memcpy((uint8_t*)(spontaneous_payment_arr + 4), obj->spontaneous_payment.data, 32);
1146                         return 0 /* LDKPaymentPurpose - SpontaneousPayment */; (void) spontaneous_payment_arr;
1147                 }
1148                 default: abort();
1149         }
1150 }
1151 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
1152         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1153         switch(obj->tag) {
1154                 case LDKEvent_FundingGenerationReady: {
1155                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1156                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
1157                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1158                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1159                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
1160                         return 0 /* LDKEvent - FundingGenerationReady */; (void) temporary_channel_id_arr; (void) obj->funding_generation_ready.channel_value_satoshis; (void) output_script_arr; (void) obj->funding_generation_ready.user_channel_id;
1161                 }
1162                 case LDKEvent_PaymentReceived: {
1163                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1164                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
1165                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
1166                         return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) obj->payment_received.amt; (void) purpose_ref;
1167                 }
1168                 case LDKEvent_PaymentSent: {
1169                         int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1170                         memcpy((uint8_t*)(payment_id_arr + 4), obj->payment_sent.payment_id.data, 32);
1171                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1172                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
1173                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1174                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_sent.payment_hash.data, 32);
1175                         uint64_t fee_paid_msat_ref = ((uint64_t)&obj->payment_sent.fee_paid_msat) | 1;
1176                         return 0 /* LDKEvent - PaymentSent */; (void) payment_id_arr; (void) payment_preimage_arr; (void) payment_hash_arr; (void) fee_paid_msat_ref;
1177                 }
1178                 case LDKEvent_PaymentPathFailed: {
1179                         int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1180                         memcpy((uint8_t*)(payment_id_arr + 4), obj->payment_path_failed.payment_id.data, 32);
1181                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1182                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_path_failed.payment_hash.data, 32);
1183                         uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
1184                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1185                         uint32_tArray path_arr = NULL;
1186                         path_arr = init_arr(path_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1187                         uint32_t *path_arr_ptr = (uint32_t*)(path_arr + 4);
1188                         for (size_t k = 0; k < path_var.datalen; k++) {
1189                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1190                                 uint64_t path_conv_10_ref = 0;
1191                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1192                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1193                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1194                                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
1195                                 path_arr_ptr[k] = path_conv_10_ref;
1196                         }
1197                         
1198                         uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
1199                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1200                         uint64_t retry_ref = 0;
1201                         if ((uint64_t)retry_var.inner > 4096) {
1202                                 CHECK((((uint64_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1203                                 CHECK((((uint64_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1204                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1205                                 retry_ref = (uint64_t)retry_var.inner & ~1;
1206                         }
1207                         return 0 /* LDKEvent - PaymentPathFailed */; (void) payment_id_arr; (void) payment_hash_arr; (void) obj->payment_path_failed.rejected_by_dest; (void) network_update_ref; (void) obj->payment_path_failed.all_paths_failed; (void) path_arr; (void) short_channel_id_ref; (void) retry_ref;
1208                 }
1209                 case LDKEvent_PendingHTLCsForwardable: {
1210                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
1211                 }
1212                 case LDKEvent_SpendableOutputs: {
1213                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1214                         uint32_tArray outputs_arr = NULL;
1215                         outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1216                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
1217                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1218                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
1219                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1220                         }
1221                         
1222                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
1223                 }
1224                 case LDKEvent_PaymentForwarded: {
1225                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1226                         return 0 /* LDKEvent - PaymentForwarded */; (void) fee_earned_msat_ref; (void) obj->payment_forwarded.claim_from_onchain_tx;
1227                 }
1228                 case LDKEvent_ChannelClosed: {
1229                         int8_tArray channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1230                         memcpy((uint8_t*)(channel_id_arr + 4), obj->channel_closed.channel_id.data, 32);
1231                         uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
1232                         return 0 /* LDKEvent - ChannelClosed */; (void) channel_id_arr; (void) obj->channel_closed.user_channel_id; (void) reason_ref;
1233                 }
1234                 case LDKEvent_DiscardFunding: {
1235                         int8_tArray channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1236                         memcpy((uint8_t*)(channel_id_arr + 4), obj->discard_funding.channel_id.data, 32);
1237                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1238                         int8_tArray transaction_arr = init_arr(transaction_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1239                         memcpy((uint8_t*)(transaction_arr + 4), transaction_var.data, transaction_var.datalen);
1240                         return 0 /* LDKEvent - DiscardFunding */; (void) channel_id_arr; (void) transaction_arr;
1241                 }
1242                 default: abort();
1243         }
1244 }
1245 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_EventZ_ref_from_ptr(uint32_t ptr) {
1246         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1247         switch(obj->tag) {
1248                 case LDKCOption_EventZ_Some: {
1249                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1250                         return 0 /* LDKCOption_EventZ - Some */; (void) some_ref;
1251                 }
1252                 case LDKCOption_EventZ_None: {
1253                         return 0 /* LDKCOption_EventZ - None */;
1254                 }
1255                 default: abort();
1256         }
1257 }
1258 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_EventZDecodeErrorZ_get_ok(uint32_t arg) {
1259         LDKCResult_COption_EventZDecodeErrorZ *val = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
1260         CHECK(val->result_ok);
1261         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1262         return res_ref;
1263 }
1264 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_EventZDecodeErrorZ_get_err(uint32_t arg) {
1265         LDKCResult_COption_EventZDecodeErrorZ *val = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
1266         CHECK(!val->result_ok);
1267         LDKDecodeError err_var = (*val->contents.err);
1268         uint64_t err_ref = 0;
1269         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1270         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1271         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1272         err_ref = (uint64_t)err_var.inner & ~1;
1273         return err_ref;
1274 }
1275 uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
1276         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1277         switch(obj->tag) {
1278                 case LDKErrorAction_DisconnectPeer: {
1279                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1280                         uint64_t msg_ref = 0;
1281                         if ((uint64_t)msg_var.inner > 4096) {
1282                                 CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1283                                 CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1284                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1285                                 msg_ref = (uint64_t)msg_var.inner & ~1;
1286                         }
1287                         return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
1288                 }
1289                 case LDKErrorAction_IgnoreError: {
1290                         return 0 /* LDKErrorAction - IgnoreError */;
1291                 }
1292                 case LDKErrorAction_IgnoreAndLog: {
1293                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
1294                         return 0 /* LDKErrorAction - IgnoreAndLog */; (void) ignore_and_log_conv;
1295                 }
1296                 case LDKErrorAction_SendErrorMessage: {
1297                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1298                         uint64_t msg_ref = 0;
1299                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1300                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1301                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1302                         msg_ref = (uint64_t)msg_var.inner & ~1;
1303                         return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
1304                 }
1305                 default: abort();
1306         }
1307 }
1308 uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
1309         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1310         switch(obj->tag) {
1311                 case LDKMessageSendEvent_SendAcceptChannel: {
1312                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1313                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
1314                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1315                         uint64_t msg_ref = 0;
1316                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1317                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1318                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1319                         msg_ref = (uint64_t)msg_var.inner & ~1;
1320                         return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
1321                 }
1322                 case LDKMessageSendEvent_SendOpenChannel: {
1323                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1324                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
1325                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1326                         uint64_t msg_ref = 0;
1327                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1328                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1329                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1330                         msg_ref = (uint64_t)msg_var.inner & ~1;
1331                         return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
1332                 }
1333                 case LDKMessageSendEvent_SendFundingCreated: {
1334                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1335                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
1336                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1337                         uint64_t msg_ref = 0;
1338                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1339                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1340                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1341                         msg_ref = (uint64_t)msg_var.inner & ~1;
1342                         return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
1343                 }
1344                 case LDKMessageSendEvent_SendFundingSigned: {
1345                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1346                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
1347                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1348                         uint64_t msg_ref = 0;
1349                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1350                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1351                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1352                         msg_ref = (uint64_t)msg_var.inner & ~1;
1353                         return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
1354                 }
1355                 case LDKMessageSendEvent_SendFundingLocked: {
1356                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1357                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
1358                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1359                         uint64_t msg_ref = 0;
1360                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1361                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1362                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1363                         msg_ref = (uint64_t)msg_var.inner & ~1;
1364                         return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
1365                 }
1366                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1367                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1368                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
1369                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1370                         uint64_t msg_ref = 0;
1371                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1372                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1373                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1374                         msg_ref = (uint64_t)msg_var.inner & ~1;
1375                         return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
1376                 }
1377                 case LDKMessageSendEvent_UpdateHTLCs: {
1378                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1379                         memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
1380                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1381                         uint64_t updates_ref = 0;
1382                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1383                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1384                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
1385                         updates_ref = (uint64_t)updates_var.inner & ~1;
1386                         return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
1387                 }
1388                 case LDKMessageSendEvent_SendRevokeAndACK: {
1389                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1390                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
1391                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1392                         uint64_t msg_ref = 0;
1393                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1394                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1395                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1396                         msg_ref = (uint64_t)msg_var.inner & ~1;
1397                         return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
1398                 }
1399                 case LDKMessageSendEvent_SendClosingSigned: {
1400                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1401                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
1402                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1403                         uint64_t msg_ref = 0;
1404                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1405                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1406                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1407                         msg_ref = (uint64_t)msg_var.inner & ~1;
1408                         return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
1409                 }
1410                 case LDKMessageSendEvent_SendShutdown: {
1411                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1412                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
1413                         LDKShutdown msg_var = obj->send_shutdown.msg;
1414                         uint64_t msg_ref = 0;
1415                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1416                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1417                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1418                         msg_ref = (uint64_t)msg_var.inner & ~1;
1419                         return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
1420                 }
1421                 case LDKMessageSendEvent_SendChannelReestablish: {
1422                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1423                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
1424                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1425                         uint64_t msg_ref = 0;
1426                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1427                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1428                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1429                         msg_ref = (uint64_t)msg_var.inner & ~1;
1430                         return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
1431                 }
1432                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1433                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1434                         uint64_t msg_ref = 0;
1435                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1436                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1437                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1438                         msg_ref = (uint64_t)msg_var.inner & ~1;
1439                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1440                         uint64_t update_msg_ref = 0;
1441                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1442                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1443                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
1444                         update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1445                         return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
1446                 }
1447                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1448                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1449                         uint64_t msg_ref = 0;
1450                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1451                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1452                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1453                         msg_ref = (uint64_t)msg_var.inner & ~1;
1454                         return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
1455                 }
1456                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1457                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1458                         uint64_t msg_ref = 0;
1459                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1460                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1461                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1462                         msg_ref = (uint64_t)msg_var.inner & ~1;
1463                         return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
1464                 }
1465                 case LDKMessageSendEvent_SendChannelUpdate: {
1466                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1467                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_update.node_id.compressed_form, 33);
1468                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1469                         uint64_t msg_ref = 0;
1470                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1471                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1472                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1473                         msg_ref = (uint64_t)msg_var.inner & ~1;
1474                         return 0 /* LDKMessageSendEvent - SendChannelUpdate */; (void) node_id_arr; (void) msg_ref;
1475                 }
1476                 case LDKMessageSendEvent_HandleError: {
1477                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1478                         memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33);
1479                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1480                         return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
1481                 }
1482                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1483                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1484                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
1485                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1486                         uint64_t msg_ref = 0;
1487                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1488                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1489                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1490                         msg_ref = (uint64_t)msg_var.inner & ~1;
1491                         return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
1492                 }
1493                 case LDKMessageSendEvent_SendShortIdsQuery: {
1494                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1495                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
1496                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1497                         uint64_t msg_ref = 0;
1498                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1499                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1500                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1501                         msg_ref = (uint64_t)msg_var.inner & ~1;
1502                         return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
1503                 }
1504                 case LDKMessageSendEvent_SendReplyChannelRange: {
1505                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1506                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_reply_channel_range.node_id.compressed_form, 33);
1507                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1508                         uint64_t msg_ref = 0;
1509                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1510                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1511                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1512                         msg_ref = (uint64_t)msg_var.inner & ~1;
1513                         return 0 /* LDKMessageSendEvent - SendReplyChannelRange */; (void) node_id_arr; (void) msg_ref;
1514                 }
1515                 default: abort();
1516         }
1517 }
1518 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1519         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1520         for (size_t i = 0; i < ret.datalen; i++) {
1521                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1522         }
1523         return ret;
1524 }
1525 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1526         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1527         CHECK(val->result_ok);
1528         LDKInitFeatures res_var = (*val->contents.result);
1529         uint64_t res_ref = 0;
1530         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1531         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1532         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1533         res_ref = (uint64_t)res_var.inner & ~1;
1534         return res_ref;
1535 }
1536 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1537         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1538         CHECK(!val->result_ok);
1539         LDKDecodeError err_var = (*val->contents.err);
1540         uint64_t err_ref = 0;
1541         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1542         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1543         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1544         err_ref = (uint64_t)err_var.inner & ~1;
1545         return err_ref;
1546 }
1547 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1548         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1549         CHECK(val->result_ok);
1550         LDKNodeFeatures res_var = (*val->contents.result);
1551         uint64_t res_ref = 0;
1552         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1553         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1554         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1555         res_ref = (uint64_t)res_var.inner & ~1;
1556         return res_ref;
1557 }
1558 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1559         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1560         CHECK(!val->result_ok);
1561         LDKDecodeError err_var = (*val->contents.err);
1562         uint64_t err_ref = 0;
1563         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1564         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1565         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1566         err_ref = (uint64_t)err_var.inner & ~1;
1567         return err_ref;
1568 }
1569 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1570         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1571         CHECK(val->result_ok);
1572         LDKChannelFeatures res_var = (*val->contents.result);
1573         uint64_t res_ref = 0;
1574         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1575         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1576         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1577         res_ref = (uint64_t)res_var.inner & ~1;
1578         return res_ref;
1579 }
1580 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1581         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1582         CHECK(!val->result_ok);
1583         LDKDecodeError err_var = (*val->contents.err);
1584         uint64_t err_ref = 0;
1585         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1586         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1587         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1588         err_ref = (uint64_t)err_var.inner & ~1;
1589         return err_ref;
1590 }
1591 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1592         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1593         CHECK(val->result_ok);
1594         LDKInvoiceFeatures res_var = (*val->contents.result);
1595         uint64_t res_ref = 0;
1596         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1597         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1598         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1599         res_ref = (uint64_t)res_var.inner & ~1;
1600         return res_ref;
1601 }
1602 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1603         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1604         CHECK(!val->result_ok);
1605         LDKDecodeError err_var = (*val->contents.err);
1606         uint64_t err_ref = 0;
1607         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1608         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1609         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1610         err_ref = (uint64_t)err_var.inner & ~1;
1611         return err_ref;
1612 }
1613 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScoringParametersDecodeErrorZ_get_ok(uint32_t arg) {
1614         LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
1615         CHECK(val->result_ok);
1616         LDKScoringParameters res_var = (*val->contents.result);
1617         uint64_t res_ref = 0;
1618         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1619         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1620         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1621         res_ref = (uint64_t)res_var.inner & ~1;
1622         return res_ref;
1623 }
1624 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScoringParametersDecodeErrorZ_get_err(uint32_t arg) {
1625         LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
1626         CHECK(!val->result_ok);
1627         LDKDecodeError err_var = (*val->contents.err);
1628         uint64_t err_ref = 0;
1629         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1630         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1631         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1632         err_ref = (uint64_t)err_var.inner & ~1;
1633         return err_ref;
1634 }
1635 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScorerDecodeErrorZ_get_ok(uint32_t arg) {
1636         LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
1637         CHECK(val->result_ok);
1638         LDKScorer res_var = (*val->contents.result);
1639         uint64_t res_ref = 0;
1640         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1641         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1642         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1643         res_ref = (uint64_t)res_var.inner & ~1;
1644         return res_ref;
1645 }
1646 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScorerDecodeErrorZ_get_err(uint32_t arg) {
1647         LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
1648         CHECK(!val->result_ok);
1649         LDKDecodeError err_var = (*val->contents.err);
1650         uint64_t err_ref = 0;
1651         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1652         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1653         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1654         err_ref = (uint64_t)err_var.inner & ~1;
1655         return err_ref;
1656 }
1657 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1658         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1659         CHECK(val->result_ok);
1660         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
1661         uint64_t res_ref = 0;
1662         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1663         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1664         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1665         res_ref = (uint64_t)res_var.inner & ~1;
1666         return res_ref;
1667 }
1668 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1669         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1670         CHECK(!val->result_ok);
1671         LDKDecodeError err_var = (*val->contents.err);
1672         uint64_t err_ref = 0;
1673         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1674         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1675         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1676         err_ref = (uint64_t)err_var.inner & ~1;
1677         return err_ref;
1678 }
1679 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1680         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1681         CHECK(val->result_ok);
1682         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
1683         uint64_t res_ref = 0;
1684         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1685         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1686         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1687         res_ref = (uint64_t)res_var.inner & ~1;
1688         return res_ref;
1689 }
1690 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1691         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1692         CHECK(!val->result_ok);
1693         LDKDecodeError err_var = (*val->contents.err);
1694         uint64_t err_ref = 0;
1695         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1696         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1697         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1698         err_ref = (uint64_t)err_var.inner & ~1;
1699         return err_ref;
1700 }
1701 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1702         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1703         CHECK(val->result_ok);
1704         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1705         return res_ref;
1706 }
1707 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1708         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1709         CHECK(!val->result_ok);
1710         LDKDecodeError err_var = (*val->contents.err);
1711         uint64_t err_ref = 0;
1712         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1713         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1714         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1715         err_ref = (uint64_t)err_var.inner & ~1;
1716         return err_ref;
1717 }
1718 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_ok(uint32_t arg) {
1719         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
1720         CHECK(val->result_ok);
1721         return *val->contents.result;
1722 }
1723 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_err(uint32_t arg) {
1724         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
1725         CHECK(!val->result_ok);
1726         return *val->contents.err;
1727 }
1728 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
1729         return tuple->a;
1730 }
1731 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t tuple) {
1732         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
1733         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1734         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_SignatureCVec_SignatureZZ_get_a(tuple_conv).compact_form, 64);
1735         return ret_arr;
1736 }
1737
1738 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
1739         return tuple->b;
1740 }
1741 ptrArray  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t tuple) {
1742         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
1743         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(tuple_conv);
1744         ptrArray ret_arr = NULL;
1745         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1746         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
1747         for (size_t m = 0; m < ret_var.datalen; m++) {
1748                 int8_tArray ret_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1749                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compact_form, 64);
1750                 ret_arr_ptr[m] = ret_conv_12_arr;
1751         }
1752         
1753         FREE(ret_var.data);
1754         return ret_arr;
1755 }
1756
1757 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
1758         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1759         CHECK(val->result_ok);
1760         LDKC2Tuple_SignatureCVec_SignatureZZ* res_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1761         *res_conv = (*val->contents.result);
1762         *res_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(res_conv);
1763         return ((uint64_t)res_conv);
1764 }
1765 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
1766         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1767         CHECK(!val->result_ok);
1768         return *val->contents.err;
1769 }
1770 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
1771         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1772         CHECK(val->result_ok);
1773         int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1774         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
1775         return res_arr;
1776 }
1777 void  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
1778         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1779         CHECK(!val->result_ok);
1780         return *val->contents.err;
1781 }
1782 typedef struct LDKBaseSign_JCalls {
1783         atomic_size_t refcnt;
1784         uint32_t get_per_commitment_point_meth;
1785         uint32_t release_commitment_secret_meth;
1786         uint32_t validate_holder_commitment_meth;
1787         uint32_t channel_keys_id_meth;
1788         uint32_t sign_counterparty_commitment_meth;
1789         uint32_t validate_counterparty_revocation_meth;
1790         uint32_t sign_holder_commitment_and_htlcs_meth;
1791         uint32_t sign_justice_revoked_output_meth;
1792         uint32_t sign_justice_revoked_htlc_meth;
1793         uint32_t sign_counterparty_htlc_transaction_meth;
1794         uint32_t sign_closing_transaction_meth;
1795         uint32_t sign_channel_announcement_meth;
1796         uint32_t ready_channel_meth;
1797 } LDKBaseSign_JCalls;
1798 static void LDKBaseSign_JCalls_free(void* this_arg) {
1799         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1800         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1801                 js_free(j_calls->get_per_commitment_point_meth);
1802                 js_free(j_calls->release_commitment_secret_meth);
1803                 js_free(j_calls->validate_holder_commitment_meth);
1804                 js_free(j_calls->channel_keys_id_meth);
1805                 js_free(j_calls->sign_counterparty_commitment_meth);
1806                 js_free(j_calls->validate_counterparty_revocation_meth);
1807                 js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
1808                 js_free(j_calls->sign_justice_revoked_output_meth);
1809                 js_free(j_calls->sign_justice_revoked_htlc_meth);
1810                 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
1811                 js_free(j_calls->sign_closing_transaction_meth);
1812                 js_free(j_calls->sign_channel_announcement_meth);
1813                 js_free(j_calls->ready_channel_meth);
1814                 FREE(j_calls);
1815         }
1816 }
1817 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1818         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1819         int8_tArray ret = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
1820         LDKPublicKey ret_ref;
1821         CHECK(*((uint32_t*)ret) == 33);
1822         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
1823         return ret_ref;
1824 }
1825 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1826         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1827         int8_tArray ret = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
1828         LDKThirtyTwoBytes ret_ref;
1829         CHECK(*((uint32_t*)ret) == 32);
1830         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1831         return ret_ref;
1832 }
1833 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
1834         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1835         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
1836         uint64_t holder_tx_ref = 0;
1837         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
1838         CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1839         CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1840         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
1841         holder_tx_ref = (uint64_t)holder_tx_var.inner;
1842         if (holder_tx_var.is_owned) {
1843                 holder_tx_ref |= 1;
1844         }
1845         uint32_t ret = js_invoke_function_1(j_calls->validate_holder_commitment_meth, holder_tx_ref);
1846         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1847         CHECK_ACCESS(ret_ptr);
1848         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
1849         FREE((void*)ret);
1850         return ret_conv;
1851 }
1852 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
1853         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1854         int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth);
1855         LDKThirtyTwoBytes ret_ref;
1856         CHECK(*((uint32_t*)ret) == 32);
1857         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1858         return ret_ref;
1859 }
1860 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1861         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1862         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1863         uint64_t commitment_tx_ref = 0;
1864         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1865         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1866         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1867         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
1868         commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1869         if (commitment_tx_var.is_owned) {
1870                 commitment_tx_ref |= 1;
1871         }
1872         uint32_t ret = js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1873         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1874         CHECK_ACCESS(ret_ptr);
1875         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
1876         FREE((void*)ret);
1877         return ret_conv;
1878 }
1879 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
1880         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1881         int8_tArray secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1882         memcpy((uint8_t*)(secret_arr + 4), *secret, 32);
1883         uint32_t ret = js_invoke_function_2(j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
1884         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1885         CHECK_ACCESS(ret_ptr);
1886         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
1887         FREE((void*)ret);
1888         return ret_conv;
1889 }
1890 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1891         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1892         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1893         uint64_t commitment_tx_ref = 0;
1894         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1895         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1896         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1897         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
1898         commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1899         if (commitment_tx_var.is_owned) {
1900                 commitment_tx_ref |= 1;
1901         }
1902         uint32_t ret = js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
1903         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1904         CHECK_ACCESS(ret_ptr);
1905         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
1906         FREE((void*)ret);
1907         return ret_conv;
1908 }
1909 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]) {
1910         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1911         LDKTransaction justice_tx_var = justice_tx;
1912         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1913         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1914         Transaction_free(justice_tx_var);
1915         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1916         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1917         uint32_t ret = js_invoke_function_4(j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
1918         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1919         CHECK_ACCESS(ret_ptr);
1920         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
1921         FREE((void*)ret);
1922         return ret_conv;
1923 }
1924 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) {
1925         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1926         LDKTransaction justice_tx_var = justice_tx;
1927         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1928         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1929         Transaction_free(justice_tx_var);
1930         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1931         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1932         LDKHTLCOutputInCommitment htlc_var = *htlc;
1933         uint64_t htlc_ref = 0;
1934         htlc_var = HTLCOutputInCommitment_clone(htlc);
1935         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1936         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1937         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
1938         htlc_ref = (uint64_t)htlc_var.inner;
1939         if (htlc_var.is_owned) {
1940                 htlc_ref |= 1;
1941         }
1942         uint32_t ret = js_invoke_function_5(j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
1943         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1944         CHECK_ACCESS(ret_ptr);
1945         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
1946         FREE((void*)ret);
1947         return ret_conv;
1948 }
1949 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) {
1950         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1951         LDKTransaction htlc_tx_var = htlc_tx;
1952         int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1953         memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
1954         Transaction_free(htlc_tx_var);
1955         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1956         memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
1957         LDKHTLCOutputInCommitment htlc_var = *htlc;
1958         uint64_t htlc_ref = 0;
1959         htlc_var = HTLCOutputInCommitment_clone(htlc);
1960         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1961         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1962         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
1963         htlc_ref = (uint64_t)htlc_var.inner;
1964         if (htlc_var.is_owned) {
1965                 htlc_ref |= 1;
1966         }
1967         uint32_t ret = js_invoke_function_5(j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
1968         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1969         CHECK_ACCESS(ret_ptr);
1970         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
1971         FREE((void*)ret);
1972         return ret_conv;
1973 }
1974 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
1975         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1976         LDKClosingTransaction closing_tx_var = *closing_tx;
1977         uint64_t closing_tx_ref = 0;
1978         closing_tx_var = ClosingTransaction_clone(closing_tx);
1979         CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1980         CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1981         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
1982         closing_tx_ref = (uint64_t)closing_tx_var.inner;
1983         if (closing_tx_var.is_owned) {
1984                 closing_tx_ref |= 1;
1985         }
1986         uint32_t ret = js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_ref);
1987         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1988         CHECK_ACCESS(ret_ptr);
1989         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
1990         FREE((void*)ret);
1991         return ret_conv;
1992 }
1993 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1994         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1995         LDKUnsignedChannelAnnouncement msg_var = *msg;
1996         uint64_t msg_ref = 0;
1997         msg_var = UnsignedChannelAnnouncement_clone(msg);
1998         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1999         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2000         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2001         msg_ref = (uint64_t)msg_var.inner;
2002         if (msg_var.is_owned) {
2003                 msg_ref |= 1;
2004         }
2005         uint32_t ret = js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
2006         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2007         CHECK_ACCESS(ret_ptr);
2008         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2009         FREE((void*)ret);
2010         return ret_conv;
2011 }
2012 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2013         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2014         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2015         uint64_t channel_parameters_ref = 0;
2016         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2017         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2018         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2019         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
2020         channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2021         if (channel_parameters_var.is_owned) {
2022                 channel_parameters_ref |= 1;
2023         }
2024         js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
2025 }
2026 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
2027         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
2028         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2029 }
2030 static inline LDKBaseSign LDKBaseSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
2031         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2032         atomic_init(&calls->refcnt, 1);
2033         //TODO: Assign calls->o from o
2034
2035         LDKChannelPublicKeys pubkeys_conv;
2036         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2037         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2038         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
2039
2040         LDKBaseSign ret = {
2041                 .this_arg = (void*) calls,
2042                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2043                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2044                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
2045                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2046                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2047                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
2048                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2049                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2050                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2051                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2052                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2053                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2054                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2055                 .free = LDKBaseSign_JCalls_free,
2056                 .pubkeys = pubkeys_conv,
2057                 .set_pubkeys = NULL,
2058         };
2059         return ret;
2060 }
2061 long  __attribute__((visibility("default"))) TS_LDKBaseSign_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
2062         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2063         *res_ptr = LDKBaseSign_init(o, pubkeys);
2064         return (long)res_ptr;
2065 }
2066 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
2067         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2068         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2069         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2070         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
2071         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
2072         return ret_arr;
2073 }
2074
2075 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
2076         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2077         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2078         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2079         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2080         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
2081         return ret_arr;
2082 }
2083
2084 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_validate_holder_commitment(uint32_t this_arg, uint32_t holder_tx) {
2085         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2086         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2087         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2088         LDKHolderCommitmentTransaction holder_tx_conv;
2089         holder_tx_conv.inner = (void*)(holder_tx & (~1));
2090         holder_tx_conv.is_owned = false;
2091         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
2092         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2093         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv);
2094         return (uint64_t)ret_conv;
2095 }
2096
2097 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
2098         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2099         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2100         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2101         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2102         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
2103         return ret_arr;
2104 }
2105
2106 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
2107         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2108         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2109         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2110         LDKCommitmentTransaction commitment_tx_conv;
2111         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2112         commitment_tx_conv.is_owned = false;
2113         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
2114         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2115         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2116         return (uint64_t)ret_conv;
2117 }
2118
2119 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_validate_counterparty_revocation(uint32_t this_arg, int64_t idx, int8_tArray secret) {
2120         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2121         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2122         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2123         unsigned char secret_arr[32];
2124         CHECK(*((uint32_t*)secret) == 32);
2125         memcpy(secret_arr, (uint8_t*)(secret + 4), 32);
2126         unsigned char (*secret_ref)[32] = &secret_arr;
2127         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2128         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
2129         return (uint64_t)ret_conv;
2130 }
2131
2132 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
2133         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2134         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2135         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2136         LDKHolderCommitmentTransaction commitment_tx_conv;
2137         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2138         commitment_tx_conv.is_owned = false;
2139         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
2140         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2141         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2142         return (uint64_t)ret_conv;
2143 }
2144
2145 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoked_output(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key) {
2146         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2147         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2148         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2149         LDKTransaction justice_tx_ref;
2150         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
2151         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2152         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
2153         justice_tx_ref.data_is_owned = true;
2154         unsigned char per_commitment_key_arr[32];
2155         CHECK(*((uint32_t*)per_commitment_key) == 32);
2156         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
2157         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2158         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2159         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2160         return (uint64_t)ret_conv;
2161 }
2162
2163 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoked_htlc(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
2164         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2165         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2166         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2167         LDKTransaction justice_tx_ref;
2168         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
2169         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2170         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
2171         justice_tx_ref.data_is_owned = true;
2172         unsigned char per_commitment_key_arr[32];
2173         CHECK(*((uint32_t*)per_commitment_key) == 32);
2174         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
2175         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2176         LDKHTLCOutputInCommitment htlc_conv;
2177         htlc_conv.inner = (void*)(htlc & (~1));
2178         htlc_conv.is_owned = false;
2179         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
2180         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2181         *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);
2182         return (uint64_t)ret_conv;
2183 }
2184
2185 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_htlc_transaction(uint32_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
2186         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2187         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2188         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2189         LDKTransaction htlc_tx_ref;
2190         htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
2191         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2192         memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
2193         htlc_tx_ref.data_is_owned = true;
2194         LDKPublicKey per_commitment_point_ref;
2195         CHECK(*((uint32_t*)per_commitment_point) == 33);
2196         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
2197         LDKHTLCOutputInCommitment htlc_conv;
2198         htlc_conv.inner = (void*)(htlc & (~1));
2199         htlc_conv.is_owned = false;
2200         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
2201         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2202         *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);
2203         return (uint64_t)ret_conv;
2204 }
2205
2206 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
2207         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2208         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2209         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2210         LDKClosingTransaction closing_tx_conv;
2211         closing_tx_conv.inner = (void*)(closing_tx & (~1));
2212         closing_tx_conv.is_owned = false;
2213         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
2214         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2215         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
2216         return (uint64_t)ret_conv;
2217 }
2218
2219 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
2220         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2221         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2222         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2223         LDKUnsignedChannelAnnouncement msg_conv;
2224         msg_conv.inner = (void*)(msg & (~1));
2225         msg_conv.is_owned = false;
2226         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
2227         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2228         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2229         return (uint64_t)ret_conv;
2230 }
2231
2232 void  __attribute__((visibility("default"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
2233         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2234         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2235         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2236         LDKChannelTransactionParameters channel_parameters_conv;
2237         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2238         channel_parameters_conv.is_owned = false;
2239         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
2240         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2241 }
2242
2243 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2244         if (this_arg->set_pubkeys != NULL)
2245                 this_arg->set_pubkeys(this_arg);
2246         return this_arg->pubkeys;
2247 }
2248 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
2249         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2250         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2251         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2252         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2253         uint64_t ret_ref = 0;
2254         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2255         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2257         ret_ref = (uint64_t)ret_var.inner;
2258         if (ret_var.is_owned) {
2259                 ret_ref |= 1;
2260         }
2261         return ret_ref;
2262 }
2263
2264 typedef struct LDKSign_JCalls {
2265         atomic_size_t refcnt;
2266         LDKBaseSign_JCalls* BaseSign;
2267         uint32_t write_meth;
2268 } LDKSign_JCalls;
2269 static void LDKSign_JCalls_free(void* this_arg) {
2270         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2271         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2272                 js_free(j_calls->write_meth);
2273                 FREE(j_calls);
2274         }
2275 }
2276 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2277         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2278         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
2279         LDKCVec_u8Z ret_ref;
2280         ret_ref.datalen = *((uint32_t*)ret);
2281         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2282         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
2283         return ret_ref;
2284 }
2285 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
2286         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
2287         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2288         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2289 }
2290 static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* BaseSign, uint32_t pubkeys) {
2291         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2292         atomic_init(&calls->refcnt, 1);
2293         //TODO: Assign calls->o from o
2294
2295         LDKChannelPublicKeys pubkeys_conv;
2296         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2297         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2298         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
2299
2300         LDKSign ret = {
2301                 .this_arg = (void*) calls,
2302                 .write = write_LDKSign_jcall,
2303                 .cloned = LDKSign_JCalls_cloned,
2304                 .free = LDKSign_JCalls_free,
2305                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
2306         };
2307         calls->BaseSign = ret.BaseSign.this_arg;
2308         return ret;
2309 }
2310 long  __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* BaseSign, uint32_t pubkeys) {
2311         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2312         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
2313         return (long)res_ptr;
2314 }
2315 int8_tArray  __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
2316         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2317         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2318         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
2319         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2320         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2321         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2322         CVec_u8Z_free(ret_var);
2323         return ret_arr;
2324 }
2325
2326 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) {
2327         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2328         CHECK(val->result_ok);
2329         LDKSign* res_ret = MALLOC(sizeof(LDKSign), "LDKSign");
2330         *res_ret = Sign_clone(&(*val->contents.result));
2331         return (uint64_t)res_ret;
2332 }
2333 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) {
2334         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2335         CHECK(!val->result_ok);
2336         LDKDecodeError err_var = (*val->contents.err);
2337         uint64_t err_ref = 0;
2338         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2339         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2340         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2341         err_ref = (uint64_t)err_var.inner & ~1;
2342         return err_ref;
2343 }
2344 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_ok(uint32_t arg) {
2345         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2346         CHECK(val->result_ok);
2347         int8_tArray es_arr = init_arr(68, sizeof(uint8_t), "Native int8_tArray Bytes");
2348         memcpy((uint8_t*)(es_arr + 4), (*val->contents.result).serialized_form, 68);
2349         return es_arr;
2350 }
2351 void  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_err(uint32_t arg) {
2352         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2353         CHECK(!val->result_ok);
2354         return *val->contents.err;
2355 }
2356 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2357         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2358         for (size_t i = 0; i < ret.datalen; i++) {
2359                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2360         }
2361         return ret;
2362 }
2363 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t arg) {
2364         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2365         CHECK(val->result_ok);
2366         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2367         ptrArray res_arr = NULL;
2368         res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
2369         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
2370         for (size_t m = 0; m < res_var.datalen; m++) {
2371                 LDKCVec_u8Z res_conv_12_var = res_var.data[m];
2372                 int8_tArray res_conv_12_arr = init_arr(res_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2373                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
2374                 res_arr_ptr[m] = res_conv_12_arr;
2375         }
2376         
2377         return res_arr;
2378 }
2379 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
2380         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2381         CHECK(!val->result_ok);
2382         return *val->contents.err;
2383 }
2384 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t arg) {
2385         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2386         CHECK(val->result_ok);
2387         LDKInMemorySigner res_var = (*val->contents.result);
2388         uint64_t res_ref = 0;
2389         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2390         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2391         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2392         res_ref = (uint64_t)res_var.inner & ~1;
2393         return res_ref;
2394 }
2395 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
2396         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2397         CHECK(!val->result_ok);
2398         LDKDecodeError err_var = (*val->contents.err);
2399         uint64_t err_ref = 0;
2400         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2401         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2402         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2403         err_ref = (uint64_t)err_var.inner & ~1;
2404         return err_ref;
2405 }
2406 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2407         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2408         for (size_t i = 0; i < ret.datalen; i++) {
2409                 ret.data[i] = TxOut_clone(&orig->data[i]);
2410         }
2411         return ret;
2412 }
2413 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_ok(uint32_t arg) {
2414         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2415         CHECK(val->result_ok);
2416         LDKTransaction res_var = (*val->contents.result);
2417         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2418         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
2419         return res_arr;
2420 }
2421 void  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_err(uint32_t arg) {
2422         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2423         CHECK(!val->result_ok);
2424         return *val->contents.err;
2425 }
2426 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
2427         return ThirtyTwoBytes_clone(&tuple->a);
2428 }
2429 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t tuple) {
2430         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
2431         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2432         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_BlockHashChannelMonitorZ_get_a(tuple_conv).data, 32);
2433         return ret_arr;
2434 }
2435
2436 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
2437         return ChannelMonitor_clone(&tuple->b);
2438 }
2439 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t tuple) {
2440         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
2441         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(tuple_conv);
2442         uint64_t ret_ref = 0;
2443         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2444         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2446         ret_ref = (uint64_t)ret_var.inner;
2447         if (ret_var.is_owned) {
2448                 ret_ref |= 1;
2449         }
2450         return ret_ref;
2451 }
2452
2453 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
2454         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
2455         for (size_t i = 0; i < ret.datalen; i++) {
2456                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
2457         }
2458         return ret;
2459 }
2460 uint32_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(uint32_t arg) {
2461         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2462         CHECK(val->result_ok);
2463         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2464         uint32_tArray res_arr = NULL;
2465         res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2466         uint32_t *res_arr_ptr = (uint32_t*)(res_arr + 4);
2467         for (size_t j = 0; j < res_var.datalen; j++) {
2468                 LDKC2Tuple_BlockHashChannelMonitorZ* res_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2469                 *res_conv_35_conv = res_var.data[j];
2470                 *res_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv_35_conv);
2471                 res_arr_ptr[j] = ((uint64_t)res_conv_35_conv);
2472         }
2473         
2474         return res_arr;
2475 }
2476 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(uint32_t arg) {
2477         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2478         CHECK(!val->result_ok);
2479         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
2480         return err_conv;
2481 }
2482 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u16Z_ref_from_ptr(uint32_t ptr) {
2483         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
2484         switch(obj->tag) {
2485                 case LDKCOption_u16Z_Some: {
2486                         return 0 /* LDKCOption_u16Z - Some */; (void) obj->some;
2487                 }
2488                 case LDKCOption_u16Z_None: {
2489                         return 0 /* LDKCOption_u16Z - None */;
2490                 }
2491                 default: abort();
2492         }
2493 }
2494 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
2495         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
2496         switch(obj->tag) {
2497                 case LDKAPIError_APIMisuseError: {
2498                         LDKStr err_str = obj->api_misuse_error.err;
2499                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2500                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_conv;
2501                 }
2502                 case LDKAPIError_FeeRateTooHigh: {
2503                         LDKStr err_str = obj->fee_rate_too_high.err;
2504                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2505                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_conv; (void) obj->fee_rate_too_high.feerate;
2506                 }
2507                 case LDKAPIError_RouteError: {
2508                         LDKStr err_str = obj->route_error.err;
2509                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2510                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
2511                 }
2512                 case LDKAPIError_ChannelUnavailable: {
2513                         LDKStr err_str = obj->channel_unavailable.err;
2514                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2515                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_conv;
2516                 }
2517                 case LDKAPIError_MonitorUpdateFailed: {
2518                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
2519                 }
2520                 case LDKAPIError_IncompatibleShutdownScript: {
2521                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
2522                         uint64_t script_ref = 0;
2523                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2524                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2525                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
2526                         script_ref = (uint64_t)script_var.inner & ~1;
2527                         return 0 /* LDKAPIError - IncompatibleShutdownScript */; (void) script_ref;
2528                 }
2529                 default: abort();
2530         }
2531 }
2532 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
2533         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2534         CHECK(val->result_ok);
2535         return *val->contents.result;
2536 }
2537 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
2538         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2539         CHECK(!val->result_ok);
2540         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2541         return err_ref;
2542 }
2543 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2544         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2545         for (size_t i = 0; i < ret.datalen; i++) {
2546                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2547         }
2548         return ret;
2549 }
2550 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2551         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2552         for (size_t i = 0; i < ret.datalen; i++) {
2553                 ret.data[i] = APIError_clone(&orig->data[i]);
2554         }
2555         return ret;
2556 }
2557 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult__u832APIErrorZ_get_ok(uint32_t arg) {
2558         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
2559         CHECK(val->result_ok);
2560         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2561         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2562         return res_arr;
2563 }
2564 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult__u832APIErrorZ_get_err(uint32_t arg) {
2565         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
2566         CHECK(!val->result_ok);
2567         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2568         return err_ref;
2569 }
2570 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_from_ptr(uint32_t ptr) {
2571         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
2572         switch(obj->tag) {
2573                 case LDKPaymentSendFailure_ParameterError: {
2574                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
2575                         return 0 /* LDKPaymentSendFailure - ParameterError */; (void) parameter_error_ref;
2576                 }
2577                 case LDKPaymentSendFailure_PathParameterError: {
2578                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
2579                         uint32_tArray path_parameter_error_arr = NULL;
2580                         path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2581                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(path_parameter_error_arr + 4);
2582                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
2583                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2584                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
2585                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
2586                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
2587                         }
2588                         
2589                         return 0 /* LDKPaymentSendFailure - PathParameterError */; (void) path_parameter_error_arr;
2590                 }
2591                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
2592                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
2593                         uint32_tArray all_failed_retry_safe_arr = NULL;
2594                         all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2595                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(all_failed_retry_safe_arr + 4);
2596                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
2597                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
2598                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
2599                         }
2600                         
2601                         return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */; (void) all_failed_retry_safe_arr;
2602                 }
2603                 case LDKPaymentSendFailure_PartialFailure: {
2604                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
2605                         uint32_tArray results_arr = NULL;
2606                         results_arr = init_arr(results_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2607                         uint32_t *results_arr_ptr = (uint32_t*)(results_arr + 4);
2608                         for (size_t w = 0; w < results_var.datalen; w++) {
2609                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2610                                 *results_conv_22_conv = results_var.data[w];
2611                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
2612                                 results_arr_ptr[w] = (uint64_t)results_conv_22_conv;
2613                         }
2614                         
2615                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
2616                         uint64_t failed_paths_retry_ref = 0;
2617                         if ((uint64_t)failed_paths_retry_var.inner > 4096) {
2618                                 CHECK((((uint64_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2619                                 CHECK((((uint64_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2620                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
2621                                 failed_paths_retry_ref = (uint64_t)failed_paths_retry_var.inner & ~1;
2622                         }
2623                         int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2624                         memcpy((uint8_t*)(payment_id_arr + 4), obj->partial_failure.payment_id.data, 32);
2625                         return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) results_arr; (void) failed_paths_retry_ref; (void) payment_id_arr;
2626                 }
2627                 default: abort();
2628         }
2629 }
2630 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t arg) {
2631         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
2632         CHECK(val->result_ok);
2633         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2634         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2635         return res_arr;
2636 }
2637 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t arg) {
2638         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
2639         CHECK(!val->result_ok);
2640         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2641         return err_ref;
2642 }
2643 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
2644         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2645         CHECK(val->result_ok);
2646         return *val->contents.result;
2647 }
2648 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
2649         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2650         CHECK(!val->result_ok);
2651         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2652         return err_ref;
2653 }
2654 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
2655         return ThirtyTwoBytes_clone(&tuple->a);
2656 }
2657 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t tuple) {
2658         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
2659         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2660         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentIdZ_get_a(tuple_conv).data, 32);
2661         return ret_arr;
2662 }
2663
2664 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
2665         return ThirtyTwoBytes_clone(&tuple->b);
2666 }
2667 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t tuple) {
2668         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
2669         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2670         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_conv).data, 32);
2671         return ret_arr;
2672 }
2673
2674 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t arg) {
2675         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
2676         CHECK(val->result_ok);
2677         LDKC2Tuple_PaymentHashPaymentIdZ* res_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
2678         *res_conv = (*val->contents.result);
2679         *res_conv = C2Tuple_PaymentHashPaymentIdZ_clone(res_conv);
2680         return ((uint64_t)res_conv);
2681 }
2682 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t arg) {
2683         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
2684         CHECK(!val->result_ok);
2685         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2686         return err_ref;
2687 }
2688 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
2689         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
2690         switch(obj->tag) {
2691                 case LDKNetAddress_IPv4: {
2692                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
2693                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
2694                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
2695                 }
2696                 case LDKNetAddress_IPv6: {
2697                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
2698                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
2699                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
2700                 }
2701                 case LDKNetAddress_OnionV2: {
2702                         int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
2703                         memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
2704                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
2705                 }
2706                 case LDKNetAddress_OnionV3: {
2707                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2708                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
2709                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
2710                 }
2711                 default: abort();
2712         }
2713 }
2714 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
2715         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
2716         for (size_t i = 0; i < ret.datalen; i++) {
2717                 ret.data[i] = NetAddress_clone(&orig->data[i]);
2718         }
2719         return ret;
2720 }
2721 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
2722         return ThirtyTwoBytes_clone(&tuple->a);
2723 }
2724 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t tuple) {
2725         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
2726         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2727         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentSecretZ_get_a(tuple_conv).data, 32);
2728         return ret_arr;
2729 }
2730
2731 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
2732         return ThirtyTwoBytes_clone(&tuple->b);
2733 }
2734 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t tuple) {
2735         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
2736         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2737         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentSecretZ_get_b(tuple_conv).data, 32);
2738         return ret_arr;
2739 }
2740
2741 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_ok(uint32_t arg) {
2742         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2743         CHECK(val->result_ok);
2744         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2745         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2746         return res_arr;
2747 }
2748 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_err(uint32_t arg) {
2749         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2750         CHECK(!val->result_ok);
2751         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2752         return err_ref;
2753 }
2754 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2755         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2756         for (size_t i = 0; i < ret.datalen; i++) {
2757                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2758         }
2759         return ret;
2760 }
2761 typedef struct LDKWatch_JCalls {
2762         atomic_size_t refcnt;
2763         uint32_t watch_channel_meth;
2764         uint32_t update_channel_meth;
2765         uint32_t release_pending_monitor_events_meth;
2766 } LDKWatch_JCalls;
2767 static void LDKWatch_JCalls_free(void* this_arg) {
2768         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2769         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2770                 js_free(j_calls->watch_channel_meth);
2771                 js_free(j_calls->update_channel_meth);
2772                 js_free(j_calls->release_pending_monitor_events_meth);
2773                 FREE(j_calls);
2774         }
2775 }
2776 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2777         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2778         LDKOutPoint funding_txo_var = funding_txo;
2779         uint64_t funding_txo_ref = 0;
2780         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2781         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2782         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
2783         funding_txo_ref = (uint64_t)funding_txo_var.inner;
2784         if (funding_txo_var.is_owned) {
2785                 funding_txo_ref |= 1;
2786         }
2787         LDKChannelMonitor monitor_var = monitor;
2788         uint64_t monitor_ref = 0;
2789         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2790         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2791         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
2792         monitor_ref = (uint64_t)monitor_var.inner;
2793         if (monitor_var.is_owned) {
2794                 monitor_ref |= 1;
2795         }
2796         uint32_t ret = js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2797         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2798         CHECK_ACCESS(ret_ptr);
2799         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
2800         FREE((void*)ret);
2801         return ret_conv;
2802 }
2803 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2804         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2805         LDKOutPoint funding_txo_var = funding_txo;
2806         uint64_t funding_txo_ref = 0;
2807         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2808         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2809         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
2810         funding_txo_ref = (uint64_t)funding_txo_var.inner;
2811         if (funding_txo_var.is_owned) {
2812                 funding_txo_ref |= 1;
2813         }
2814         LDKChannelMonitorUpdate update_var = update;
2815         uint64_t update_ref = 0;
2816         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2817         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2818         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
2819         update_ref = (uint64_t)update_var.inner;
2820         if (update_var.is_owned) {
2821                 update_ref |= 1;
2822         }
2823         uint32_t ret = js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
2824         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2825         CHECK_ACCESS(ret_ptr);
2826         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
2827         FREE((void*)ret);
2828         return ret_conv;
2829 }
2830 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
2831         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2832         uint32_tArray ret = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
2833         LDKCVec_MonitorEventZ ret_constr;
2834         ret_constr.datalen = *((uint32_t*)ret);
2835         if (ret_constr.datalen > 0)
2836                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2837         else
2838                 ret_constr.data = NULL;
2839         uint32_t* ret_vals = (uint32_t*)(ret + 4);
2840         for (size_t o = 0; o < ret_constr.datalen; o++) {
2841                 uint32_t ret_conv_14 = ret_vals[o];
2842                 void* ret_conv_14_ptr = (void*)(((uint64_t)ret_conv_14) & ~1);
2843                 CHECK_ACCESS(ret_conv_14_ptr);
2844                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
2845                 FREE((void*)ret_conv_14);
2846                 ret_constr.data[o] = ret_conv_14_conv;
2847         }
2848         return ret_constr;
2849 }
2850 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
2851         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
2852         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2853 }
2854 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
2855         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2856         atomic_init(&calls->refcnt, 1);
2857         //TODO: Assign calls->o from o
2858
2859         LDKWatch ret = {
2860                 .this_arg = (void*) calls,
2861                 .watch_channel = watch_channel_LDKWatch_jcall,
2862                 .update_channel = update_channel_LDKWatch_jcall,
2863                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
2864                 .free = LDKWatch_JCalls_free,
2865         };
2866         return ret;
2867 }
2868 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
2869         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2870         *res_ptr = LDKWatch_init(o);
2871         return (long)res_ptr;
2872 }
2873 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
2874         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2875         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2876         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
2877         LDKOutPoint funding_txo_conv;
2878         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2879         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2880         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
2881         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2882         LDKChannelMonitor monitor_conv;
2883         monitor_conv.inner = (void*)(monitor & (~1));
2884         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2885         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
2886         monitor_conv = ChannelMonitor_clone(&monitor_conv);
2887         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2888         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2889         return (uint64_t)ret_conv;
2890 }
2891
2892 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
2893         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2894         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2895         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
2896         LDKOutPoint funding_txo_conv;
2897         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2898         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2899         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
2900         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2901         LDKChannelMonitorUpdate update_conv;
2902         update_conv.inner = (void*)(update & (~1));
2903         update_conv.is_owned = (update & 1) || (update == 0);
2904         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
2905         update_conv = ChannelMonitorUpdate_clone(&update_conv);
2906         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2907         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2908         return (uint64_t)ret_conv;
2909 }
2910
2911 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
2912         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2913         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2914         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
2915         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2916         uint32_tArray ret_arr = NULL;
2917         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2918         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
2919         for (size_t o = 0; o < ret_var.datalen; o++) {
2920                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2921                 *ret_conv_14_copy = ret_var.data[o];
2922                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
2923                 ret_arr_ptr[o] = ret_conv_14_ref;
2924         }
2925         
2926         FREE(ret_var.data);
2927         return ret_arr;
2928 }
2929
2930 typedef struct LDKBroadcasterInterface_JCalls {
2931         atomic_size_t refcnt;
2932         uint32_t broadcast_transaction_meth;
2933 } LDKBroadcasterInterface_JCalls;
2934 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2935         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2936         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2937                 js_free(j_calls->broadcast_transaction_meth);
2938                 FREE(j_calls);
2939         }
2940 }
2941 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
2942         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2943         LDKTransaction tx_var = tx;
2944         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2945         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
2946         Transaction_free(tx_var);
2947         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
2948 }
2949 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
2950         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
2951         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2952 }
2953 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
2954         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2955         atomic_init(&calls->refcnt, 1);
2956         //TODO: Assign calls->o from o
2957
2958         LDKBroadcasterInterface ret = {
2959                 .this_arg = (void*) calls,
2960                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
2961                 .free = LDKBroadcasterInterface_JCalls_free,
2962         };
2963         return ret;
2964 }
2965 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
2966         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2967         *res_ptr = LDKBroadcasterInterface_init(o);
2968         return (long)res_ptr;
2969 }
2970 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
2971         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2972         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2973         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
2974         LDKTransaction tx_ref;
2975         tx_ref.datalen = *((uint32_t*)tx);
2976         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
2977         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
2978         tx_ref.data_is_owned = true;
2979         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
2980 }
2981
2982 typedef struct LDKKeysInterface_JCalls {
2983         atomic_size_t refcnt;
2984         uint32_t get_node_secret_meth;
2985         uint32_t get_destination_script_meth;
2986         uint32_t get_shutdown_scriptpubkey_meth;
2987         uint32_t get_channel_signer_meth;
2988         uint32_t get_secure_random_bytes_meth;
2989         uint32_t read_chan_signer_meth;
2990         uint32_t sign_invoice_meth;
2991 } LDKKeysInterface_JCalls;
2992 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2993         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2994         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2995                 js_free(j_calls->get_node_secret_meth);
2996                 js_free(j_calls->get_destination_script_meth);
2997                 js_free(j_calls->get_shutdown_scriptpubkey_meth);
2998                 js_free(j_calls->get_channel_signer_meth);
2999                 js_free(j_calls->get_secure_random_bytes_meth);
3000                 js_free(j_calls->read_chan_signer_meth);
3001                 js_free(j_calls->sign_invoice_meth);
3002                 FREE(j_calls);
3003         }
3004 }
3005 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3006         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3007         int8_tArray ret = js_invoke_function_0(j_calls->get_node_secret_meth);
3008         LDKSecretKey ret_ref;
3009         CHECK(*((uint32_t*)ret) == 32);
3010         memcpy(ret_ref.bytes, (uint8_t*)(ret + 4), 32);
3011         return ret_ref;
3012 }
3013 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
3014         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3015         int8_tArray ret = js_invoke_function_0(j_calls->get_destination_script_meth);
3016         LDKCVec_u8Z ret_ref;
3017         ret_ref.datalen = *((uint32_t*)ret);
3018         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3019         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
3020         return ret_ref;
3021 }
3022 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
3023         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3024         uint32_t ret = js_invoke_function_0(j_calls->get_shutdown_scriptpubkey_meth);
3025         LDKShutdownScript ret_conv;
3026         ret_conv.inner = (void*)(ret & (~1));
3027         ret_conv.is_owned = (ret & 1) || (ret == 0);
3028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
3029         return ret_conv;
3030 }
3031 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3032         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3033         uint32_t ret = js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3034         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3035         CHECK_ACCESS(ret_ptr);
3036         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
3037         FREE((void*)ret);
3038         return ret_conv;
3039 }
3040 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
3041         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3042         int8_tArray ret = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
3043         LDKThirtyTwoBytes ret_ref;
3044         CHECK(*((uint32_t*)ret) == 32);
3045         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
3046         return ret_ref;
3047 }
3048 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
3049         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3050         LDKu8slice reader_var = reader;
3051         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3052         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
3053         uint32_t ret = js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
3054         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3055         CHECK_ACCESS(ret_ptr);
3056         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
3057         FREE((void*)ret);
3058         return ret_conv;
3059 }
3060 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
3061         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3062         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
3063         int8_tArray invoice_preimage_arr = init_arr(invoice_preimage_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3064         memcpy((uint8_t*)(invoice_preimage_arr + 4), invoice_preimage_var.data, invoice_preimage_var.datalen);
3065         CVec_u8Z_free(invoice_preimage_var);
3066         uint32_t ret = js_invoke_function_1(j_calls->sign_invoice_meth, invoice_preimage_arr);
3067         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3068         CHECK_ACCESS(ret_ptr);
3069         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
3070         FREE((void*)ret);
3071         return ret_conv;
3072 }
3073 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
3074         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
3075         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3076 }
3077 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
3078         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3079         atomic_init(&calls->refcnt, 1);
3080         //TODO: Assign calls->o from o
3081
3082         LDKKeysInterface ret = {
3083                 .this_arg = (void*) calls,
3084                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
3085                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
3086                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
3087                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
3088                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
3089                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
3090                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
3091                 .free = LDKKeysInterface_JCalls_free,
3092         };
3093         return ret;
3094 }
3095 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
3096         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3097         *res_ptr = LDKKeysInterface_init(o);
3098         return (long)res_ptr;
3099 }
3100 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
3101         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3102         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3103         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3104         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3105         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
3106         return ret_arr;
3107 }
3108
3109 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
3110         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3111         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3112         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3113         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
3114         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3115         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3116         CVec_u8Z_free(ret_var);
3117         return ret_arr;
3118 }
3119
3120 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
3121         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3122         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3123         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3124         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
3125         uint64_t ret_ref = 0;
3126         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3127         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3128         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3129         ret_ref = (uint64_t)ret_var.inner;
3130         if (ret_var.is_owned) {
3131                 ret_ref |= 1;
3132         }
3133         return ret_ref;
3134 }
3135
3136 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
3137         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3138         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3139         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3140         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
3141         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
3142         return (uint64_t)ret_ret;
3143 }
3144
3145 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
3146         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3147         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3148         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3149         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3150         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
3151         return ret_arr;
3152 }
3153
3154 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
3155         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3156         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3157         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3158         LDKu8slice reader_ref;
3159         reader_ref.datalen = *((uint32_t*)reader);
3160         reader_ref.data = (int8_t*)(reader + 4);
3161         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
3162         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
3163         return (uint64_t)ret_conv;
3164 }
3165
3166 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
3167         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3168         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3169         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3170         LDKCVec_u8Z invoice_preimage_ref;
3171         invoice_preimage_ref.datalen = *((uint32_t*)invoice_preimage);
3172         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
3173         memcpy(invoice_preimage_ref.data, (uint8_t*)(invoice_preimage + 4), invoice_preimage_ref.datalen);
3174         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
3175         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
3176         return (uint64_t)ret_conv;
3177 }
3178
3179 typedef struct LDKFeeEstimator_JCalls {
3180         atomic_size_t refcnt;
3181         uint32_t get_est_sat_per_1000_weight_meth;
3182 } LDKFeeEstimator_JCalls;
3183 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
3184         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3185         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3186                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
3187                 FREE(j_calls);
3188         }
3189 }
3190 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
3191         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3192         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
3193         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
3194 }
3195 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
3196         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
3197         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3198 }
3199 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
3200         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
3201         atomic_init(&calls->refcnt, 1);
3202         //TODO: Assign calls->o from o
3203
3204         LDKFeeEstimator ret = {
3205                 .this_arg = (void*) calls,
3206                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
3207                 .free = LDKFeeEstimator_JCalls_free,
3208         };
3209         return ret;
3210 }
3211 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
3212         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
3213         *res_ptr = LDKFeeEstimator_init(o);
3214         return (long)res_ptr;
3215 }
3216 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
3217         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3218         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3219         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
3220         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
3221         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
3222         return ret_val;
3223 }
3224
3225 typedef struct LDKLogger_JCalls {
3226         atomic_size_t refcnt;
3227         uint32_t log_meth;
3228 } LDKLogger_JCalls;
3229 static void LDKLogger_JCalls_free(void* this_arg) {
3230         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3231         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3232                 js_free(j_calls->log_meth);
3233                 FREE(j_calls);
3234         }
3235 }
3236 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
3237         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3238         LDKRecord record_var = *record;
3239         uint64_t record_ref = 0;
3240         record_var = Record_clone(record);
3241         CHECK((((uint64_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3242         CHECK((((uint64_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3243         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
3244         record_ref = (uint64_t)record_var.inner;
3245         if (record_var.is_owned) {
3246                 record_ref |= 1;
3247         }
3248         js_invoke_function_1(j_calls->log_meth, record_ref);
3249 }
3250 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
3251         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
3252         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3253 }
3254 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
3255         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3256         atomic_init(&calls->refcnt, 1);
3257         //TODO: Assign calls->o from o
3258
3259         LDKLogger ret = {
3260                 .this_arg = (void*) calls,
3261                 .log = log_LDKLogger_jcall,
3262                 .free = LDKLogger_JCalls_free,
3263         };
3264         return ret;
3265 }
3266 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
3267         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3268         *res_ptr = LDKLogger_init(o);
3269         return (long)res_ptr;
3270 }
3271 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
3272         return ThirtyTwoBytes_clone(&tuple->a);
3273 }
3274 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t tuple) {
3275         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
3276         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3277         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_BlockHashChannelManagerZ_get_a(tuple_conv).data, 32);
3278         return ret_arr;
3279 }
3280
3281 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
3282         return &tuple->b;
3283 }
3284 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t tuple) {
3285         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
3286         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
3287         uint64_t ret_ref = 0;
3288         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3289         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3291         ret_ref = (uint64_t)ret_var.inner & ~1;
3292         return ret_ref;
3293 }
3294
3295 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
3296         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3297         CHECK(val->result_ok);
3298         LDKC2Tuple_BlockHashChannelManagerZ* res_conv = &(*val->contents.result);
3299         // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
3300         return ((uint64_t)res_conv) | 1;
3301 }
3302 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
3303         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3304         CHECK(!val->result_ok);
3305         LDKDecodeError err_var = (*val->contents.err);
3306         uint64_t err_ref = 0;
3307         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3308         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3309         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3310         err_ref = (uint64_t)err_var.inner & ~1;
3311         return err_ref;
3312 }
3313 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t arg) {
3314         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
3315         CHECK(val->result_ok);
3316         LDKChannelConfig res_var = (*val->contents.result);
3317         uint64_t res_ref = 0;
3318         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3319         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3320         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3321         res_ref = (uint64_t)res_var.inner & ~1;
3322         return res_ref;
3323 }
3324 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
3325         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
3326         CHECK(!val->result_ok);
3327         LDKDecodeError err_var = (*val->contents.err);
3328         uint64_t err_ref = 0;
3329         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3330         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3331         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3332         err_ref = (uint64_t)err_var.inner & ~1;
3333         return err_ref;
3334 }
3335 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_ok(uint32_t arg) {
3336         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
3337         CHECK(val->result_ok);
3338         LDKOutPoint res_var = (*val->contents.result);
3339         uint64_t res_ref = 0;
3340         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3341         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3342         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3343         res_ref = (uint64_t)res_var.inner & ~1;
3344         return res_ref;
3345 }
3346 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
3347         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
3348         CHECK(!val->result_ok);
3349         LDKDecodeError err_var = (*val->contents.err);
3350         uint64_t err_ref = 0;
3351         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3352         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3353         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3354         err_ref = (uint64_t)err_var.inner & ~1;
3355         return err_ref;
3356 }
3357 typedef struct LDKType_JCalls {
3358         atomic_size_t refcnt;
3359         uint32_t type_id_meth;
3360         uint32_t debug_str_meth;
3361         uint32_t write_meth;
3362 } LDKType_JCalls;
3363 static void LDKType_JCalls_free(void* this_arg) {
3364         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3365         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3366                 js_free(j_calls->type_id_meth);
3367                 js_free(j_calls->debug_str_meth);
3368                 js_free(j_calls->write_meth);
3369                 FREE(j_calls);
3370         }
3371 }
3372 uint16_t type_id_LDKType_jcall(const void* this_arg) {
3373         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3374         return js_invoke_function_0(j_calls->type_id_meth);
3375 }
3376 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
3377         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3378         uint32_t ret = js_invoke_function_0(j_calls->debug_str_meth);
3379         LDKStr ret_conv = str_ref_to_owned_c(ret);
3380         return ret_conv;
3381 }
3382 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
3383         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3384         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
3385         LDKCVec_u8Z ret_ref;
3386         ret_ref.datalen = *((uint32_t*)ret);
3387         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3388         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
3389         return ret_ref;
3390 }
3391 static void LDKType_JCalls_cloned(LDKType* new_obj) {
3392         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
3393         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3394 }
3395 static inline LDKType LDKType_init (/*TODO: JS Object Reference */void* o) {
3396         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
3397         atomic_init(&calls->refcnt, 1);
3398         //TODO: Assign calls->o from o
3399
3400         LDKType ret = {
3401                 .this_arg = (void*) calls,
3402                 .type_id = type_id_LDKType_jcall,
3403                 .debug_str = debug_str_LDKType_jcall,
3404                 .write = write_LDKType_jcall,
3405                 .cloned = LDKType_JCalls_cloned,
3406                 .free = LDKType_JCalls_free,
3407         };
3408         return ret;
3409 }
3410 long  __attribute__((visibility("default"))) TS_LDKType_new(/*TODO: JS Object Reference */void* o) {
3411         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
3412         *res_ptr = LDKType_init(o);
3413         return (long)res_ptr;
3414 }
3415 int16_t  __attribute__((visibility("default"))) TS_Type_type_id(uint32_t this_arg) {
3416         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3417         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3418         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
3419         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
3420         return ret_val;
3421 }
3422
3423 jstring  __attribute__((visibility("default"))) TS_Type_debug_str(uint32_t this_arg) {
3424         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3425         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3426         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
3427         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
3428         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
3429         Str_free(ret_str);
3430         return ret_conv;
3431 }
3432
3433 int8_tArray  __attribute__((visibility("default"))) TS_Type_write(uint32_t this_arg) {
3434         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3435         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3436         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
3437         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3438         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3439         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3440         CVec_u8Z_free(ret_var);
3441         return ret_arr;
3442 }
3443
3444 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_TypeZ_ref_from_ptr(uint32_t ptr) {
3445         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
3446         switch(obj->tag) {
3447                 case LDKCOption_TypeZ_Some: {
3448                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
3449                         *some_ret = Type_clone(&obj->some);
3450                         return 0 /* LDKCOption_TypeZ - Some */; (void) (uint64_t)some_ret;
3451                 }
3452                 case LDKCOption_TypeZ_None: {
3453                         return 0 /* LDKCOption_TypeZ - None */;
3454                 }
3455                 default: abort();
3456         }
3457 }
3458 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t arg) {
3459         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
3460         CHECK(val->result_ok);
3461         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3462         return res_ref;
3463 }
3464 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_err(uint32_t arg) {
3465         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
3466         CHECK(!val->result_ok);
3467         LDKDecodeError err_var = (*val->contents.err);
3468         uint64_t err_ref = 0;
3469         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3470         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3471         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3472         err_ref = (uint64_t)err_var.inner & ~1;
3473         return err_ref;
3474 }
3475 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentError_ref_from_ptr(uint32_t ptr) {
3476         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
3477         switch(obj->tag) {
3478                 case LDKPaymentError_Invoice: {
3479                         LDKStr invoice_str = obj->invoice;
3480                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
3481                         return 0 /* LDKPaymentError - Invoice */; (void) invoice_conv;
3482                 }
3483                 case LDKPaymentError_Routing: {
3484                         LDKLightningError routing_var = obj->routing;
3485                         uint64_t routing_ref = 0;
3486                         CHECK((((uint64_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3487                         CHECK((((uint64_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3488                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
3489                         routing_ref = (uint64_t)routing_var.inner & ~1;
3490                         return 0 /* LDKPaymentError - Routing */; (void) routing_ref;
3491                 }
3492                 case LDKPaymentError_Sending: {
3493                         uint64_t sending_ref = ((uint64_t)&obj->sending) | 1;
3494                         return 0 /* LDKPaymentError - Sending */; (void) sending_ref;
3495                 }
3496                 default: abort();
3497         }
3498 }
3499 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentErrorZ_get_ok(uint32_t arg) {
3500         LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
3501         CHECK(val->result_ok);
3502         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3503         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
3504         return res_arr;
3505 }
3506 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentErrorZ_get_err(uint32_t arg) {
3507         LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
3508         CHECK(!val->result_ok);
3509         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3510         return err_ref;
3511 }
3512 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_ok(uint32_t arg) {
3513         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
3514         CHECK(val->result_ok);
3515         uint32_t res_conv = LDKSiPrefix_to_js((*val->contents.result));
3516         return res_conv;
3517 }
3518 void  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_err(uint32_t arg) {
3519         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
3520         CHECK(!val->result_ok);
3521         return *val->contents.err;
3522 }
3523 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_ok(uint32_t arg) {
3524         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
3525         CHECK(val->result_ok);
3526         LDKInvoice res_var = (*val->contents.result);
3527         uint64_t res_ref = 0;
3528         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3529         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3530         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3531         res_ref = (uint64_t)res_var.inner & ~1;
3532         return res_ref;
3533 }
3534 void  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_err(uint32_t arg) {
3535         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
3536         CHECK(!val->result_ok);
3537         return *val->contents.err;
3538 }
3539 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_ok(uint32_t arg) {
3540         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
3541         CHECK(val->result_ok);
3542         LDKSignedRawInvoice res_var = (*val->contents.result);
3543         uint64_t res_ref = 0;
3544         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3545         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3546         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3547         res_ref = (uint64_t)res_var.inner & ~1;
3548         return res_ref;
3549 }
3550 void  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_err(uint32_t arg) {
3551         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
3552         CHECK(!val->result_ok);
3553         return *val->contents.err;
3554 }
3555 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
3556         return RawInvoice_clone(&tuple->a);
3557 }
3558 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t tuple) {
3559         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
3560         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
3561         uint64_t ret_ref = 0;
3562         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3563         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3565         ret_ref = (uint64_t)ret_var.inner;
3566         if (ret_var.is_owned) {
3567                 ret_ref |= 1;
3568         }
3569         return ret_ref;
3570 }
3571
3572 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
3573         return ThirtyTwoBytes_clone(&tuple->b);
3574 }
3575 int8_tArray  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t tuple) {
3576         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
3577         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3578         memcpy((uint8_t*)(ret_arr + 4), C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(tuple_conv).data, 32);
3579         return ret_arr;
3580 }
3581
3582 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
3583         return InvoiceSignature_clone(&tuple->c);
3584 }
3585 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t tuple) {
3586         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
3587         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
3588         uint64_t ret_ref = 0;
3589         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3590         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3592         ret_ref = (uint64_t)ret_var.inner;
3593         if (ret_var.is_owned) {
3594                 ret_ref |= 1;
3595         }
3596         return ret_ref;
3597 }
3598
3599 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_ok(uint32_t arg) {
3600         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
3601         CHECK(val->result_ok);
3602         LDKPayeePubKey res_var = (*val->contents.result);
3603         uint64_t res_ref = 0;
3604         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3605         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3606         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3607         res_ref = (uint64_t)res_var.inner & ~1;
3608         return res_ref;
3609 }
3610 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_err(uint32_t arg) {
3611         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
3612         CHECK(!val->result_ok);
3613         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3614         return err_conv;
3615 }
3616 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
3617         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
3618         for (size_t i = 0; i < ret.datalen; i++) {
3619                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
3620         }
3621         return ret;
3622 }
3623 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t arg) {
3624         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
3625         CHECK(val->result_ok);
3626         LDKPositiveTimestamp res_var = (*val->contents.result);
3627         uint64_t res_ref = 0;
3628         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3629         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3630         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3631         res_ref = (uint64_t)res_var.inner & ~1;
3632         return res_ref;
3633 }
3634 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_err(uint32_t arg) {
3635         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
3636         CHECK(!val->result_ok);
3637         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3638         return err_conv;
3639 }
3640 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_ok(uint32_t arg) {
3641         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3642         CHECK(val->result_ok);
3643         return *val->contents.result;
3644 }
3645 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_err(uint32_t arg) {
3646         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3647         CHECK(!val->result_ok);
3648         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3649         return err_conv;
3650 }
3651 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_ok(uint32_t arg) {
3652         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3653         CHECK(val->result_ok);
3654         LDKInvoice res_var = (*val->contents.result);
3655         uint64_t res_ref = 0;
3656         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3657         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3658         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3659         res_ref = (uint64_t)res_var.inner & ~1;
3660         return res_ref;
3661 }
3662 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_err(uint32_t arg) {
3663         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3664         CHECK(!val->result_ok);
3665         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3666         return err_conv;
3667 }
3668 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_ok(uint32_t arg) {
3669         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3670         CHECK(val->result_ok);
3671         LDKDescription res_var = (*val->contents.result);
3672         uint64_t res_ref = 0;
3673         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3674         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3675         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3676         res_ref = (uint64_t)res_var.inner & ~1;
3677         return res_ref;
3678 }
3679 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_err(uint32_t arg) {
3680         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3681         CHECK(!val->result_ok);
3682         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3683         return err_conv;
3684 }
3685 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_ok(uint32_t arg) {
3686         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3687         CHECK(val->result_ok);
3688         LDKExpiryTime res_var = (*val->contents.result);
3689         uint64_t res_ref = 0;
3690         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3691         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3692         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3693         res_ref = (uint64_t)res_var.inner & ~1;
3694         return res_ref;
3695 }
3696 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_err(uint32_t arg) {
3697         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3698         CHECK(!val->result_ok);
3699         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3700         return err_conv;
3701 }
3702 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_ok(uint32_t arg) {
3703         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3704         CHECK(val->result_ok);
3705         LDKPrivateRoute res_var = (*val->contents.result);
3706         uint64_t res_ref = 0;
3707         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3708         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3709         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3710         res_ref = (uint64_t)res_var.inner & ~1;
3711         return res_ref;
3712 }
3713 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_err(uint32_t arg) {
3714         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3715         CHECK(!val->result_ok);
3716         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3717         return err_conv;
3718 }
3719 jstring  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_ok(uint32_t arg) {
3720         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3721         CHECK(val->result_ok);
3722         LDKStr res_str = (*val->contents.result);
3723         jstring res_conv = str_ref_to_ts(res_str.chars, res_str.len);
3724         return res_conv;
3725 }
3726 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_err(uint32_t arg) {
3727         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3728         CHECK(!val->result_ok);
3729         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3730         return err_conv;
3731 }
3732 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3733         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3734         CHECK(val->result_ok);
3735         LDKChannelMonitorUpdate res_var = (*val->contents.result);
3736         uint64_t res_ref = 0;
3737         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3738         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3739         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3740         res_ref = (uint64_t)res_var.inner & ~1;
3741         return res_ref;
3742 }
3743 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
3744         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3745         CHECK(!val->result_ok);
3746         LDKDecodeError err_var = (*val->contents.err);
3747         uint64_t err_ref = 0;
3748         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3749         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3750         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3751         err_ref = (uint64_t)err_var.inner & ~1;
3752         return err_ref;
3753 }
3754 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_MonitorEventZ_ref_from_ptr(uint32_t ptr) {
3755         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
3756         switch(obj->tag) {
3757                 case LDKCOption_MonitorEventZ_Some: {
3758                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
3759                         return 0 /* LDKCOption_MonitorEventZ - Some */; (void) some_ref;
3760                 }
3761                 case LDKCOption_MonitorEventZ_None: {
3762                         return 0 /* LDKCOption_MonitorEventZ - None */;
3763                 }
3764                 default: abort();
3765         }
3766 }
3767 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t arg) {
3768         LDKCResult_COption_MonitorEventZDecodeErrorZ *val = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
3769         CHECK(val->result_ok);
3770         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3771         return res_ref;
3772 }
3773 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t arg) {
3774         LDKCResult_COption_MonitorEventZDecodeErrorZ *val = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
3775         CHECK(!val->result_ok);
3776         LDKDecodeError err_var = (*val->contents.err);
3777         uint64_t err_ref = 0;
3778         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3779         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3780         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3781         err_ref = (uint64_t)err_var.inner & ~1;
3782         return err_ref;
3783 }
3784 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3785         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3786         CHECK(val->result_ok);
3787         LDKHTLCUpdate res_var = (*val->contents.result);
3788         uint64_t res_ref = 0;
3789         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3790         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3791         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3792         res_ref = (uint64_t)res_var.inner & ~1;
3793         return res_ref;
3794 }
3795 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
3796         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3797         CHECK(!val->result_ok);
3798         LDKDecodeError err_var = (*val->contents.err);
3799         uint64_t err_ref = 0;
3800         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3801         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3802         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3803         err_ref = (uint64_t)err_var.inner & ~1;
3804         return err_ref;
3805 }
3806 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
3807         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3808         CHECK(val->result_ok);
3809         return *val->contents.result;
3810 }
3811 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
3812         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3813         CHECK(!val->result_ok);
3814         LDKMonitorUpdateError err_var = (*val->contents.err);
3815         uint64_t err_ref = 0;
3816         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3817         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3818         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3819         err_ref = (uint64_t)err_var.inner & ~1;
3820         return err_ref;
3821 }
3822 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
3823         return OutPoint_clone(&tuple->a);
3824 }
3825 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t tuple) {
3826         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
3827         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
3828         uint64_t ret_ref = 0;
3829         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3830         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3832         ret_ref = (uint64_t)ret_var.inner;
3833         if (ret_var.is_owned) {
3834                 ret_ref |= 1;
3835         }
3836         return ret_ref;
3837 }
3838
3839 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
3840         return CVec_u8Z_clone(&tuple->b);
3841 }
3842 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t tuple) {
3843         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
3844         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(tuple_conv);
3845         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3846         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3847         CVec_u8Z_free(ret_var);
3848         return ret_arr;
3849 }
3850
3851 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
3852         return tuple->a;
3853 }
3854 int32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t tuple) {
3855         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
3856         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(tuple_conv);
3857         return ret_val;
3858 }
3859
3860 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
3861         return CVec_u8Z_clone(&tuple->b);
3862 }
3863 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t tuple) {
3864         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
3865         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(tuple_conv);
3866         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3867         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3868         CVec_u8Z_free(ret_var);
3869         return ret_arr;
3870 }
3871
3872 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
3873         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
3874         for (size_t i = 0; i < ret.datalen; i++) {
3875                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
3876         }
3877         return ret;
3878 }
3879 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
3880         return ThirtyTwoBytes_clone(&tuple->a);
3881 }
3882 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t tuple) {
3883         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
3884         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3885         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(tuple_conv).data, 32);
3886         return ret_arr;
3887 }
3888
3889 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
3890         return CVec_C2Tuple_u32ScriptZZ_clone(&tuple->b);
3891 }
3892 uint32_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t tuple) {
3893         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
3894         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
3895         uint32_tArray ret_arr = NULL;
3896         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3897         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3898         for (size_t v = 0; v < ret_var.datalen; v++) {
3899                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
3900                 *ret_conv_21_conv = ret_var.data[v];
3901                 ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv);
3902         }
3903         
3904         FREE(ret_var.data);
3905         return ret_arr;
3906 }
3907
3908 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
3909         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 };
3910         for (size_t i = 0; i < ret.datalen; i++) {
3911                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
3912         }
3913         return ret;
3914 }
3915 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
3916         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
3917         for (size_t i = 0; i < ret.datalen; i++) {
3918                 ret.data[i] = Event_clone(&orig->data[i]);
3919         }
3920         return ret;
3921 }
3922 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
3923         return tuple->a;
3924 }
3925 int32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t tuple) {
3926         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
3927         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(tuple_conv);
3928         return ret_val;
3929 }
3930
3931 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
3932         return TxOut_clone(&tuple->b);
3933 }
3934 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t tuple) {
3935         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
3936         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3937         *ret_ref = C2Tuple_u32TxOutZ_get_b(tuple_conv);
3938         return (uint64_t)ret_ref;
3939 }
3940
3941 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
3942         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
3943         for (size_t i = 0; i < ret.datalen; i++) {
3944                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
3945         }
3946         return ret;
3947 }
3948 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
3949         return ThirtyTwoBytes_clone(&tuple->a);
3950 }
3951 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t tuple) {
3952         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
3953         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3954         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(tuple_conv).data, 32);
3955         return ret_arr;
3956 }
3957
3958 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
3959         return CVec_C2Tuple_u32TxOutZZ_clone(&tuple->b);
3960 }
3961 uint32_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t tuple) {
3962         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
3963         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
3964         uint32_tArray ret_arr = NULL;
3965         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3966         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3967         for (size_t u = 0; u < ret_var.datalen; u++) {
3968                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
3969                 *ret_conv_20_conv = ret_var.data[u];
3970                 ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
3971         }
3972         
3973         FREE(ret_var.data);
3974         return ret_arr;
3975 }
3976
3977 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
3978         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 };
3979         for (size_t i = 0; i < ret.datalen; i++) {
3980                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
3981         }
3982         return ret;
3983 }
3984 uint32_t __attribute__((visibility("default"))) TS_LDKBalance_ref_from_ptr(uint32_t ptr) {
3985         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
3986         switch(obj->tag) {
3987                 case LDKBalance_ClaimableOnChannelClose: {
3988                         return 0 /* LDKBalance - ClaimableOnChannelClose */; (void) obj->claimable_on_channel_close.claimable_amount_satoshis;
3989                 }
3990                 case LDKBalance_ClaimableAwaitingConfirmations: {
3991                         return 0 /* LDKBalance - ClaimableAwaitingConfirmations */; (void) obj->claimable_awaiting_confirmations.claimable_amount_satoshis; (void) obj->claimable_awaiting_confirmations.confirmation_height;
3992                 }
3993                 case LDKBalance_ContentiousClaimable: {
3994                         return 0 /* LDKBalance - ContentiousClaimable */; (void) obj->contentious_claimable.claimable_amount_satoshis; (void) obj->contentious_claimable.timeout_height;
3995                 }
3996                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
3997                         return 0 /* LDKBalance - MaybeClaimableHTLCAwaitingTimeout */; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
3998                 }
3999                 default: abort();
4000         }
4001 }
4002 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
4003         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
4004         for (size_t i = 0; i < ret.datalen; i++) {
4005                 ret.data[i] = Balance_clone(&orig->data[i]);
4006         }
4007         return ret;
4008 }
4009 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
4010         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4011         CHECK(val->result_ok);
4012         LDKC2Tuple_BlockHashChannelMonitorZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
4013         *res_conv = (*val->contents.result);
4014         *res_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv);
4015         return ((uint64_t)res_conv);
4016 }
4017 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
4018         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4019         CHECK(!val->result_ok);
4020         LDKDecodeError err_var = (*val->contents.err);
4021         uint64_t err_ref = 0;
4022         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4023         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4024         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4025         err_ref = (uint64_t)err_var.inner & ~1;
4026         return err_ref;
4027 }
4028 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
4029         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
4030         CHECK(val->result_ok);
4031         return *val->contents.result;
4032 }
4033 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
4034         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
4035         CHECK(!val->result_ok);
4036         LDKLightningError err_var = (*val->contents.err);
4037         uint64_t err_ref = 0;
4038         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4039         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4040         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4041         err_ref = (uint64_t)err_var.inner & ~1;
4042         return err_ref;
4043 }
4044 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
4045         return tuple->a;
4046 }
4047 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t tuple) {
4048         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
4049         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4050         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PublicKeyTypeZ_get_a(tuple_conv).compressed_form, 33);
4051         return ret_arr;
4052 }
4053
4054 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
4055         return Type_clone(&tuple->b);
4056 }
4057 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t tuple) {
4058         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
4059         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
4060         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
4061         return (uint64_t)ret_ret;
4062 }
4063
4064 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
4065         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
4066         for (size_t i = 0; i < ret.datalen; i++) {
4067                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
4068         }
4069         return ret;
4070 }
4071 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
4072         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4073         CHECK(val->result_ok);
4074         return *val->contents.result;
4075 }
4076 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
4077         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4078         CHECK(!val->result_ok);
4079         LDKLightningError err_var = (*val->contents.err);
4080         uint64_t err_ref = 0;
4081         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4082         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4083         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4084         err_ref = (uint64_t)err_var.inner & ~1;
4085         return err_ref;
4086 }
4087 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
4088         return ChannelAnnouncement_clone(&tuple->a);
4089 }
4090 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t tuple) {
4091         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
4092         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
4093         uint64_t ret_ref = 0;
4094         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4095         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4097         ret_ref = (uint64_t)ret_var.inner;
4098         if (ret_var.is_owned) {
4099                 ret_ref |= 1;
4100         }
4101         return ret_ref;
4102 }
4103
4104 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
4105         return ChannelUpdate_clone(&tuple->b);
4106 }
4107 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t tuple) {
4108         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
4109         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
4110         uint64_t ret_ref = 0;
4111         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4112         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4114         ret_ref = (uint64_t)ret_var.inner;
4115         if (ret_var.is_owned) {
4116                 ret_ref |= 1;
4117         }
4118         return ret_ref;
4119 }
4120
4121 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
4122         return ChannelUpdate_clone(&tuple->c);
4123 }
4124 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t tuple) {
4125         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
4126         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
4127         uint64_t ret_ref = 0;
4128         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4129         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4131         ret_ref = (uint64_t)ret_var.inner;
4132         if (ret_var.is_owned) {
4133                 ret_ref |= 1;
4134         }
4135         return ret_ref;
4136 }
4137
4138 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
4139         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
4140         for (size_t i = 0; i < ret.datalen; i++) {
4141                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
4142         }
4143         return ret;
4144 }
4145 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
4146         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
4147         for (size_t i = 0; i < ret.datalen; i++) {
4148                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
4149         }
4150         return ret;
4151 }
4152 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
4153         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4154         CHECK(val->result_ok);
4155         LDKCVec_u8Z res_var = (*val->contents.result);
4156         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4157         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
4158         return res_arr;
4159 }
4160 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
4161         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4162         CHECK(!val->result_ok);
4163         LDKPeerHandleError err_var = (*val->contents.err);
4164         uint64_t err_ref = 0;
4165         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4166         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4167         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4168         err_ref = (uint64_t)err_var.inner & ~1;
4169         return err_ref;
4170 }
4171 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
4172         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4173         CHECK(val->result_ok);
4174         return *val->contents.result;
4175 }
4176 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
4177         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4178         CHECK(!val->result_ok);
4179         LDKPeerHandleError err_var = (*val->contents.err);
4180         uint64_t err_ref = 0;
4181         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4182         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4183         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4184         err_ref = (uint64_t)err_var.inner & ~1;
4185         return err_ref;
4186 }
4187 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
4188         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4189         CHECK(val->result_ok);
4190         return *val->contents.result;
4191 }
4192 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
4193         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4194         CHECK(!val->result_ok);
4195         LDKPeerHandleError err_var = (*val->contents.err);
4196         uint64_t err_ref = 0;
4197         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4198         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4199         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4200         err_ref = (uint64_t)err_var.inner & ~1;
4201         return err_ref;
4202 }
4203 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_get_ok(uint32_t arg) {
4204         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
4205         CHECK(val->result_ok);
4206         LDKNodeId res_var = (*val->contents.result);
4207         uint64_t res_ref = 0;
4208         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4209         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4210         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4211         res_ref = (uint64_t)res_var.inner & ~1;
4212         return res_ref;
4213 }
4214 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_get_err(uint32_t arg) {
4215         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
4216         CHECK(!val->result_ok);
4217         LDKDecodeError err_var = (*val->contents.err);
4218         uint64_t err_ref = 0;
4219         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4220         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4221         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4222         err_ref = (uint64_t)err_var.inner & ~1;
4223         return err_ref;
4224 }
4225 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t arg) {
4226         LDKCResult_COption_NetworkUpdateZDecodeErrorZ *val = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
4227         CHECK(val->result_ok);
4228         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
4229         return res_ref;
4230 }
4231 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t arg) {
4232         LDKCResult_COption_NetworkUpdateZDecodeErrorZ *val = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
4233         CHECK(!val->result_ok);
4234         LDKDecodeError err_var = (*val->contents.err);
4235         uint64_t err_ref = 0;
4236         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4237         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4238         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4239         err_ref = (uint64_t)err_var.inner & ~1;
4240         return err_ref;
4241 }
4242 typedef struct LDKAccess_JCalls {
4243         atomic_size_t refcnt;
4244         uint32_t get_utxo_meth;
4245 } LDKAccess_JCalls;
4246 static void LDKAccess_JCalls_free(void* this_arg) {
4247         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4248         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4249                 js_free(j_calls->get_utxo_meth);
4250                 FREE(j_calls);
4251         }
4252 }
4253 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4254         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4255         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4256         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
4257         uint32_t ret = js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4258         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4259         CHECK_ACCESS(ret_ptr);
4260         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
4261         FREE((void*)ret);
4262         return ret_conv;
4263 }
4264 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
4265         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
4266         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4267 }
4268 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
4269         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4270         atomic_init(&calls->refcnt, 1);
4271         //TODO: Assign calls->o from o
4272
4273         LDKAccess ret = {
4274                 .this_arg = (void*) calls,
4275                 .get_utxo = get_utxo_LDKAccess_jcall,
4276                 .free = LDKAccess_JCalls_free,
4277         };
4278         return ret;
4279 }
4280 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
4281         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4282         *res_ptr = LDKAccess_init(o);
4283         return (long)res_ptr;
4284 }
4285 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
4286         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4287         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4288         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
4289         unsigned char genesis_hash_arr[32];
4290         CHECK(*((uint32_t*)genesis_hash) == 32);
4291         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
4292         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4293         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4294         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4295         return (uint64_t)ret_conv;
4296 }
4297
4298 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_AccessZ_ref_from_ptr(uint32_t ptr) {
4299         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
4300         switch(obj->tag) {
4301                 case LDKCOption_AccessZ_Some: {
4302                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
4303                         *some_ret = obj->some;
4304                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
4305                         return 0 /* LDKCOption_AccessZ - Some */; (void) (uint64_t)some_ret;
4306                 }
4307                 case LDKCOption_AccessZ_None: {
4308                         return 0 /* LDKCOption_AccessZ - None */;
4309                 }
4310                 default: abort();
4311         }
4312 }
4313 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
4314         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4315         CHECK(val->result_ok);
4316         LDKDirectionalChannelInfo res_var = (*val->contents.result);
4317         uint64_t res_ref = 0;
4318         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4319         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4320         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4321         res_ref = (uint64_t)res_var.inner & ~1;
4322         return res_ref;
4323 }
4324 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
4325         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4326         CHECK(!val->result_ok);
4327         LDKDecodeError err_var = (*val->contents.err);
4328         uint64_t err_ref = 0;
4329         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4330         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4331         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4332         err_ref = (uint64_t)err_var.inner & ~1;
4333         return err_ref;
4334 }
4335 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
4336         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4337         CHECK(val->result_ok);
4338         LDKChannelInfo res_var = (*val->contents.result);
4339         uint64_t res_ref = 0;
4340         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4341         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4342         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4343         res_ref = (uint64_t)res_var.inner & ~1;
4344         return res_ref;
4345 }
4346 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
4347         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4348         CHECK(!val->result_ok);
4349         LDKDecodeError err_var = (*val->contents.err);
4350         uint64_t err_ref = 0;
4351         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4352         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4353         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4354         err_ref = (uint64_t)err_var.inner & ~1;
4355         return err_ref;
4356 }
4357 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
4358         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4359         CHECK(val->result_ok);
4360         LDKRoutingFees res_var = (*val->contents.result);
4361         uint64_t res_ref = 0;
4362         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4363         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4364         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4365         res_ref = (uint64_t)res_var.inner & ~1;
4366         return res_ref;
4367 }
4368 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
4369         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4370         CHECK(!val->result_ok);
4371         LDKDecodeError err_var = (*val->contents.err);
4372         uint64_t err_ref = 0;
4373         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4374         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4375         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4376         err_ref = (uint64_t)err_var.inner & ~1;
4377         return err_ref;
4378 }
4379 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
4380         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
4381         CHECK(val->result_ok);
4382         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
4383         uint64_t res_ref = 0;
4384         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4385         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4386         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4387         res_ref = (uint64_t)res_var.inner & ~1;
4388         return res_ref;
4389 }
4390 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
4391         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
4392         CHECK(!val->result_ok);
4393         LDKDecodeError err_var = (*val->contents.err);
4394         uint64_t err_ref = 0;
4395         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4396         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4397         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4398         err_ref = (uint64_t)err_var.inner & ~1;
4399         return err_ref;
4400 }
4401 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
4402         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
4403         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
4404         return ret;
4405 }
4406 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
4407         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
4408         CHECK(val->result_ok);
4409         LDKNodeInfo res_var = (*val->contents.result);
4410         uint64_t res_ref = 0;
4411         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4412         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4413         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4414         res_ref = (uint64_t)res_var.inner & ~1;
4415         return res_ref;
4416 }
4417 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
4418         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
4419         CHECK(!val->result_ok);
4420         LDKDecodeError err_var = (*val->contents.err);
4421         uint64_t err_ref = 0;
4422         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4423         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4424         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4425         err_ref = (uint64_t)err_var.inner & ~1;
4426         return err_ref;
4427 }
4428 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
4429         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
4430         CHECK(val->result_ok);
4431         LDKNetworkGraph res_var = (*val->contents.result);
4432         uint64_t res_ref = 0;
4433         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4434         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4435         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4436         res_ref = (uint64_t)res_var.inner & ~1;
4437         return res_ref;
4438 }
4439 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
4440         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
4441         CHECK(!val->result_ok);
4442         LDKDecodeError err_var = (*val->contents.err);
4443         uint64_t err_ref = 0;
4444         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4445         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4446         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4447         err_ref = (uint64_t)err_var.inner & ~1;
4448         return err_ref;
4449 }
4450 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_CVec_NetAddressZZ_ref_from_ptr(uint32_t ptr) {
4451         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
4452         switch(obj->tag) {
4453                 case LDKCOption_CVec_NetAddressZZ_Some: {
4454                         LDKCVec_NetAddressZ some_var = obj->some;
4455                         uint32_tArray some_arr = NULL;
4456                         some_arr = init_arr(some_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4457                         uint32_t *some_arr_ptr = (uint32_t*)(some_arr + 4);
4458                         for (size_t m = 0; m < some_var.datalen; m++) {
4459                                 uint64_t some_conv_12_ref = ((uint64_t)&some_var.data[m]) | 1;
4460                                 some_arr_ptr[m] = some_conv_12_ref;
4461                         }
4462                         
4463                         return 0 /* LDKCOption_CVec_NetAddressZZ - Some */; (void) some_arr;
4464                 }
4465                 case LDKCOption_CVec_NetAddressZZ_None: {
4466                         return 0 /* LDKCOption_CVec_NetAddressZZ - None */;
4467                 }
4468                 default: abort();
4469         }
4470 }
4471 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_ok(uint32_t arg) {
4472         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
4473         CHECK(val->result_ok);
4474         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
4475         return res_ref;
4476 }
4477 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_err(uint32_t arg) {
4478         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
4479         CHECK(!val->result_ok);
4480         LDKDecodeError err_var = (*val->contents.err);
4481         uint64_t err_ref = 0;
4482         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4483         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4484         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4485         err_ref = (uint64_t)err_var.inner & ~1;
4486         return err_ref;
4487 }
4488 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
4489         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
4490         for (size_t i = 0; i < ret.datalen; i++) {
4491                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
4492         }
4493         return ret;
4494 }
4495 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
4496         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
4497         for (size_t i = 0; i < ret.datalen; i++) {
4498                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
4499         }
4500         return ret;
4501 }
4502 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
4503         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
4504         for (size_t i = 0; i < ret.datalen; i++) {
4505                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
4506         }
4507         return ret;
4508 }
4509 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
4510         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
4511         for (size_t i = 0; i < ret.datalen; i++) {
4512                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
4513         }
4514         return ret;
4515 }
4516 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t arg) {
4517         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
4518         CHECK(val->result_ok);
4519         LDKAcceptChannel res_var = (*val->contents.result);
4520         uint64_t res_ref = 0;
4521         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4522         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4523         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4524         res_ref = (uint64_t)res_var.inner & ~1;
4525         return res_ref;
4526 }
4527 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
4528         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
4529         CHECK(!val->result_ok);
4530         LDKDecodeError err_var = (*val->contents.err);
4531         uint64_t err_ref = 0;
4532         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4533         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4534         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4535         err_ref = (uint64_t)err_var.inner & ~1;
4536         return err_ref;
4537 }
4538 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t arg) {
4539         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
4540         CHECK(val->result_ok);
4541         LDKAnnouncementSignatures res_var = (*val->contents.result);
4542         uint64_t res_ref = 0;
4543         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4544         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4545         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4546         res_ref = (uint64_t)res_var.inner & ~1;
4547         return res_ref;
4548 }
4549 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
4550         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
4551         CHECK(!val->result_ok);
4552         LDKDecodeError err_var = (*val->contents.err);
4553         uint64_t err_ref = 0;
4554         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4555         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4556         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4557         err_ref = (uint64_t)err_var.inner & ~1;
4558         return err_ref;
4559 }
4560 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
4561         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4562         CHECK(val->result_ok);
4563         LDKChannelReestablish res_var = (*val->contents.result);
4564         uint64_t res_ref = 0;
4565         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4566         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4567         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4568         res_ref = (uint64_t)res_var.inner & ~1;
4569         return res_ref;
4570 }
4571 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
4572         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4573         CHECK(!val->result_ok);
4574         LDKDecodeError err_var = (*val->contents.err);
4575         uint64_t err_ref = 0;
4576         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4577         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4578         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4579         err_ref = (uint64_t)err_var.inner & ~1;
4580         return err_ref;
4581 }
4582 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4583         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4584         CHECK(val->result_ok);
4585         LDKClosingSigned res_var = (*val->contents.result);
4586         uint64_t res_ref = 0;
4587         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4588         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4589         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4590         res_ref = (uint64_t)res_var.inner & ~1;
4591         return res_ref;
4592 }
4593 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
4594         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4595         CHECK(!val->result_ok);
4596         LDKDecodeError err_var = (*val->contents.err);
4597         uint64_t err_ref = 0;
4598         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4599         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4600         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4601         err_ref = (uint64_t)err_var.inner & ~1;
4602         return err_ref;
4603 }
4604 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t arg) {
4605         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
4606         CHECK(val->result_ok);
4607         LDKClosingSignedFeeRange res_var = (*val->contents.result);
4608         uint64_t res_ref = 0;
4609         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4610         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4611         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4612         res_ref = (uint64_t)res_var.inner & ~1;
4613         return res_ref;
4614 }
4615 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t arg) {
4616         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
4617         CHECK(!val->result_ok);
4618         LDKDecodeError err_var = (*val->contents.err);
4619         uint64_t err_ref = 0;
4620         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4621         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4622         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4623         err_ref = (uint64_t)err_var.inner & ~1;
4624         return err_ref;
4625 }
4626 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t arg) {
4627         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4628         CHECK(val->result_ok);
4629         LDKCommitmentSigned res_var = (*val->contents.result);
4630         uint64_t res_ref = 0;
4631         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4632         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4633         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4634         res_ref = (uint64_t)res_var.inner & ~1;
4635         return res_ref;
4636 }
4637 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
4638         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4639         CHECK(!val->result_ok);
4640         LDKDecodeError err_var = (*val->contents.err);
4641         uint64_t err_ref = 0;
4642         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4643         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4644         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4645         err_ref = (uint64_t)err_var.inner & ~1;
4646         return err_ref;
4647 }
4648 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t arg) {
4649         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4650         CHECK(val->result_ok);
4651         LDKFundingCreated res_var = (*val->contents.result);
4652         uint64_t res_ref = 0;
4653         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4654         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4655         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4656         res_ref = (uint64_t)res_var.inner & ~1;
4657         return res_ref;
4658 }
4659 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
4660         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4661         CHECK(!val->result_ok);
4662         LDKDecodeError err_var = (*val->contents.err);
4663         uint64_t err_ref = 0;
4664         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4665         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4666         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4667         err_ref = (uint64_t)err_var.inner & ~1;
4668         return err_ref;
4669 }
4670 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4671         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4672         CHECK(val->result_ok);
4673         LDKFundingSigned res_var = (*val->contents.result);
4674         uint64_t res_ref = 0;
4675         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4676         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4677         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4678         res_ref = (uint64_t)res_var.inner & ~1;
4679         return res_ref;
4680 }
4681 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
4682         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4683         CHECK(!val->result_ok);
4684         LDKDecodeError err_var = (*val->contents.err);
4685         uint64_t err_ref = 0;
4686         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4687         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4688         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4689         err_ref = (uint64_t)err_var.inner & ~1;
4690         return err_ref;
4691 }
4692 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_ok(uint32_t arg) {
4693         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4694         CHECK(val->result_ok);
4695         LDKFundingLocked res_var = (*val->contents.result);
4696         uint64_t res_ref = 0;
4697         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4698         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4699         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4700         res_ref = (uint64_t)res_var.inner & ~1;
4701         return res_ref;
4702 }
4703 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
4704         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4705         CHECK(!val->result_ok);
4706         LDKDecodeError err_var = (*val->contents.err);
4707         uint64_t err_ref = 0;
4708         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4709         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4710         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4711         err_ref = (uint64_t)err_var.inner & ~1;
4712         return err_ref;
4713 }
4714 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
4715         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4716         CHECK(val->result_ok);
4717         LDKInit res_var = (*val->contents.result);
4718         uint64_t res_ref = 0;
4719         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4720         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4721         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4722         res_ref = (uint64_t)res_var.inner & ~1;
4723         return res_ref;
4724 }
4725 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
4726         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4727         CHECK(!val->result_ok);
4728         LDKDecodeError err_var = (*val->contents.err);
4729         uint64_t err_ref = 0;
4730         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4731         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4732         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4733         err_ref = (uint64_t)err_var.inner & ~1;
4734         return err_ref;
4735 }
4736 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_ok(uint32_t arg) {
4737         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4738         CHECK(val->result_ok);
4739         LDKOpenChannel res_var = (*val->contents.result);
4740         uint64_t res_ref = 0;
4741         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4742         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4743         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4744         res_ref = (uint64_t)res_var.inner & ~1;
4745         return res_ref;
4746 }
4747 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
4748         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4749         CHECK(!val->result_ok);
4750         LDKDecodeError err_var = (*val->contents.err);
4751         uint64_t err_ref = 0;
4752         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4753         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4754         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4755         err_ref = (uint64_t)err_var.inner & ~1;
4756         return err_ref;
4757 }
4758 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t arg) {
4759         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4760         CHECK(val->result_ok);
4761         LDKRevokeAndACK res_var = (*val->contents.result);
4762         uint64_t res_ref = 0;
4763         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4764         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4765         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4766         res_ref = (uint64_t)res_var.inner & ~1;
4767         return res_ref;
4768 }
4769 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
4770         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4771         CHECK(!val->result_ok);
4772         LDKDecodeError err_var = (*val->contents.err);
4773         uint64_t err_ref = 0;
4774         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4775         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4776         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4777         err_ref = (uint64_t)err_var.inner & ~1;
4778         return err_ref;
4779 }
4780 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_ok(uint32_t arg) {
4781         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4782         CHECK(val->result_ok);
4783         LDKShutdown res_var = (*val->contents.result);
4784         uint64_t res_ref = 0;
4785         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4786         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4787         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4788         res_ref = (uint64_t)res_var.inner & ~1;
4789         return res_ref;
4790 }
4791 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
4792         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4793         CHECK(!val->result_ok);
4794         LDKDecodeError err_var = (*val->contents.err);
4795         uint64_t err_ref = 0;
4796         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4797         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4798         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4799         err_ref = (uint64_t)err_var.inner & ~1;
4800         return err_ref;
4801 }
4802 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4803         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4804         CHECK(val->result_ok);
4805         LDKUpdateFailHTLC res_var = (*val->contents.result);
4806         uint64_t res_ref = 0;
4807         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4808         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4809         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4810         res_ref = (uint64_t)res_var.inner & ~1;
4811         return res_ref;
4812 }
4813 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
4814         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4815         CHECK(!val->result_ok);
4816         LDKDecodeError err_var = (*val->contents.err);
4817         uint64_t err_ref = 0;
4818         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4819         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4820         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4821         err_ref = (uint64_t)err_var.inner & ~1;
4822         return err_ref;
4823 }
4824 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4825         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4826         CHECK(val->result_ok);
4827         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
4828         uint64_t res_ref = 0;
4829         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4830         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4831         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4832         res_ref = (uint64_t)res_var.inner & ~1;
4833         return res_ref;
4834 }
4835 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
4836         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4837         CHECK(!val->result_ok);
4838         LDKDecodeError err_var = (*val->contents.err);
4839         uint64_t err_ref = 0;
4840         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4841         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4842         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4843         err_ref = (uint64_t)err_var.inner & ~1;
4844         return err_ref;
4845 }
4846 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t arg) {
4847         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4848         CHECK(val->result_ok);
4849         LDKUpdateFee res_var = (*val->contents.result);
4850         uint64_t res_ref = 0;
4851         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4852         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4853         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4854         res_ref = (uint64_t)res_var.inner & ~1;
4855         return res_ref;
4856 }
4857 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
4858         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4859         CHECK(!val->result_ok);
4860         LDKDecodeError err_var = (*val->contents.err);
4861         uint64_t err_ref = 0;
4862         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4863         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4864         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4865         err_ref = (uint64_t)err_var.inner & ~1;
4866         return err_ref;
4867 }
4868 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4869         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4870         CHECK(val->result_ok);
4871         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
4872         uint64_t res_ref = 0;
4873         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4874         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4875         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4876         res_ref = (uint64_t)res_var.inner & ~1;
4877         return res_ref;
4878 }
4879 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
4880         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4881         CHECK(!val->result_ok);
4882         LDKDecodeError err_var = (*val->contents.err);
4883         uint64_t err_ref = 0;
4884         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4885         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4886         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4887         err_ref = (uint64_t)err_var.inner & ~1;
4888         return err_ref;
4889 }
4890 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4891         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4892         CHECK(val->result_ok);
4893         LDKUpdateAddHTLC res_var = (*val->contents.result);
4894         uint64_t res_ref = 0;
4895         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4896         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4897         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4898         res_ref = (uint64_t)res_var.inner & ~1;
4899         return res_ref;
4900 }
4901 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
4902         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
4903         CHECK(!val->result_ok);
4904         LDKDecodeError err_var = (*val->contents.err);
4905         uint64_t err_ref = 0;
4906         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4907         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4908         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4909         err_ref = (uint64_t)err_var.inner & ~1;
4910         return err_ref;
4911 }
4912 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
4913         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4914         CHECK(val->result_ok);
4915         LDKPing res_var = (*val->contents.result);
4916         uint64_t res_ref = 0;
4917         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4918         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4919         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4920         res_ref = (uint64_t)res_var.inner & ~1;
4921         return res_ref;
4922 }
4923 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
4924         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
4925         CHECK(!val->result_ok);
4926         LDKDecodeError err_var = (*val->contents.err);
4927         uint64_t err_ref = 0;
4928         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4929         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4930         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4931         err_ref = (uint64_t)err_var.inner & ~1;
4932         return err_ref;
4933 }
4934 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
4935         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4936         CHECK(val->result_ok);
4937         LDKPong res_var = (*val->contents.result);
4938         uint64_t res_ref = 0;
4939         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4940         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4941         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4942         res_ref = (uint64_t)res_var.inner & ~1;
4943         return res_ref;
4944 }
4945 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
4946         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
4947         CHECK(!val->result_ok);
4948         LDKDecodeError err_var = (*val->contents.err);
4949         uint64_t err_ref = 0;
4950         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4951         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4952         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4953         err_ref = (uint64_t)err_var.inner & ~1;
4954         return err_ref;
4955 }
4956 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4957         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4958         CHECK(val->result_ok);
4959         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
4960         uint64_t res_ref = 0;
4961         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4962         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4963         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4964         res_ref = (uint64_t)res_var.inner & ~1;
4965         return res_ref;
4966 }
4967 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4968         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4969         CHECK(!val->result_ok);
4970         LDKDecodeError err_var = (*val->contents.err);
4971         uint64_t err_ref = 0;
4972         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4973         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4974         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4975         err_ref = (uint64_t)err_var.inner & ~1;
4976         return err_ref;
4977 }
4978 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
4979         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4980         CHECK(val->result_ok);
4981         LDKChannelAnnouncement res_var = (*val->contents.result);
4982         uint64_t res_ref = 0;
4983         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4984         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4985         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4986         res_ref = (uint64_t)res_var.inner & ~1;
4987         return res_ref;
4988 }
4989 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
4990         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
4991         CHECK(!val->result_ok);
4992         LDKDecodeError err_var = (*val->contents.err);
4993         uint64_t err_ref = 0;
4994         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4995         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4996         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4997         err_ref = (uint64_t)err_var.inner & ~1;
4998         return err_ref;
4999 }
5000 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
5001         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5002         CHECK(val->result_ok);
5003         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
5004         uint64_t res_ref = 0;
5005         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5006         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5007         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5008         res_ref = (uint64_t)res_var.inner & ~1;
5009         return res_ref;
5010 }
5011 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
5012         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5013         CHECK(!val->result_ok);
5014         LDKDecodeError err_var = (*val->contents.err);
5015         uint64_t err_ref = 0;
5016         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5017         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5018         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5019         err_ref = (uint64_t)err_var.inner & ~1;
5020         return err_ref;
5021 }
5022 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
5023         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5024         CHECK(val->result_ok);
5025         LDKChannelUpdate res_var = (*val->contents.result);
5026         uint64_t res_ref = 0;
5027         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5028         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5029         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5030         res_ref = (uint64_t)res_var.inner & ~1;
5031         return res_ref;
5032 }
5033 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
5034         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5035         CHECK(!val->result_ok);
5036         LDKDecodeError err_var = (*val->contents.err);
5037         uint64_t err_ref = 0;
5038         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5039         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5040         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5041         err_ref = (uint64_t)err_var.inner & ~1;
5042         return err_ref;
5043 }
5044 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
5045         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5046         CHECK(val->result_ok);
5047         LDKErrorMessage res_var = (*val->contents.result);
5048         uint64_t res_ref = 0;
5049         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5050         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5051         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5052         res_ref = (uint64_t)res_var.inner & ~1;
5053         return res_ref;
5054 }
5055 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
5056         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5057         CHECK(!val->result_ok);
5058         LDKDecodeError err_var = (*val->contents.err);
5059         uint64_t err_ref = 0;
5060         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5061         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5062         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5063         err_ref = (uint64_t)err_var.inner & ~1;
5064         return err_ref;
5065 }
5066 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5067         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5068         CHECK(val->result_ok);
5069         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
5070         uint64_t res_ref = 0;
5071         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5072         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5073         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5074         res_ref = (uint64_t)res_var.inner & ~1;
5075         return res_ref;
5076 }
5077 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5078         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5079         CHECK(!val->result_ok);
5080         LDKDecodeError err_var = (*val->contents.err);
5081         uint64_t err_ref = 0;
5082         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5083         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5084         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5085         err_ref = (uint64_t)err_var.inner & ~1;
5086         return err_ref;
5087 }
5088 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5089         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5090         CHECK(val->result_ok);
5091         LDKNodeAnnouncement res_var = (*val->contents.result);
5092         uint64_t res_ref = 0;
5093         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5094         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5095         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5096         res_ref = (uint64_t)res_var.inner & ~1;
5097         return res_ref;
5098 }
5099 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5100         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5101         CHECK(!val->result_ok);
5102         LDKDecodeError err_var = (*val->contents.err);
5103         uint64_t err_ref = 0;
5104         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5105         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5106         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5107         err_ref = (uint64_t)err_var.inner & ~1;
5108         return err_ref;
5109 }
5110 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
5111         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5112         CHECK(val->result_ok);
5113         LDKQueryShortChannelIds res_var = (*val->contents.result);
5114         uint64_t res_ref = 0;
5115         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5116         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5117         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5118         res_ref = (uint64_t)res_var.inner & ~1;
5119         return res_ref;
5120 }
5121 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
5122         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5123         CHECK(!val->result_ok);
5124         LDKDecodeError err_var = (*val->contents.err);
5125         uint64_t err_ref = 0;
5126         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5127         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5128         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5129         err_ref = (uint64_t)err_var.inner & ~1;
5130         return err_ref;
5131 }
5132 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
5133         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5134         CHECK(val->result_ok);
5135         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
5136         uint64_t res_ref = 0;
5137         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5138         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5139         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5140         res_ref = (uint64_t)res_var.inner & ~1;
5141         return res_ref;
5142 }
5143 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
5144         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5145         CHECK(!val->result_ok);
5146         LDKDecodeError err_var = (*val->contents.err);
5147         uint64_t err_ref = 0;
5148         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5149         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5150         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5151         err_ref = (uint64_t)err_var.inner & ~1;
5152         return err_ref;
5153 }
5154 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
5155         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5156         CHECK(val->result_ok);
5157         LDKQueryChannelRange res_var = (*val->contents.result);
5158         uint64_t res_ref = 0;
5159         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5160         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5161         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5162         res_ref = (uint64_t)res_var.inner & ~1;
5163         return res_ref;
5164 }
5165 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
5166         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5167         CHECK(!val->result_ok);
5168         LDKDecodeError err_var = (*val->contents.err);
5169         uint64_t err_ref = 0;
5170         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5171         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5172         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5173         err_ref = (uint64_t)err_var.inner & ~1;
5174         return err_ref;
5175 }
5176 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
5177         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5178         CHECK(val->result_ok);
5179         LDKReplyChannelRange res_var = (*val->contents.result);
5180         uint64_t res_ref = 0;
5181         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5182         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5183         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5184         res_ref = (uint64_t)res_var.inner & ~1;
5185         return res_ref;
5186 }
5187 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
5188         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5189         CHECK(!val->result_ok);
5190         LDKDecodeError err_var = (*val->contents.err);
5191         uint64_t err_ref = 0;
5192         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5193         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5194         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5195         err_ref = (uint64_t)err_var.inner & ~1;
5196         return err_ref;
5197 }
5198 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
5199         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5200         CHECK(val->result_ok);
5201         LDKGossipTimestampFilter res_var = (*val->contents.result);
5202         uint64_t res_ref = 0;
5203         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5204         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5205         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5206         res_ref = (uint64_t)res_var.inner & ~1;
5207         return res_ref;
5208 }
5209 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
5210         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5211         CHECK(!val->result_ok);
5212         LDKDecodeError err_var = (*val->contents.err);
5213         uint64_t err_ref = 0;
5214         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5215         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5216         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5217         err_ref = (uint64_t)err_var.inner & ~1;
5218         return err_ref;
5219 }
5220 uint32_t __attribute__((visibility("default"))) TS_LDKSignOrCreationError_ref_from_ptr(uint32_t ptr) {
5221         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
5222         switch(obj->tag) {
5223                 case LDKSignOrCreationError_SignError: {
5224                         return 0 /* LDKSignOrCreationError - SignError */;
5225                 }
5226                 case LDKSignOrCreationError_CreationError: {
5227                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
5228                         return 0 /* LDKSignOrCreationError - CreationError */; (void) creation_error_conv;
5229                 }
5230                 default: abort();
5231         }
5232 }
5233 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t arg) {
5234         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5235         CHECK(val->result_ok);
5236         LDKInvoice res_var = (*val->contents.result);
5237         uint64_t res_ref = 0;
5238         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5239         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5240         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5241         res_ref = (uint64_t)res_var.inner & ~1;
5242         return res_ref;
5243 }
5244 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t arg) {
5245         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5246         CHECK(!val->result_ok);
5247         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
5248         return err_ref;
5249 }
5250 typedef struct LDKFilter_JCalls {
5251         atomic_size_t refcnt;
5252         uint32_t register_tx_meth;
5253         uint32_t register_output_meth;
5254 } LDKFilter_JCalls;
5255 static void LDKFilter_JCalls_free(void* this_arg) {
5256         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5257         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5258                 js_free(j_calls->register_tx_meth);
5259                 js_free(j_calls->register_output_meth);
5260                 FREE(j_calls);
5261         }
5262 }
5263 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5264         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5265         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5266         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5267         LDKu8slice script_pubkey_var = script_pubkey;
5268         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5269         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
5270         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
5271 }
5272 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5273         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5274         LDKWatchedOutput output_var = output;
5275         uint64_t output_ref = 0;
5276         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5277         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5278         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
5279         output_ref = (uint64_t)output_var.inner;
5280         if (output_var.is_owned) {
5281                 output_ref |= 1;
5282         }
5283         uint32_t ret = js_invoke_function_1(j_calls->register_output_meth, output_ref);
5284         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
5285         CHECK_ACCESS(ret_ptr);
5286         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
5287         FREE((void*)ret);
5288         return ret_conv;
5289 }
5290 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
5291         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
5292         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5293 }
5294 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
5295         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5296         atomic_init(&calls->refcnt, 1);
5297         //TODO: Assign calls->o from o
5298
5299         LDKFilter ret = {
5300                 .this_arg = (void*) calls,
5301                 .register_tx = register_tx_LDKFilter_jcall,
5302                 .register_output = register_output_LDKFilter_jcall,
5303                 .free = LDKFilter_JCalls_free,
5304         };
5305         return ret;
5306 }
5307 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
5308         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5309         *res_ptr = LDKFilter_init(o);
5310         return (long)res_ptr;
5311 }
5312 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
5313         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5314         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5315         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
5316         unsigned char txid_arr[32];
5317         CHECK(*((uint32_t*)txid) == 32);
5318         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5319         unsigned char (*txid_ref)[32] = &txid_arr;
5320         LDKu8slice script_pubkey_ref;
5321         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
5322         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
5323         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5324 }
5325
5326 uint32_t  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
5327         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5328         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5329         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
5330         LDKWatchedOutput output_conv;
5331         output_conv.inner = (void*)(output & (~1));
5332         output_conv.is_owned = (output & 1) || (output == 0);
5333         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
5334         output_conv = WatchedOutput_clone(&output_conv);
5335         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5336         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5337         uint64_t ret_ref = (uint64_t)ret_copy;
5338         return ret_ref;
5339 }
5340
5341 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_FilterZ_ref_from_ptr(uint32_t ptr) {
5342         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
5343         switch(obj->tag) {
5344                 case LDKCOption_FilterZ_Some: {
5345                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
5346                         *some_ret = obj->some;
5347                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
5348                         return 0 /* LDKCOption_FilterZ - Some */; (void) (uint64_t)some_ret;
5349                 }
5350                 case LDKCOption_FilterZ_None: {
5351                         return 0 /* LDKCOption_FilterZ - None */;
5352                 }
5353                 default: abort();
5354         }
5355 }
5356 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_get_ok(uint32_t arg) {
5357         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
5358         CHECK(val->result_ok);
5359         LDKLockedChannelMonitor res_var = (*val->contents.result);
5360         uint64_t res_ref = 0;
5361         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5362         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5363         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5364         res_ref = (uint64_t)res_var.inner & ~1;
5365         return res_ref;
5366 }
5367 void  __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_get_err(uint32_t arg) {
5368         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
5369         CHECK(!val->result_ok);
5370         return *val->contents.err;
5371 }
5372 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
5373         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
5374         for (size_t i = 0; i < ret.datalen; i++) {
5375                 ret.data[i] = OutPoint_clone(&orig->data[i]);
5376         }
5377         return ret;
5378 }
5379 typedef struct LDKMessageSendEventsProvider_JCalls {
5380         atomic_size_t refcnt;
5381         uint32_t get_and_clear_pending_msg_events_meth;
5382 } LDKMessageSendEventsProvider_JCalls;
5383 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
5384         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5385         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5386                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
5387                 FREE(j_calls);
5388         }
5389 }
5390 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
5391         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5392         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
5393         LDKCVec_MessageSendEventZ ret_constr;
5394         ret_constr.datalen = *((uint32_t*)ret);
5395         if (ret_constr.datalen > 0)
5396                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
5397         else
5398                 ret_constr.data = NULL;
5399         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5400         for (size_t s = 0; s < ret_constr.datalen; s++) {
5401                 uint32_t ret_conv_18 = ret_vals[s];
5402                 void* ret_conv_18_ptr = (void*)(((uint64_t)ret_conv_18) & ~1);
5403                 CHECK_ACCESS(ret_conv_18_ptr);
5404                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
5405                 FREE((void*)ret_conv_18);
5406                 ret_constr.data[s] = ret_conv_18_conv;
5407         }
5408         return ret_constr;
5409 }
5410 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
5411         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
5412         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5413 }
5414 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
5415         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
5416         atomic_init(&calls->refcnt, 1);
5417         //TODO: Assign calls->o from o
5418
5419         LDKMessageSendEventsProvider ret = {
5420                 .this_arg = (void*) calls,
5421                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
5422                 .free = LDKMessageSendEventsProvider_JCalls_free,
5423         };
5424         return ret;
5425 }
5426 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
5427         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
5428         *res_ptr = LDKMessageSendEventsProvider_init(o);
5429         return (long)res_ptr;
5430 }
5431 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
5432         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5433         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5434         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
5435         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
5436         uint32_tArray ret_arr = NULL;
5437         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5438         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
5439         for (size_t s = 0; s < ret_var.datalen; s++) {
5440                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
5441                 *ret_conv_18_copy = ret_var.data[s];
5442                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
5443                 ret_arr_ptr[s] = ret_conv_18_ref;
5444         }
5445         
5446         FREE(ret_var.data);
5447         return ret_arr;
5448 }
5449
5450 typedef struct LDKEventHandler_JCalls {
5451         atomic_size_t refcnt;
5452         uint32_t handle_event_meth;
5453 } LDKEventHandler_JCalls;
5454 static void LDKEventHandler_JCalls_free(void* this_arg) {
5455         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
5456         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5457                 js_free(j_calls->handle_event_meth);
5458                 FREE(j_calls);
5459         }
5460 }
5461 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
5462         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
5463         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
5464         *ret_event = Event_clone(event);
5465         js_invoke_function_1(j_calls->handle_event_meth, (uint64_t)ret_event);
5466 }
5467 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
5468         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
5469         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5470 }
5471 static inline LDKEventHandler LDKEventHandler_init (/*TODO: JS Object Reference */void* o) {
5472         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
5473         atomic_init(&calls->refcnt, 1);
5474         //TODO: Assign calls->o from o
5475
5476         LDKEventHandler ret = {
5477                 .this_arg = (void*) calls,
5478                 .handle_event = handle_event_LDKEventHandler_jcall,
5479                 .free = LDKEventHandler_JCalls_free,
5480         };
5481         return ret;
5482 }
5483 long  __attribute__((visibility("default"))) TS_LDKEventHandler_new(/*TODO: JS Object Reference */void* o) {
5484         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
5485         *res_ptr = LDKEventHandler_init(o);
5486         return (long)res_ptr;
5487 }
5488 void  __attribute__((visibility("default"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
5489         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5490         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5491         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
5492         LDKEvent* event_conv = (LDKEvent*)event;
5493         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
5494 }
5495
5496 typedef struct LDKEventsProvider_JCalls {
5497         atomic_size_t refcnt;
5498         uint32_t process_pending_events_meth;
5499 } LDKEventsProvider_JCalls;
5500 static void LDKEventsProvider_JCalls_free(void* this_arg) {
5501         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
5502         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5503                 js_free(j_calls->process_pending_events_meth);
5504                 FREE(j_calls);
5505         }
5506 }
5507 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
5508         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
5509         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
5510         *handler_ret = handler;
5511         js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)handler_ret);
5512 }
5513 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
5514         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
5515         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5516 }
5517 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
5518         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
5519         atomic_init(&calls->refcnt, 1);
5520         //TODO: Assign calls->o from o
5521
5522         LDKEventsProvider ret = {
5523                 .this_arg = (void*) calls,
5524                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
5525                 .free = LDKEventsProvider_JCalls_free,
5526         };
5527         return ret;
5528 }
5529 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
5530         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
5531         *res_ptr = LDKEventsProvider_init(o);
5532         return (long)res_ptr;
5533 }
5534 void  __attribute__((visibility("default"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
5535         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5536         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5537         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
5538         void* handler_ptr = (void*)(((uint64_t)handler) & ~1);
5539         CHECK_ACCESS(handler_ptr);
5540         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
5541         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
5542 }
5543
5544 typedef struct LDKListen_JCalls {
5545         atomic_size_t refcnt;
5546         uint32_t block_connected_meth;
5547         uint32_t block_disconnected_meth;
5548 } LDKListen_JCalls;
5549 static void LDKListen_JCalls_free(void* this_arg) {
5550         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5551         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5552                 js_free(j_calls->block_connected_meth);
5553                 js_free(j_calls->block_disconnected_meth);
5554                 FREE(j_calls);
5555         }
5556 }
5557 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
5558         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5559         LDKu8slice block_var = block;
5560         int8_tArray block_arr = init_arr(block_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5561         memcpy((uint8_t*)(block_arr + 4), block_var.data, block_var.datalen);
5562         js_invoke_function_2(j_calls->block_connected_meth, block_arr, height);
5563 }
5564 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
5565         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5566         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5567         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5568         js_invoke_function_2(j_calls->block_disconnected_meth, header_arr, height);
5569 }
5570 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
5571         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
5572         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5573 }
5574 static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) {
5575         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
5576         atomic_init(&calls->refcnt, 1);
5577         //TODO: Assign calls->o from o
5578
5579         LDKListen ret = {
5580                 .this_arg = (void*) calls,
5581                 .block_connected = block_connected_LDKListen_jcall,
5582                 .block_disconnected = block_disconnected_LDKListen_jcall,
5583                 .free = LDKListen_JCalls_free,
5584         };
5585         return ret;
5586 }
5587 long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object Reference */void* o) {
5588         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
5589         *res_ptr = LDKListen_init(o);
5590         return (long)res_ptr;
5591 }
5592 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
5593         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5594         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5595         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
5596         LDKu8slice block_ref;
5597         block_ref.datalen = *((uint32_t*)block);
5598         block_ref.data = (int8_t*)(block + 4);
5599         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
5600 }
5601
5602 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
5603         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5604         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5605         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
5606         unsigned char header_arr[80];
5607         CHECK(*((uint32_t*)header) == 80);
5608         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5609         unsigned char (*header_ref)[80] = &header_arr;
5610         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
5611 }
5612
5613 typedef struct LDKConfirm_JCalls {
5614         atomic_size_t refcnt;
5615         uint32_t transactions_confirmed_meth;
5616         uint32_t transaction_unconfirmed_meth;
5617         uint32_t best_block_updated_meth;
5618         uint32_t get_relevant_txids_meth;
5619 } LDKConfirm_JCalls;
5620 static void LDKConfirm_JCalls_free(void* this_arg) {
5621         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5622         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5623                 js_free(j_calls->transactions_confirmed_meth);
5624                 js_free(j_calls->transaction_unconfirmed_meth);
5625                 js_free(j_calls->best_block_updated_meth);
5626                 js_free(j_calls->get_relevant_txids_meth);
5627                 FREE(j_calls);
5628         }
5629 }
5630 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
5631         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5632         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5633         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5634         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
5635         uint32_tArray txdata_arr = NULL;
5636         txdata_arr = init_arr(txdata_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5637         uint32_t *txdata_arr_ptr = (uint32_t*)(txdata_arr + 4);
5638         for (size_t c = 0; c < txdata_var.datalen; c++) {
5639                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
5640                 *txdata_conv_28_conv = txdata_var.data[c];
5641                 txdata_arr_ptr[c] = ((uint64_t)txdata_conv_28_conv);
5642         }
5643         
5644         FREE(txdata_var.data);
5645         js_invoke_function_3(j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
5646 }
5647 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
5648         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5649         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5650         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5651         js_invoke_function_1(j_calls->transaction_unconfirmed_meth, txid_arr);
5652 }
5653 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
5654         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5655         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5656         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5657         js_invoke_function_2(j_calls->best_block_updated_meth, header_arr, height);
5658 }
5659 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
5660         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5661         ptrArray ret = js_invoke_function_0(j_calls->get_relevant_txids_meth);
5662         LDKCVec_TxidZ ret_constr;
5663         ret_constr.datalen = *((uint32_t*)ret);
5664         if (ret_constr.datalen > 0)
5665                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
5666         else
5667                 ret_constr.data = NULL;
5668         int8_tArray* ret_vals = (int8_tArray*)(ret + 4);
5669         for (size_t m = 0; m < ret_constr.datalen; m++) {
5670                 int8_tArray ret_conv_12 = ret_vals[m];
5671                 LDKThirtyTwoBytes ret_conv_12_ref;
5672                 CHECK(*((uint32_t*)ret_conv_12) == 32);
5673                 memcpy(ret_conv_12_ref.data, (uint8_t*)(ret_conv_12 + 4), 32);
5674                 ret_constr.data[m] = ret_conv_12_ref;
5675         }
5676         return ret_constr;
5677 }
5678 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
5679         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
5680         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5681 }
5682 static inline LDKConfirm LDKConfirm_init (/*TODO: JS Object Reference */void* o) {
5683         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
5684         atomic_init(&calls->refcnt, 1);
5685         //TODO: Assign calls->o from o
5686
5687         LDKConfirm ret = {
5688                 .this_arg = (void*) calls,
5689                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
5690                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
5691                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
5692                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
5693                 .free = LDKConfirm_JCalls_free,
5694         };
5695         return ret;
5696 }
5697 long  __attribute__((visibility("default"))) TS_LDKConfirm_new(/*TODO: JS Object Reference */void* o) {
5698         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
5699         *res_ptr = LDKConfirm_init(o);
5700         return (long)res_ptr;
5701 }
5702 void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
5703         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5704         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5705         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
5706         unsigned char header_arr[80];
5707         CHECK(*((uint32_t*)header) == 80);
5708         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5709         unsigned char (*header_ref)[80] = &header_arr;
5710         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
5711         txdata_constr.datalen = *((uint32_t*)txdata);
5712         if (txdata_constr.datalen > 0)
5713                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
5714         else
5715                 txdata_constr.data = NULL;
5716         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
5717         for (size_t c = 0; c < txdata_constr.datalen; c++) {
5718                 uint32_t txdata_conv_28 = txdata_vals[c];
5719                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
5720                 CHECK_ACCESS(txdata_conv_28_ptr);
5721                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
5722                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
5723                 txdata_constr.data[c] = txdata_conv_28_conv;
5724         }
5725         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
5726 }
5727
5728 void  __attribute__((visibility("default"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
5729         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5730         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5731         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
5732         unsigned char txid_arr[32];
5733         CHECK(*((uint32_t*)txid) == 32);
5734         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5735         unsigned char (*txid_ref)[32] = &txid_arr;
5736         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
5737 }
5738
5739 void  __attribute__((visibility("default"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
5740         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5741         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5742         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
5743         unsigned char header_arr[80];
5744         CHECK(*((uint32_t*)header) == 80);
5745         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5746         unsigned char (*header_ref)[80] = &header_arr;
5747         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
5748 }
5749
5750 ptrArray  __attribute__((visibility("default"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
5751         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5752         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5753         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
5754         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
5755         ptrArray ret_arr = NULL;
5756         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
5757         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
5758         for (size_t m = 0; m < ret_var.datalen; m++) {
5759                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5760                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
5761                 ret_arr_ptr[m] = ret_conv_12_arr;
5762         }
5763         
5764         FREE(ret_var.data);
5765         return ret_arr;
5766 }
5767
5768 typedef struct LDKPersist_JCalls {
5769         atomic_size_t refcnt;
5770         uint32_t persist_new_channel_meth;
5771         uint32_t update_persisted_channel_meth;
5772 } LDKPersist_JCalls;
5773 static void LDKPersist_JCalls_free(void* this_arg) {
5774         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5775         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5776                 js_free(j_calls->persist_new_channel_meth);
5777                 js_free(j_calls->update_persisted_channel_meth);
5778                 FREE(j_calls);
5779         }
5780 }
5781 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
5782         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5783         LDKOutPoint channel_id_var = channel_id;
5784         uint64_t channel_id_ref = 0;
5785         CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5786         CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5787         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
5788         channel_id_ref = (uint64_t)channel_id_var.inner;
5789         if (channel_id_var.is_owned) {
5790                 channel_id_ref |= 1;
5791         }
5792         LDKChannelMonitor data_var = *data;
5793         uint64_t data_ref = 0;
5794         data_var = ChannelMonitor_clone(data);
5795         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5796         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5797         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
5798         data_ref = (uint64_t)data_var.inner;
5799         if (data_var.is_owned) {
5800                 data_ref |= 1;
5801         }
5802         LDKMonitorUpdateId update_id_var = update_id;
5803         uint64_t update_id_ref = 0;
5804         CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5805         CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5806         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
5807         update_id_ref = (uint64_t)update_id_var.inner;
5808         if (update_id_var.is_owned) {
5809                 update_id_ref |= 1;
5810         }
5811         uint32_t ret = js_invoke_function_3(j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
5812         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
5813         CHECK_ACCESS(ret_ptr);
5814         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5815         FREE((void*)ret);
5816         return ret_conv;
5817 }
5818 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
5819         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5820         LDKOutPoint channel_id_var = channel_id;
5821         uint64_t channel_id_ref = 0;
5822         CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5823         CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5824         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
5825         channel_id_ref = (uint64_t)channel_id_var.inner;
5826         if (channel_id_var.is_owned) {
5827                 channel_id_ref |= 1;
5828         }
5829         LDKChannelMonitorUpdate update_var = *update;
5830         uint64_t update_ref = 0;
5831         if ((uint64_t)update_var.inner > 4096) {
5832                 update_var = ChannelMonitorUpdate_clone(update);
5833                 CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5834                 CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5835         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5836                 update_ref = (uint64_t)update_var.inner;
5837                 if (update_var.is_owned) {
5838                         update_ref |= 1;
5839                 }
5840         }
5841         LDKChannelMonitor data_var = *data;
5842         uint64_t data_ref = 0;
5843         data_var = ChannelMonitor_clone(data);
5844         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5845         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5846         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
5847         data_ref = (uint64_t)data_var.inner;
5848         if (data_var.is_owned) {
5849                 data_ref |= 1;
5850         }
5851         LDKMonitorUpdateId update_id_var = update_id;
5852         uint64_t update_id_ref = 0;
5853         CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5854         CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5855         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
5856         update_id_ref = (uint64_t)update_id_var.inner;
5857         if (update_id_var.is_owned) {
5858                 update_id_ref |= 1;
5859         }
5860         uint32_t ret = js_invoke_function_4(j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
5861         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
5862         CHECK_ACCESS(ret_ptr);
5863         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5864         FREE((void*)ret);
5865         return ret_conv;
5866 }
5867 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
5868         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
5869         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5870 }
5871 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
5872         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
5873         atomic_init(&calls->refcnt, 1);
5874         //TODO: Assign calls->o from o
5875
5876         LDKPersist ret = {
5877                 .this_arg = (void*) calls,
5878                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
5879                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
5880                 .free = LDKPersist_JCalls_free,
5881         };
5882         return ret;
5883 }
5884 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
5885         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
5886         *res_ptr = LDKPersist_init(o);
5887         return (long)res_ptr;
5888 }
5889 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t channel_id, uint32_t data, uint32_t update_id) {
5890         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5891         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5892         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
5893         LDKOutPoint channel_id_conv;
5894         channel_id_conv.inner = (void*)(channel_id & (~1));
5895         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
5896         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
5897         channel_id_conv = OutPoint_clone(&channel_id_conv);
5898         LDKChannelMonitor data_conv;
5899         data_conv.inner = (void*)(data & (~1));
5900         data_conv.is_owned = false;
5901         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
5902         LDKMonitorUpdateId update_id_conv;
5903         update_id_conv.inner = (void*)(update_id & (~1));
5904         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
5905         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
5906         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
5907         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5908         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
5909         return (uint64_t)ret_conv;
5910 }
5911
5912 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t channel_id, uint32_t update, uint32_t data, uint32_t update_id) {
5913         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5914         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5915         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
5916         LDKOutPoint channel_id_conv;
5917         channel_id_conv.inner = (void*)(channel_id & (~1));
5918         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
5919         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
5920         channel_id_conv = OutPoint_clone(&channel_id_conv);
5921         LDKChannelMonitorUpdate update_conv;
5922         update_conv.inner = (void*)(update & (~1));
5923         update_conv.is_owned = false;
5924         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
5925         LDKChannelMonitor data_conv;
5926         data_conv.inner = (void*)(data & (~1));
5927         data_conv.is_owned = false;
5928         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
5929         LDKMonitorUpdateId update_id_conv;
5930         update_id_conv.inner = (void*)(update_id & (~1));
5931         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
5932         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
5933         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
5934         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5935         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
5936         return (uint64_t)ret_conv;
5937 }
5938
5939 typedef struct LDKChannelMessageHandler_JCalls {
5940         atomic_size_t refcnt;
5941         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5942         uint32_t handle_open_channel_meth;
5943         uint32_t handle_accept_channel_meth;
5944         uint32_t handle_funding_created_meth;
5945         uint32_t handle_funding_signed_meth;
5946         uint32_t handle_funding_locked_meth;
5947         uint32_t handle_shutdown_meth;
5948         uint32_t handle_closing_signed_meth;
5949         uint32_t handle_update_add_htlc_meth;
5950         uint32_t handle_update_fulfill_htlc_meth;
5951         uint32_t handle_update_fail_htlc_meth;
5952         uint32_t handle_update_fail_malformed_htlc_meth;
5953         uint32_t handle_commitment_signed_meth;
5954         uint32_t handle_revoke_and_ack_meth;
5955         uint32_t handle_update_fee_meth;
5956         uint32_t handle_announcement_signatures_meth;
5957         uint32_t peer_disconnected_meth;
5958         uint32_t peer_connected_meth;
5959         uint32_t handle_channel_reestablish_meth;
5960         uint32_t handle_channel_update_meth;
5961         uint32_t handle_error_meth;
5962 } LDKChannelMessageHandler_JCalls;
5963 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
5964         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5965         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5966                 js_free(j_calls->handle_open_channel_meth);
5967                 js_free(j_calls->handle_accept_channel_meth);
5968                 js_free(j_calls->handle_funding_created_meth);
5969                 js_free(j_calls->handle_funding_signed_meth);
5970                 js_free(j_calls->handle_funding_locked_meth);
5971                 js_free(j_calls->handle_shutdown_meth);
5972                 js_free(j_calls->handle_closing_signed_meth);
5973                 js_free(j_calls->handle_update_add_htlc_meth);
5974                 js_free(j_calls->handle_update_fulfill_htlc_meth);
5975                 js_free(j_calls->handle_update_fail_htlc_meth);
5976                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
5977                 js_free(j_calls->handle_commitment_signed_meth);
5978                 js_free(j_calls->handle_revoke_and_ack_meth);
5979                 js_free(j_calls->handle_update_fee_meth);
5980                 js_free(j_calls->handle_announcement_signatures_meth);
5981                 js_free(j_calls->peer_disconnected_meth);
5982                 js_free(j_calls->peer_connected_meth);
5983                 js_free(j_calls->handle_channel_reestablish_meth);
5984                 js_free(j_calls->handle_channel_update_meth);
5985                 js_free(j_calls->handle_error_meth);
5986                 FREE(j_calls);
5987         }
5988 }
5989 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
5990         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5991         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5992         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5993         LDKInitFeatures their_features_var = their_features;
5994         uint64_t their_features_ref = 0;
5995         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5996         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5997         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
5998         their_features_ref = (uint64_t)their_features_var.inner;
5999         if (their_features_var.is_owned) {
6000                 their_features_ref |= 1;
6001         }
6002         LDKOpenChannel msg_var = *msg;
6003         uint64_t msg_ref = 0;
6004         msg_var = OpenChannel_clone(msg);
6005         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6006         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6007         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6008         msg_ref = (uint64_t)msg_var.inner;
6009         if (msg_var.is_owned) {
6010                 msg_ref |= 1;
6011         }
6012         js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
6013 }
6014 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
6015         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6016         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6017         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6018         LDKInitFeatures their_features_var = their_features;
6019         uint64_t their_features_ref = 0;
6020         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6021         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6022         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
6023         their_features_ref = (uint64_t)their_features_var.inner;
6024         if (their_features_var.is_owned) {
6025                 their_features_ref |= 1;
6026         }
6027         LDKAcceptChannel msg_var = *msg;
6028         uint64_t msg_ref = 0;
6029         msg_var = AcceptChannel_clone(msg);
6030         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6031         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6032         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6033         msg_ref = (uint64_t)msg_var.inner;
6034         if (msg_var.is_owned) {
6035                 msg_ref |= 1;
6036         }
6037         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
6038 }
6039 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
6040         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6041         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6042         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6043         LDKFundingCreated msg_var = *msg;
6044         uint64_t msg_ref = 0;
6045         msg_var = FundingCreated_clone(msg);
6046         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6047         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6048         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6049         msg_ref = (uint64_t)msg_var.inner;
6050         if (msg_var.is_owned) {
6051                 msg_ref |= 1;
6052         }
6053         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
6054 }
6055 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
6056         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6057         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6058         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6059         LDKFundingSigned msg_var = *msg;
6060         uint64_t msg_ref = 0;
6061         msg_var = FundingSigned_clone(msg);
6062         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6063         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6064         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6065         msg_ref = (uint64_t)msg_var.inner;
6066         if (msg_var.is_owned) {
6067                 msg_ref |= 1;
6068         }
6069         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
6070 }
6071 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
6072         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6073         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6074         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6075         LDKFundingLocked msg_var = *msg;
6076         uint64_t msg_ref = 0;
6077         msg_var = FundingLocked_clone(msg);
6078         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6079         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6080         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6081         msg_ref = (uint64_t)msg_var.inner;
6082         if (msg_var.is_owned) {
6083                 msg_ref |= 1;
6084         }
6085         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
6086 }
6087 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
6088         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6089         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6090         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6091         LDKInitFeatures their_features_var = *their_features;
6092         uint64_t their_features_ref = 0;
6093         their_features_var = InitFeatures_clone(their_features);
6094         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6095         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6096         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
6097         their_features_ref = (uint64_t)their_features_var.inner;
6098         if (their_features_var.is_owned) {
6099                 their_features_ref |= 1;
6100         }
6101         LDKShutdown msg_var = *msg;
6102         uint64_t msg_ref = 0;
6103         msg_var = Shutdown_clone(msg);
6104         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6105         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6106         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6107         msg_ref = (uint64_t)msg_var.inner;
6108         if (msg_var.is_owned) {
6109                 msg_ref |= 1;
6110         }
6111         js_invoke_function_3(j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
6112 }
6113 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
6114         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6115         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6116         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6117         LDKClosingSigned msg_var = *msg;
6118         uint64_t msg_ref = 0;
6119         msg_var = ClosingSigned_clone(msg);
6120         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6121         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6122         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6123         msg_ref = (uint64_t)msg_var.inner;
6124         if (msg_var.is_owned) {
6125                 msg_ref |= 1;
6126         }
6127         js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
6128 }
6129 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
6130         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6131         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6132         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6133         LDKUpdateAddHTLC msg_var = *msg;
6134         uint64_t msg_ref = 0;
6135         msg_var = UpdateAddHTLC_clone(msg);
6136         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6137         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6138         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6139         msg_ref = (uint64_t)msg_var.inner;
6140         if (msg_var.is_owned) {
6141                 msg_ref |= 1;
6142         }
6143         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
6144 }
6145 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
6146         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6147         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6148         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6149         LDKUpdateFulfillHTLC msg_var = *msg;
6150         uint64_t msg_ref = 0;
6151         msg_var = UpdateFulfillHTLC_clone(msg);
6152         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6153         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6154         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6155         msg_ref = (uint64_t)msg_var.inner;
6156         if (msg_var.is_owned) {
6157                 msg_ref |= 1;
6158         }
6159         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
6160 }
6161 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
6162         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6163         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6164         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6165         LDKUpdateFailHTLC msg_var = *msg;
6166         uint64_t msg_ref = 0;
6167         msg_var = UpdateFailHTLC_clone(msg);
6168         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6169         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6170         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6171         msg_ref = (uint64_t)msg_var.inner;
6172         if (msg_var.is_owned) {
6173                 msg_ref |= 1;
6174         }
6175         js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
6176 }
6177 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
6178         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6179         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6180         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6181         LDKUpdateFailMalformedHTLC msg_var = *msg;
6182         uint64_t msg_ref = 0;
6183         msg_var = UpdateFailMalformedHTLC_clone(msg);
6184         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6185         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6186         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6187         msg_ref = (uint64_t)msg_var.inner;
6188         if (msg_var.is_owned) {
6189                 msg_ref |= 1;
6190         }
6191         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
6192 }
6193 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
6194         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6195         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6196         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6197         LDKCommitmentSigned msg_var = *msg;
6198         uint64_t msg_ref = 0;
6199         msg_var = CommitmentSigned_clone(msg);
6200         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6201         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6202         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6203         msg_ref = (uint64_t)msg_var.inner;
6204         if (msg_var.is_owned) {
6205                 msg_ref |= 1;
6206         }
6207         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
6208 }
6209 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
6210         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6211         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6212         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6213         LDKRevokeAndACK msg_var = *msg;
6214         uint64_t msg_ref = 0;
6215         msg_var = RevokeAndACK_clone(msg);
6216         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6217         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6218         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6219         msg_ref = (uint64_t)msg_var.inner;
6220         if (msg_var.is_owned) {
6221                 msg_ref |= 1;
6222         }
6223         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
6224 }
6225 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
6226         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6227         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6228         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6229         LDKUpdateFee msg_var = *msg;
6230         uint64_t msg_ref = 0;
6231         msg_var = UpdateFee_clone(msg);
6232         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6233         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6234         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6235         msg_ref = (uint64_t)msg_var.inner;
6236         if (msg_var.is_owned) {
6237                 msg_ref |= 1;
6238         }
6239         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
6240 }
6241 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
6242         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6243         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6244         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6245         LDKAnnouncementSignatures msg_var = *msg;
6246         uint64_t msg_ref = 0;
6247         msg_var = AnnouncementSignatures_clone(msg);
6248         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6249         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6250         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6251         msg_ref = (uint64_t)msg_var.inner;
6252         if (msg_var.is_owned) {
6253                 msg_ref |= 1;
6254         }
6255         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
6256 }
6257 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
6258         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6259         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6260         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6261         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
6262 }
6263 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
6264         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6265         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6266         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6267         LDKInit msg_var = *msg;
6268         uint64_t msg_ref = 0;
6269         msg_var = Init_clone(msg);
6270         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6271         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6272         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6273         msg_ref = (uint64_t)msg_var.inner;
6274         if (msg_var.is_owned) {
6275                 msg_ref |= 1;
6276         }
6277         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
6278 }
6279 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
6280         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6281         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6282         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6283         LDKChannelReestablish msg_var = *msg;
6284         uint64_t msg_ref = 0;
6285         msg_var = ChannelReestablish_clone(msg);
6286         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6287         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6288         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6289         msg_ref = (uint64_t)msg_var.inner;
6290         if (msg_var.is_owned) {
6291                 msg_ref |= 1;
6292         }
6293         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
6294 }
6295 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
6296         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6297         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6298         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6299         LDKChannelUpdate msg_var = *msg;
6300         uint64_t msg_ref = 0;
6301         msg_var = ChannelUpdate_clone(msg);
6302         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6303         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6304         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6305         msg_ref = (uint64_t)msg_var.inner;
6306         if (msg_var.is_owned) {
6307                 msg_ref |= 1;
6308         }
6309         js_invoke_function_2(j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
6310 }
6311 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
6312         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6313         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6314         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6315         LDKErrorMessage msg_var = *msg;
6316         uint64_t msg_ref = 0;
6317         msg_var = ErrorMessage_clone(msg);
6318         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6319         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6320         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6321         msg_ref = (uint64_t)msg_var.inner;
6322         if (msg_var.is_owned) {
6323                 msg_ref |= 1;
6324         }
6325         js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
6326 }
6327 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
6328         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
6329         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6330         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6331 }
6332 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
6333         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
6334         atomic_init(&calls->refcnt, 1);
6335         //TODO: Assign calls->o from o
6336
6337         LDKChannelMessageHandler ret = {
6338                 .this_arg = (void*) calls,
6339                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
6340                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
6341                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
6342                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
6343                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
6344                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
6345                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
6346                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
6347                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
6348                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
6349                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
6350                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
6351                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
6352                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
6353                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
6354                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
6355                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
6356                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
6357                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
6358                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
6359                 .free = LDKChannelMessageHandler_JCalls_free,
6360                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
6361         };
6362         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6363         return ret;
6364 }
6365 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
6366         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
6367         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
6368         return (long)res_ptr;
6369 }
6370 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_open_channel(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
6371         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6372         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6373         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6374         LDKPublicKey their_node_id_ref;
6375         CHECK(*((uint32_t*)their_node_id) == 33);
6376         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6377         LDKInitFeatures their_features_conv;
6378         their_features_conv.inner = (void*)(their_features & (~1));
6379         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
6380         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
6381         their_features_conv = InitFeatures_clone(&their_features_conv);
6382         LDKOpenChannel msg_conv;
6383         msg_conv.inner = (void*)(msg & (~1));
6384         msg_conv.is_owned = false;
6385         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6386         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
6387 }
6388
6389 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_accept_channel(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
6390         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6391         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6392         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6393         LDKPublicKey their_node_id_ref;
6394         CHECK(*((uint32_t*)their_node_id) == 33);
6395         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6396         LDKInitFeatures their_features_conv;
6397         their_features_conv.inner = (void*)(their_features & (~1));
6398         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
6399         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
6400         their_features_conv = InitFeatures_clone(&their_features_conv);
6401         LDKAcceptChannel msg_conv;
6402         msg_conv.inner = (void*)(msg & (~1));
6403         msg_conv.is_owned = false;
6404         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6405         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
6406 }
6407
6408 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6409         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6410         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6411         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6412         LDKPublicKey their_node_id_ref;
6413         CHECK(*((uint32_t*)their_node_id) == 33);
6414         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6415         LDKFundingCreated msg_conv;
6416         msg_conv.inner = (void*)(msg & (~1));
6417         msg_conv.is_owned = false;
6418         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6419         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6420 }
6421
6422 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6423         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6424         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6425         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6426         LDKPublicKey their_node_id_ref;
6427         CHECK(*((uint32_t*)their_node_id) == 33);
6428         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6429         LDKFundingSigned msg_conv;
6430         msg_conv.inner = (void*)(msg & (~1));
6431         msg_conv.is_owned = false;
6432         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6433         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6434 }
6435
6436 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6437         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6438         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6439         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6440         LDKPublicKey their_node_id_ref;
6441         CHECK(*((uint32_t*)their_node_id) == 33);
6442         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6443         LDKFundingLocked msg_conv;
6444         msg_conv.inner = (void*)(msg & (~1));
6445         msg_conv.is_owned = false;
6446         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6447         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6448 }
6449
6450 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
6451         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6452         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6453         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6454         LDKPublicKey their_node_id_ref;
6455         CHECK(*((uint32_t*)their_node_id) == 33);
6456         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6457         LDKInitFeatures their_features_conv;
6458         their_features_conv.inner = (void*)(their_features & (~1));
6459         their_features_conv.is_owned = false;
6460         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
6461         LDKShutdown msg_conv;
6462         msg_conv.inner = (void*)(msg & (~1));
6463         msg_conv.is_owned = false;
6464         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6465         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
6466 }
6467
6468 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6469         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6470         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6471         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6472         LDKPublicKey their_node_id_ref;
6473         CHECK(*((uint32_t*)their_node_id) == 33);
6474         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6475         LDKClosingSigned msg_conv;
6476         msg_conv.inner = (void*)(msg & (~1));
6477         msg_conv.is_owned = false;
6478         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6479         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6480 }
6481
6482 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6483         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6484         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6485         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6486         LDKPublicKey their_node_id_ref;
6487         CHECK(*((uint32_t*)their_node_id) == 33);
6488         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6489         LDKUpdateAddHTLC msg_conv;
6490         msg_conv.inner = (void*)(msg & (~1));
6491         msg_conv.is_owned = false;
6492         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6493         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6494 }
6495
6496 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6497         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6498         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6499         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6500         LDKPublicKey their_node_id_ref;
6501         CHECK(*((uint32_t*)their_node_id) == 33);
6502         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6503         LDKUpdateFulfillHTLC msg_conv;
6504         msg_conv.inner = (void*)(msg & (~1));
6505         msg_conv.is_owned = false;
6506         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6507         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6508 }
6509
6510 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6511         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6512         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6513         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6514         LDKPublicKey their_node_id_ref;
6515         CHECK(*((uint32_t*)their_node_id) == 33);
6516         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6517         LDKUpdateFailHTLC msg_conv;
6518         msg_conv.inner = (void*)(msg & (~1));
6519         msg_conv.is_owned = false;
6520         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6521         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6522 }
6523
6524 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6525         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6526         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6527         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6528         LDKPublicKey their_node_id_ref;
6529         CHECK(*((uint32_t*)their_node_id) == 33);
6530         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6531         LDKUpdateFailMalformedHTLC msg_conv;
6532         msg_conv.inner = (void*)(msg & (~1));
6533         msg_conv.is_owned = false;
6534         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6535         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6536 }
6537
6538 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6539         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6540         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6541         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6542         LDKPublicKey their_node_id_ref;
6543         CHECK(*((uint32_t*)their_node_id) == 33);
6544         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6545         LDKCommitmentSigned msg_conv;
6546         msg_conv.inner = (void*)(msg & (~1));
6547         msg_conv.is_owned = false;
6548         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6549         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6550 }
6551
6552 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6553         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6554         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6555         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6556         LDKPublicKey their_node_id_ref;
6557         CHECK(*((uint32_t*)their_node_id) == 33);
6558         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6559         LDKRevokeAndACK msg_conv;
6560         msg_conv.inner = (void*)(msg & (~1));
6561         msg_conv.is_owned = false;
6562         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6563         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6564 }
6565
6566 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6567         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6568         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6569         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6570         LDKPublicKey their_node_id_ref;
6571         CHECK(*((uint32_t*)their_node_id) == 33);
6572         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6573         LDKUpdateFee msg_conv;
6574         msg_conv.inner = (void*)(msg & (~1));
6575         msg_conv.is_owned = false;
6576         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6577         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6578 }
6579
6580 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6581         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6582         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6583         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6584         LDKPublicKey their_node_id_ref;
6585         CHECK(*((uint32_t*)their_node_id) == 33);
6586         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6587         LDKAnnouncementSignatures msg_conv;
6588         msg_conv.inner = (void*)(msg & (~1));
6589         msg_conv.is_owned = false;
6590         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6591         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6592 }
6593
6594 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
6595         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6596         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6597         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6598         LDKPublicKey their_node_id_ref;
6599         CHECK(*((uint32_t*)their_node_id) == 33);
6600         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6601         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
6602 }
6603
6604 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6605         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6606         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6607         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6608         LDKPublicKey their_node_id_ref;
6609         CHECK(*((uint32_t*)their_node_id) == 33);
6610         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6611         LDKInit msg_conv;
6612         msg_conv.inner = (void*)(msg & (~1));
6613         msg_conv.is_owned = false;
6614         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6615         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6616 }
6617
6618 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6619         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6620         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6621         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6622         LDKPublicKey their_node_id_ref;
6623         CHECK(*((uint32_t*)their_node_id) == 33);
6624         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6625         LDKChannelReestablish msg_conv;
6626         msg_conv.inner = (void*)(msg & (~1));
6627         msg_conv.is_owned = false;
6628         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6629         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6630 }
6631
6632 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6633         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6634         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6635         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6636         LDKPublicKey their_node_id_ref;
6637         CHECK(*((uint32_t*)their_node_id) == 33);
6638         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6639         LDKChannelUpdate msg_conv;
6640         msg_conv.inner = (void*)(msg & (~1));
6641         msg_conv.is_owned = false;
6642         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6643         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6644 }
6645
6646 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6647         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6648         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6649         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6650         LDKPublicKey their_node_id_ref;
6651         CHECK(*((uint32_t*)their_node_id) == 33);
6652         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6653         LDKErrorMessage msg_conv;
6654         msg_conv.inner = (void*)(msg & (~1));
6655         msg_conv.is_owned = false;
6656         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6657         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6658 }
6659
6660 typedef struct LDKRoutingMessageHandler_JCalls {
6661         atomic_size_t refcnt;
6662         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
6663         uint32_t handle_node_announcement_meth;
6664         uint32_t handle_channel_announcement_meth;
6665         uint32_t handle_channel_update_meth;
6666         uint32_t get_next_channel_announcements_meth;
6667         uint32_t get_next_node_announcements_meth;
6668         uint32_t sync_routing_table_meth;
6669         uint32_t handle_reply_channel_range_meth;
6670         uint32_t handle_reply_short_channel_ids_end_meth;
6671         uint32_t handle_query_channel_range_meth;
6672         uint32_t handle_query_short_channel_ids_meth;
6673 } LDKRoutingMessageHandler_JCalls;
6674 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
6675         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6676         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6677                 js_free(j_calls->handle_node_announcement_meth);
6678                 js_free(j_calls->handle_channel_announcement_meth);
6679                 js_free(j_calls->handle_channel_update_meth);
6680                 js_free(j_calls->get_next_channel_announcements_meth);
6681                 js_free(j_calls->get_next_node_announcements_meth);
6682                 js_free(j_calls->sync_routing_table_meth);
6683                 js_free(j_calls->handle_reply_channel_range_meth);
6684                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
6685                 js_free(j_calls->handle_query_channel_range_meth);
6686                 js_free(j_calls->handle_query_short_channel_ids_meth);
6687                 FREE(j_calls);
6688         }
6689 }
6690 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
6691         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6692         LDKNodeAnnouncement msg_var = *msg;
6693         uint64_t msg_ref = 0;
6694         msg_var = NodeAnnouncement_clone(msg);
6695         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6696         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6697         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6698         msg_ref = (uint64_t)msg_var.inner;
6699         if (msg_var.is_owned) {
6700                 msg_ref |= 1;
6701         }
6702         uint32_t ret = js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
6703         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6704         CHECK_ACCESS(ret_ptr);
6705         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
6706         FREE((void*)ret);
6707         return ret_conv;
6708 }
6709 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
6710         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6711         LDKChannelAnnouncement msg_var = *msg;
6712         uint64_t msg_ref = 0;
6713         msg_var = ChannelAnnouncement_clone(msg);
6714         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6715         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6716         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6717         msg_ref = (uint64_t)msg_var.inner;
6718         if (msg_var.is_owned) {
6719                 msg_ref |= 1;
6720         }
6721         uint32_t ret = js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
6722         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6723         CHECK_ACCESS(ret_ptr);
6724         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
6725         FREE((void*)ret);
6726         return ret_conv;
6727 }
6728 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
6729         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6730         LDKChannelUpdate msg_var = *msg;
6731         uint64_t msg_ref = 0;
6732         msg_var = ChannelUpdate_clone(msg);
6733         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6734         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6735         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6736         msg_ref = (uint64_t)msg_var.inner;
6737         if (msg_var.is_owned) {
6738                 msg_ref |= 1;
6739         }
6740         uint32_t ret = js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
6741         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6742         CHECK_ACCESS(ret_ptr);
6743         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
6744         FREE((void*)ret);
6745         return ret_conv;
6746 }
6747 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
6748         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6749         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
6750         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
6751         ret_constr.datalen = *((uint32_t*)ret);
6752         if (ret_constr.datalen > 0)
6753                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
6754         else
6755                 ret_constr.data = NULL;
6756         uint32_t* ret_vals = (uint32_t*)(ret + 4);
6757         for (size_t h = 0; h < ret_constr.datalen; h++) {
6758                 uint32_t ret_conv_59 = ret_vals[h];
6759                 void* ret_conv_59_ptr = (void*)(((uint64_t)ret_conv_59) & ~1);
6760                 CHECK_ACCESS(ret_conv_59_ptr);
6761                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
6762                 FREE((void*)ret_conv_59);
6763                 ret_constr.data[h] = ret_conv_59_conv;
6764         }
6765         return ret_constr;
6766 }
6767 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
6768         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6769         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6770         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
6771         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
6772         LDKCVec_NodeAnnouncementZ ret_constr;
6773         ret_constr.datalen = *((uint32_t*)ret);
6774         if (ret_constr.datalen > 0)
6775                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
6776         else
6777                 ret_constr.data = NULL;
6778         uint32_t* ret_vals = (uint32_t*)(ret + 4);
6779         for (size_t s = 0; s < ret_constr.datalen; s++) {
6780                 uint32_t ret_conv_18 = ret_vals[s];
6781                 LDKNodeAnnouncement ret_conv_18_conv;
6782                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
6783                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
6784                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
6785                 ret_constr.data[s] = ret_conv_18_conv;
6786         }
6787         return ret_constr;
6788 }
6789 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
6790         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6791         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6792         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6793         LDKInit init_var = *init;
6794         uint64_t init_ref = 0;
6795         init_var = Init_clone(init);
6796         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6797         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6798         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
6799         init_ref = (uint64_t)init_var.inner;
6800         if (init_var.is_owned) {
6801                 init_ref |= 1;
6802         }
6803         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
6804 }
6805 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
6806         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6807         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6808         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6809         LDKReplyChannelRange msg_var = msg;
6810         uint64_t msg_ref = 0;
6811         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6812         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6813         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6814         msg_ref = (uint64_t)msg_var.inner;
6815         if (msg_var.is_owned) {
6816                 msg_ref |= 1;
6817         }
6818         uint32_t ret = js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
6819         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6820         CHECK_ACCESS(ret_ptr);
6821         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
6822         FREE((void*)ret);
6823         return ret_conv;
6824 }
6825 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
6826         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6827         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6828         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6829         LDKReplyShortChannelIdsEnd msg_var = msg;
6830         uint64_t msg_ref = 0;
6831         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6832         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6833         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6834         msg_ref = (uint64_t)msg_var.inner;
6835         if (msg_var.is_owned) {
6836                 msg_ref |= 1;
6837         }
6838         uint32_t ret = js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
6839         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6840         CHECK_ACCESS(ret_ptr);
6841         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
6842         FREE((void*)ret);
6843         return ret_conv;
6844 }
6845 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
6846         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6847         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6848         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6849         LDKQueryChannelRange msg_var = msg;
6850         uint64_t msg_ref = 0;
6851         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6852         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6853         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6854         msg_ref = (uint64_t)msg_var.inner;
6855         if (msg_var.is_owned) {
6856                 msg_ref |= 1;
6857         }
6858         uint32_t ret = js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
6859         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6860         CHECK_ACCESS(ret_ptr);
6861         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
6862         FREE((void*)ret);
6863         return ret_conv;
6864 }
6865 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
6866         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6867         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6868         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6869         LDKQueryShortChannelIds msg_var = msg;
6870         uint64_t msg_ref = 0;
6871         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6872         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6873         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6874         msg_ref = (uint64_t)msg_var.inner;
6875         if (msg_var.is_owned) {
6876                 msg_ref |= 1;
6877         }
6878         uint32_t ret = js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
6879         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6880         CHECK_ACCESS(ret_ptr);
6881         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
6882         FREE((void*)ret);
6883         return ret_conv;
6884 }
6885 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
6886         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
6887         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6888         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6889 }
6890 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
6891         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
6892         atomic_init(&calls->refcnt, 1);
6893         //TODO: Assign calls->o from o
6894
6895         LDKRoutingMessageHandler ret = {
6896                 .this_arg = (void*) calls,
6897                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
6898                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
6899                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
6900                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
6901                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
6902                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
6903                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
6904                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
6905                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
6906                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
6907                 .free = LDKRoutingMessageHandler_JCalls_free,
6908                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
6909         };
6910         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6911         return ret;
6912 }
6913 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
6914         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
6915         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
6916         return (long)res_ptr;
6917 }
6918 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
6919         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6920         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6921         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
6922         LDKNodeAnnouncement msg_conv;
6923         msg_conv.inner = (void*)(msg & (~1));
6924         msg_conv.is_owned = false;
6925         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6926         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6927         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
6928         return (uint64_t)ret_conv;
6929 }
6930
6931 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
6932         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6933         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6934         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
6935         LDKChannelAnnouncement msg_conv;
6936         msg_conv.inner = (void*)(msg & (~1));
6937         msg_conv.is_owned = false;
6938         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6939         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6940         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
6941         return (uint64_t)ret_conv;
6942 }
6943
6944 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
6945         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6946         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6947         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
6948         LDKChannelUpdate msg_conv;
6949         msg_conv.inner = (void*)(msg & (~1));
6950         msg_conv.is_owned = false;
6951         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6952         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6953         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
6954         return (uint64_t)ret_conv;
6955 }
6956
6957 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
6958         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6959         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6960         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
6961         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
6962         uint32_tArray ret_arr = NULL;
6963         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6964         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6965         for (size_t h = 0; h < ret_var.datalen; h++) {
6966                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6967                 *ret_conv_59_conv = ret_var.data[h];
6968                 ret_arr_ptr[h] = ((uint64_t)ret_conv_59_conv);
6969         }
6970         
6971         FREE(ret_var.data);
6972         return ret_arr;
6973 }
6974
6975 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
6976         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6977         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6978         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
6979         LDKPublicKey starting_point_ref;
6980         CHECK(*((uint32_t*)starting_point) == 33);
6981         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
6982         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
6983         uint32_tArray ret_arr = NULL;
6984         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6985         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6986         for (size_t s = 0; s < ret_var.datalen; s++) {
6987                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
6988                 uint64_t ret_conv_18_ref = 0;
6989                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6990                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6991                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
6992                 ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
6993                 if (ret_conv_18_var.is_owned) {
6994                         ret_conv_18_ref |= 1;
6995                 }
6996                 ret_arr_ptr[s] = ret_conv_18_ref;
6997         }
6998         
6999         FREE(ret_var.data);
7000         return ret_arr;
7001 }
7002
7003 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
7004         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7005         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7006         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7007         LDKPublicKey their_node_id_ref;
7008         CHECK(*((uint32_t*)their_node_id) == 33);
7009         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7010         LDKInit init_conv;
7011         init_conv.inner = (void*)(init & (~1));
7012         init_conv.is_owned = false;
7013         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
7014         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
7015 }
7016
7017 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7018         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7019         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7020         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7021         LDKPublicKey their_node_id_ref;
7022         CHECK(*((uint32_t*)their_node_id) == 33);
7023         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7024         LDKReplyChannelRange msg_conv;
7025         msg_conv.inner = (void*)(msg & (~1));
7026         msg_conv.is_owned = (msg & 1) || (msg == 0);
7027         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7028         msg_conv = ReplyChannelRange_clone(&msg_conv);
7029         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7030         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
7031         return (uint64_t)ret_conv;
7032 }
7033
7034 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_short_channel_ids_end(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7035         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7036         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7037         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7038         LDKPublicKey their_node_id_ref;
7039         CHECK(*((uint32_t*)their_node_id) == 33);
7040         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7041         LDKReplyShortChannelIdsEnd msg_conv;
7042         msg_conv.inner = (void*)(msg & (~1));
7043         msg_conv.is_owned = (msg & 1) || (msg == 0);
7044         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7045         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
7046         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7047         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
7048         return (uint64_t)ret_conv;
7049 }
7050
7051 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7052         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7053         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7054         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7055         LDKPublicKey their_node_id_ref;
7056         CHECK(*((uint32_t*)their_node_id) == 33);
7057         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7058         LDKQueryChannelRange msg_conv;
7059         msg_conv.inner = (void*)(msg & (~1));
7060         msg_conv.is_owned = (msg & 1) || (msg == 0);
7061         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7062         msg_conv = QueryChannelRange_clone(&msg_conv);
7063         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7064         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
7065         return (uint64_t)ret_conv;
7066 }
7067
7068 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7069         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7070         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7071         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7072         LDKPublicKey their_node_id_ref;
7073         CHECK(*((uint32_t*)their_node_id) == 33);
7074         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7075         LDKQueryShortChannelIds msg_conv;
7076         msg_conv.inner = (void*)(msg & (~1));
7077         msg_conv.is_owned = (msg & 1) || (msg == 0);
7078         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7079         msg_conv = QueryShortChannelIds_clone(&msg_conv);
7080         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7081         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
7082         return (uint64_t)ret_conv;
7083 }
7084
7085 typedef struct LDKCustomMessageReader_JCalls {
7086         atomic_size_t refcnt;
7087         uint32_t read_meth;
7088 } LDKCustomMessageReader_JCalls;
7089 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
7090         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
7091         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7092                 js_free(j_calls->read_meth);
7093                 FREE(j_calls);
7094         }
7095 }
7096 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
7097         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
7098         LDKu8slice buffer_var = buffer;
7099         int8_tArray buffer_arr = init_arr(buffer_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7100         memcpy((uint8_t*)(buffer_arr + 4), buffer_var.data, buffer_var.datalen);
7101         uint32_t ret = js_invoke_function_2(j_calls->read_meth, message_type, buffer_arr);
7102         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7103         CHECK_ACCESS(ret_ptr);
7104         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
7105         FREE((void*)ret);
7106         return ret_conv;
7107 }
7108 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
7109         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
7110         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7111 }
7112 static inline LDKCustomMessageReader LDKCustomMessageReader_init (/*TODO: JS Object Reference */void* o) {
7113         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
7114         atomic_init(&calls->refcnt, 1);
7115         //TODO: Assign calls->o from o
7116
7117         LDKCustomMessageReader ret = {
7118                 .this_arg = (void*) calls,
7119                 .read = read_LDKCustomMessageReader_jcall,
7120                 .free = LDKCustomMessageReader_JCalls_free,
7121         };
7122         return ret;
7123 }
7124 long  __attribute__((visibility("default"))) TS_LDKCustomMessageReader_new(/*TODO: JS Object Reference */void* o) {
7125         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
7126         *res_ptr = LDKCustomMessageReader_init(o);
7127         return (long)res_ptr;
7128 }
7129 uint32_t  __attribute__((visibility("default"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
7130         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7131         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7132         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
7133         LDKu8slice buffer_ref;
7134         buffer_ref.datalen = *((uint32_t*)buffer);
7135         buffer_ref.data = (int8_t*)(buffer + 4);
7136         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
7137         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
7138         return (uint64_t)ret_conv;
7139 }
7140
7141 typedef struct LDKCustomMessageHandler_JCalls {
7142         atomic_size_t refcnt;
7143         LDKCustomMessageReader_JCalls* CustomMessageReader;
7144         uint32_t handle_custom_message_meth;
7145         uint32_t get_and_clear_pending_msg_meth;
7146 } LDKCustomMessageHandler_JCalls;
7147 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
7148         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
7149         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7150                 js_free(j_calls->handle_custom_message_meth);
7151                 js_free(j_calls->get_and_clear_pending_msg_meth);
7152                 FREE(j_calls);
7153         }
7154 }
7155 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
7156         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
7157         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
7158         *msg_ret = msg;
7159         int8_tArray sender_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7160         memcpy((uint8_t*)(sender_node_id_arr + 4), sender_node_id.compressed_form, 33);
7161         uint32_t ret = js_invoke_function_2(j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr);
7162         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7163         CHECK_ACCESS(ret_ptr);
7164         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
7165         FREE((void*)ret);
7166         return ret_conv;
7167 }
7168 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
7169         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
7170         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_meth);
7171         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
7172         ret_constr.datalen = *((uint32_t*)ret);
7173         if (ret_constr.datalen > 0)
7174                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
7175         else
7176                 ret_constr.data = NULL;
7177         uint32_t* ret_vals = (uint32_t*)(ret + 4);
7178         for (size_t z = 0; z < ret_constr.datalen; z++) {
7179                 uint32_t ret_conv_25 = ret_vals[z];
7180                 void* ret_conv_25_ptr = (void*)(((uint64_t)ret_conv_25) & ~1);
7181                 CHECK_ACCESS(ret_conv_25_ptr);
7182                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
7183                 FREE((void*)ret_conv_25);
7184                 ret_constr.data[z] = ret_conv_25_conv;
7185         }
7186         return ret_constr;
7187 }
7188 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
7189         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
7190         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7191         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
7192 }
7193 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* CustomMessageReader) {
7194         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
7195         atomic_init(&calls->refcnt, 1);
7196         //TODO: Assign calls->o from o
7197
7198         LDKCustomMessageHandler ret = {
7199                 .this_arg = (void*) calls,
7200                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
7201                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
7202                 .free = LDKCustomMessageHandler_JCalls_free,
7203                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
7204         };
7205         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
7206         return ret;
7207 }
7208 long  __attribute__((visibility("default"))) TS_LDKCustomMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* CustomMessageReader) {
7209         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
7210         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
7211         return (long)res_ptr;
7212 }
7213 uint32_t  __attribute__((visibility("default"))) TS_CustomMessageHandler_handle_custom_message(uint32_t this_arg, uint32_t msg, int8_tArray sender_node_id) {
7214         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7215         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7216         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
7217         void* msg_ptr = (void*)(((uint64_t)msg) & ~1);
7218         CHECK_ACCESS(msg_ptr);
7219         LDKType msg_conv = *(LDKType*)(msg_ptr);
7220         LDKPublicKey sender_node_id_ref;
7221         CHECK(*((uint32_t*)sender_node_id) == 33);
7222         memcpy(sender_node_id_ref.compressed_form, (uint8_t*)(sender_node_id + 4), 33);
7223         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7224         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
7225         return (uint64_t)ret_conv;
7226 }
7227
7228 uint32_tArray  __attribute__((visibility("default"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
7229         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7230         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7231         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
7232         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
7233         uint32_tArray ret_arr = NULL;
7234         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7235         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7236         for (size_t z = 0; z < ret_var.datalen; z++) {
7237                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
7238                 *ret_conv_25_conv = ret_var.data[z];
7239                 ret_arr_ptr[z] = ((uint64_t)ret_conv_25_conv);
7240         }
7241         
7242         FREE(ret_var.data);
7243         return ret_arr;
7244 }
7245
7246 typedef struct LDKSocketDescriptor_JCalls {
7247         atomic_size_t refcnt;
7248         uint32_t send_data_meth;
7249         uint32_t disconnect_socket_meth;
7250         uint32_t eq_meth;
7251         uint32_t hash_meth;
7252 } LDKSocketDescriptor_JCalls;
7253 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
7254         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7255         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7256                 js_free(j_calls->send_data_meth);
7257                 js_free(j_calls->disconnect_socket_meth);
7258                 js_free(j_calls->eq_meth);
7259                 js_free(j_calls->hash_meth);
7260                 FREE(j_calls);
7261         }
7262 }
7263 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
7264         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7265         LDKu8slice data_var = data;
7266         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7267         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
7268         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
7269 }
7270 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
7271         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7272         js_invoke_function_0(j_calls->disconnect_socket_meth);
7273 }
7274 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
7275         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7276         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
7277         *other_arg_clone = SocketDescriptor_clone(other_arg);
7278         return js_invoke_function_1(j_calls->eq_meth, (uint64_t)other_arg_clone);
7279 }
7280 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
7281         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7282         return js_invoke_function_0(j_calls->hash_meth);
7283 }
7284 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
7285         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
7286         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7287 }
7288 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
7289         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
7290         atomic_init(&calls->refcnt, 1);
7291         //TODO: Assign calls->o from o
7292
7293         LDKSocketDescriptor ret = {
7294                 .this_arg = (void*) calls,
7295                 .send_data = send_data_LDKSocketDescriptor_jcall,
7296                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
7297                 .eq = eq_LDKSocketDescriptor_jcall,
7298                 .hash = hash_LDKSocketDescriptor_jcall,
7299                 .cloned = LDKSocketDescriptor_JCalls_cloned,
7300                 .free = LDKSocketDescriptor_JCalls_free,
7301         };
7302         return ret;
7303 }
7304 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
7305         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
7306         *res_ptr = LDKSocketDescriptor_init(o);
7307         return (long)res_ptr;
7308 }
7309 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
7310         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7311         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7312         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
7313         LDKu8slice data_ref;
7314         data_ref.datalen = *((uint32_t*)data);
7315         data_ref.data = (int8_t*)(data + 4);
7316         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
7317         return ret_val;
7318 }
7319
7320 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
7321         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7322         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7323         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
7324         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
7325 }
7326
7327 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
7328         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7329         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7330         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
7331         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
7332         return ret_val;
7333 }
7334
7335 typedef struct LDKScore_JCalls {
7336         atomic_size_t refcnt;
7337         uint32_t channel_penalty_msat_meth;
7338         uint32_t payment_path_failed_meth;
7339         uint32_t write_meth;
7340 } LDKScore_JCalls;
7341 static void LDKScore_JCalls_free(void* this_arg) {
7342         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
7343         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7344                 js_free(j_calls->channel_penalty_msat_meth);
7345                 js_free(j_calls->payment_path_failed_meth);
7346                 js_free(j_calls->write_meth);
7347                 FREE(j_calls);
7348         }
7349 }
7350 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target) {
7351         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
7352         LDKNodeId source_var = *source;
7353         uint64_t source_ref = 0;
7354         source_var = NodeId_clone(source);
7355         CHECK((((uint64_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7356         CHECK((((uint64_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7357         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
7358         source_ref = (uint64_t)source_var.inner;
7359         if (source_var.is_owned) {
7360                 source_ref |= 1;
7361         }
7362         LDKNodeId target_var = *target;
7363         uint64_t target_ref = 0;
7364         target_var = NodeId_clone(target);
7365         CHECK((((uint64_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7366         CHECK((((uint64_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7367         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
7368         target_ref = (uint64_t)target_var.inner;
7369         if (target_var.is_owned) {
7370                 target_ref |= 1;
7371         }
7372         return js_invoke_function_3(j_calls->channel_penalty_msat_meth, short_channel_id, source_ref, target_ref);
7373 }
7374 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
7375         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
7376         LDKCVec_RouteHopZ path_var = path;
7377         uint32_tArray path_arr = NULL;
7378         path_arr = init_arr(path_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7379         uint32_t *path_arr_ptr = (uint32_t*)(path_arr + 4);
7380         for (size_t k = 0; k < path_var.datalen; k++) {
7381                 LDKRouteHop path_conv_10_var = path_var.data[k];
7382                 uint64_t path_conv_10_ref = 0;
7383                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7384                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7385                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
7386                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner;
7387                 if (path_conv_10_var.is_owned) {
7388                         path_conv_10_ref |= 1;
7389                 }
7390                 path_arr_ptr[k] = path_conv_10_ref;
7391         }
7392         
7393         FREE(path_var.data);
7394         js_invoke_function_2(j_calls->payment_path_failed_meth, path_arr, short_channel_id);
7395 }
7396 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
7397         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
7398         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
7399         LDKCVec_u8Z ret_ref;
7400         ret_ref.datalen = *((uint32_t*)ret);
7401         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7402         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
7403         return ret_ref;
7404 }
7405 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
7406         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
7407         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7408 }
7409 static inline LDKScore LDKScore_init (/*TODO: JS Object Reference */void* o) {
7410         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
7411         atomic_init(&calls->refcnt, 1);
7412         //TODO: Assign calls->o from o
7413
7414         LDKScore ret = {
7415                 .this_arg = (void*) calls,
7416                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
7417                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
7418                 .write = write_LDKScore_jcall,
7419                 .free = LDKScore_JCalls_free,
7420         };
7421         return ret;
7422 }
7423 long  __attribute__((visibility("default"))) TS_LDKScore_new(/*TODO: JS Object Reference */void* o) {
7424         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
7425         *res_ptr = LDKScore_init(o);
7426         return (long)res_ptr;
7427 }
7428 int64_t  __attribute__((visibility("default"))) TS_Score_channel_penalty_msat(uint32_t this_arg, int64_t short_channel_id, uint32_t source, uint32_t target) {
7429         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7430         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7431         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
7432         LDKNodeId source_conv;
7433         source_conv.inner = (void*)(source & (~1));
7434         source_conv.is_owned = false;
7435         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
7436         LDKNodeId target_conv;
7437         target_conv.inner = (void*)(target & (~1));
7438         target_conv.is_owned = false;
7439         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
7440         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv);
7441         return ret_val;
7442 }
7443
7444 void  __attribute__((visibility("default"))) TS_Score_payment_path_failed(uint32_t this_arg, uint32_tArray path, int64_t short_channel_id) {
7445         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7446         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7447         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
7448         LDKCVec_RouteHopZ path_constr;
7449         path_constr.datalen = *((uint32_t*)path);
7450         if (path_constr.datalen > 0)
7451                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7452         else
7453                 path_constr.data = NULL;
7454         uint32_t* path_vals = (uint32_t*)(path + 4);
7455         for (size_t k = 0; k < path_constr.datalen; k++) {
7456                 uint32_t path_conv_10 = path_vals[k];
7457                 LDKRouteHop path_conv_10_conv;
7458                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
7459                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
7460                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
7461                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
7462                 path_constr.data[k] = path_conv_10_conv;
7463         }
7464         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
7465 }
7466
7467 int8_tArray  __attribute__((visibility("default"))) TS_Score_write(uint32_t this_arg) {
7468         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7469         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7470         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
7471         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
7472         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7473         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
7474         CVec_u8Z_free(ret_var);
7475         return ret_arr;
7476 }
7477
7478 typedef struct LDKChannelManagerPersister_JCalls {
7479         atomic_size_t refcnt;
7480         uint32_t persist_manager_meth;
7481 } LDKChannelManagerPersister_JCalls;
7482 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
7483         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
7484         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7485                 js_free(j_calls->persist_manager_meth);
7486                 FREE(j_calls);
7487         }
7488 }
7489 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
7490         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
7491         LDKChannelManager channel_manager_var = *channel_manager;
7492         uint64_t channel_manager_ref = 0;
7493         // Warning: we may need a move here but no clone is available for LDKChannelManager
7494         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7495         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7496         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
7497         channel_manager_ref = (uint64_t)channel_manager_var.inner;
7498         if (channel_manager_var.is_owned) {
7499                 channel_manager_ref |= 1;
7500         }
7501         uint32_t ret = js_invoke_function_1(j_calls->persist_manager_meth, channel_manager_ref);
7502         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7503         CHECK_ACCESS(ret_ptr);
7504         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
7505         FREE((void*)ret);
7506         return ret_conv;
7507 }
7508 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
7509         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
7510         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7511 }
7512 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (/*TODO: JS Object Reference */void* o) {
7513         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
7514         atomic_init(&calls->refcnt, 1);
7515         //TODO: Assign calls->o from o
7516
7517         LDKChannelManagerPersister ret = {
7518                 .this_arg = (void*) calls,
7519                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
7520                 .free = LDKChannelManagerPersister_JCalls_free,
7521         };
7522         return ret;
7523 }
7524 long  __attribute__((visibility("default"))) TS_LDKChannelManagerPersister_new(/*TODO: JS Object Reference */void* o) {
7525         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
7526         *res_ptr = LDKChannelManagerPersister_init(o);
7527         return (long)res_ptr;
7528 }
7529 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerPersister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
7530         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7531         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7532         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)this_arg_ptr;
7533         LDKChannelManager channel_manager_conv;
7534         channel_manager_conv.inner = (void*)(channel_manager & (~1));
7535         channel_manager_conv.is_owned = false;
7536         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
7537         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
7538         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
7539         return (uint64_t)ret_conv;
7540 }
7541
7542 uint32_t __attribute__((visibility("default"))) TS_LDKFallback_ref_from_ptr(uint32_t ptr) {
7543         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
7544         switch(obj->tag) {
7545                 case LDKFallback_SegWitProgram: {
7546                         uint8_t version_val = obj->seg_wit_program.version._0;
7547                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
7548                         int8_tArray program_arr = init_arr(program_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7549                         memcpy((uint8_t*)(program_arr + 4), program_var.data, program_var.datalen);
7550                         return 0 /* LDKFallback - SegWitProgram */; (void) version_val; (void) program_arr;
7551                 }
7552                 case LDKFallback_PubKeyHash: {
7553                         int8_tArray pub_key_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
7554                         memcpy((uint8_t*)(pub_key_hash_arr + 4), obj->pub_key_hash.data, 20);
7555                         return 0 /* LDKFallback - PubKeyHash */; (void) pub_key_hash_arr;
7556                 }
7557                 case LDKFallback_ScriptHash: {
7558                         int8_tArray script_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
7559                         memcpy((uint8_t*)(script_hash_arr + 4), obj->script_hash.data, 20);
7560                         return 0 /* LDKFallback - ScriptHash */; (void) script_hash_arr;
7561                 }
7562                 default: abort();
7563         }
7564 }
7565 typedef struct LDKPayer_JCalls {
7566         atomic_size_t refcnt;
7567         uint32_t node_id_meth;
7568         uint32_t first_hops_meth;
7569         uint32_t send_payment_meth;
7570         uint32_t retry_payment_meth;
7571 } LDKPayer_JCalls;
7572 static void LDKPayer_JCalls_free(void* this_arg) {
7573         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
7574         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7575                 js_free(j_calls->node_id_meth);
7576                 js_free(j_calls->first_hops_meth);
7577                 js_free(j_calls->send_payment_meth);
7578                 js_free(j_calls->retry_payment_meth);
7579                 FREE(j_calls);
7580         }
7581 }
7582 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
7583         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
7584         int8_tArray ret = js_invoke_function_0(j_calls->node_id_meth);
7585         LDKPublicKey ret_ref;
7586         CHECK(*((uint32_t*)ret) == 33);
7587         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
7588         return ret_ref;
7589 }
7590 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
7591         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
7592         uint32_tArray ret = js_invoke_function_0(j_calls->first_hops_meth);
7593         LDKCVec_ChannelDetailsZ ret_constr;
7594         ret_constr.datalen = *((uint32_t*)ret);
7595         if (ret_constr.datalen > 0)
7596                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
7597         else
7598                 ret_constr.data = NULL;
7599         uint32_t* ret_vals = (uint32_t*)(ret + 4);
7600         for (size_t q = 0; q < ret_constr.datalen; q++) {
7601                 uint32_t ret_conv_16 = ret_vals[q];
7602                 LDKChannelDetails ret_conv_16_conv;
7603                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
7604                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
7605                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
7606                 ret_constr.data[q] = ret_conv_16_conv;
7607         }
7608         return ret_constr;
7609 }
7610 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
7611         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
7612         LDKRoute route_var = *route;
7613         uint64_t route_ref = 0;
7614         route_var = Route_clone(route);
7615         CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7616         CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7617         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
7618         route_ref = (uint64_t)route_var.inner;
7619         if (route_var.is_owned) {
7620                 route_ref |= 1;
7621         }
7622         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7623         memcpy((uint8_t*)(payment_hash_arr + 4), payment_hash.data, 32);
7624         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7625         memcpy((uint8_t*)(payment_secret_arr + 4), payment_secret.data, 32);
7626         uint32_t ret = js_invoke_function_3(j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
7627         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7628         CHECK_ACCESS(ret_ptr);
7629         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
7630         FREE((void*)ret);
7631         return ret_conv;
7632 }
7633 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
7634         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
7635         LDKRoute route_var = *route;
7636         uint64_t route_ref = 0;
7637         route_var = Route_clone(route);
7638         CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7639         CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7640         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
7641         route_ref = (uint64_t)route_var.inner;
7642         if (route_var.is_owned) {
7643                 route_ref |= 1;
7644         }
7645         int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7646         memcpy((uint8_t*)(payment_id_arr + 4), payment_id.data, 32);
7647         uint32_t ret = js_invoke_function_2(j_calls->retry_payment_meth, route_ref, payment_id_arr);
7648         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7649         CHECK_ACCESS(ret_ptr);
7650         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
7651         FREE((void*)ret);
7652         return ret_conv;
7653 }
7654 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
7655         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
7656         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7657 }
7658 static inline LDKPayer LDKPayer_init (/*TODO: JS Object Reference */void* o) {
7659         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
7660         atomic_init(&calls->refcnt, 1);
7661         //TODO: Assign calls->o from o
7662
7663         LDKPayer ret = {
7664                 .this_arg = (void*) calls,
7665                 .node_id = node_id_LDKPayer_jcall,
7666                 .first_hops = first_hops_LDKPayer_jcall,
7667                 .send_payment = send_payment_LDKPayer_jcall,
7668                 .retry_payment = retry_payment_LDKPayer_jcall,
7669                 .free = LDKPayer_JCalls_free,
7670         };
7671         return ret;
7672 }
7673 long  __attribute__((visibility("default"))) TS_LDKPayer_new(/*TODO: JS Object Reference */void* o) {
7674         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
7675         *res_ptr = LDKPayer_init(o);
7676         return (long)res_ptr;
7677 }
7678 int8_tArray  __attribute__((visibility("default"))) TS_Payer_node_id(uint32_t this_arg) {
7679         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7680         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7681         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
7682         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7683         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
7684         return ret_arr;
7685 }
7686
7687 uint32_tArray  __attribute__((visibility("default"))) TS_Payer_first_hops(uint32_t this_arg) {
7688         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7689         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7690         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
7691         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
7692         uint32_tArray ret_arr = NULL;
7693         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7694         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7695         for (size_t q = 0; q < ret_var.datalen; q++) {
7696                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
7697                 uint64_t ret_conv_16_ref = 0;
7698                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7699                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7700                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
7701                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
7702                 if (ret_conv_16_var.is_owned) {
7703                         ret_conv_16_ref |= 1;
7704                 }
7705                 ret_arr_ptr[q] = ret_conv_16_ref;
7706         }
7707         
7708         FREE(ret_var.data);
7709         return ret_arr;
7710 }
7711
7712 uint32_t  __attribute__((visibility("default"))) TS_Payer_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
7713         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7714         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7715         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
7716         LDKRoute route_conv;
7717         route_conv.inner = (void*)(route & (~1));
7718         route_conv.is_owned = false;
7719         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
7720         LDKThirtyTwoBytes payment_hash_ref;
7721         CHECK(*((uint32_t*)payment_hash) == 32);
7722         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
7723         LDKThirtyTwoBytes payment_secret_ref;
7724         CHECK(*((uint32_t*)payment_secret) == 32);
7725         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
7726         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
7727         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
7728         return (uint64_t)ret_conv;
7729 }
7730
7731 uint32_t  __attribute__((visibility("default"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
7732         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7733         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7734         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
7735         LDKRoute route_conv;
7736         route_conv.inner = (void*)(route & (~1));
7737         route_conv.is_owned = false;
7738         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
7739         LDKThirtyTwoBytes payment_id_ref;
7740         CHECK(*((uint32_t*)payment_id) == 32);
7741         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
7742         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7743         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
7744         return (uint64_t)ret_conv;
7745 }
7746
7747 typedef struct LDKRouter_JCalls {
7748         atomic_size_t refcnt;
7749         uint32_t find_route_meth;
7750 } LDKRouter_JCalls;
7751 static void LDKRouter_JCalls_free(void* this_arg) {
7752         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
7753         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7754                 js_free(j_calls->find_route_meth);
7755                 FREE(j_calls);
7756         }
7757 }
7758 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * params, LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
7759         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
7760         int8_tArray payer_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7761         memcpy((uint8_t*)(payer_arr + 4), payer.compressed_form, 33);
7762         LDKRouteParameters params_var = *params;
7763         uint64_t params_ref = 0;
7764         params_var = RouteParameters_clone(params);
7765         CHECK((((uint64_t)params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7766         CHECK((((uint64_t)&params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7767         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_var);
7768         params_ref = (uint64_t)params_var.inner;
7769         if (params_var.is_owned) {
7770                 params_ref |= 1;
7771         }
7772         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
7773         uint32_tArray first_hops_arr = NULL;
7774         if (first_hops != NULL) {
7775                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
7776                 first_hops_arr = init_arr(first_hops_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7777                 uint32_t *first_hops_arr_ptr = (uint32_t*)(first_hops_arr + 4);
7778                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
7779                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
7780                         uint64_t first_hops_conv_16_ref = 0;
7781                         CHECK((((uint64_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7782                         CHECK((((uint64_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7783                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
7784                         first_hops_conv_16_ref = (uint64_t)first_hops_conv_16_var.inner;
7785                         if (first_hops_conv_16_var.is_owned) {
7786                                 first_hops_conv_16_ref |= 1;
7787                         }
7788                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
7789                 }
7790         
7791         }
7792         // WARNING: This object doesn't live past this scope, needs clone!
7793         uint64_t ret_scorer = ((uint64_t)scorer) | 1;
7794         uint32_t ret = js_invoke_function_4(j_calls->find_route_meth, payer_arr, params_ref, first_hops_arr, ret_scorer);
7795         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7796         CHECK_ACCESS(ret_ptr);
7797         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
7798         FREE((void*)ret);
7799         return ret_conv;
7800 }
7801 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
7802         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
7803         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7804 }
7805 static inline LDKRouter LDKRouter_init (/*TODO: JS Object Reference */void* o) {
7806         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
7807         atomic_init(&calls->refcnt, 1);
7808         //TODO: Assign calls->o from o
7809
7810         LDKRouter ret = {
7811                 .this_arg = (void*) calls,
7812                 .find_route = find_route_LDKRouter_jcall,
7813                 .free = LDKRouter_JCalls_free,
7814         };
7815         return ret;
7816 }
7817 long  __attribute__((visibility("default"))) TS_LDKRouter_new(/*TODO: JS Object Reference */void* o) {
7818         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
7819         *res_ptr = LDKRouter_init(o);
7820         return (long)res_ptr;
7821 }
7822 uint32_t  __attribute__((visibility("default"))) TS_Router_find_route(uint32_t this_arg, int8_tArray payer, uint32_t params, uint32_tArray first_hops, uint32_t scorer) {
7823         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7824         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7825         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
7826         LDKPublicKey payer_ref;
7827         CHECK(*((uint32_t*)payer) == 33);
7828         memcpy(payer_ref.compressed_form, (uint8_t*)(payer + 4), 33);
7829         LDKRouteParameters params_conv;
7830         params_conv.inner = (void*)(params & (~1));
7831         params_conv.is_owned = false;
7832         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
7833         LDKCVec_ChannelDetailsZ first_hops_constr;
7834         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
7835         if (first_hops != 0) {
7836                 first_hops_constr.datalen = *((uint32_t*)first_hops);
7837                 if (first_hops_constr.datalen > 0)
7838                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
7839                 else
7840                         first_hops_constr.data = NULL;
7841                 uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
7842                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
7843                         uint32_t first_hops_conv_16 = first_hops_vals[q];
7844                         LDKChannelDetails first_hops_conv_16_conv;
7845                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
7846                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
7847                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
7848                         first_hops_constr.data[q] = first_hops_conv_16_conv;
7849                 }
7850                 first_hops_ptr = &first_hops_constr;
7851         }
7852         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
7853         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
7854         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
7855         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
7856         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &params_conv, first_hops_ptr, scorer_conv);
7857         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
7858         return (uint64_t)ret_conv;
7859 }
7860
7861 jstring  __attribute__((visibility("default"))) TS__ldk_get_compiled_version() {
7862         LDKStr ret_str = _ldk_get_compiled_version();
7863         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
7864         Str_free(ret_str);
7865         return ret_conv;
7866 }
7867
7868 jstring  __attribute__((visibility("default"))) TS__ldk_c_bindings_get_compiled_version() {
7869         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
7870         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
7871         Str_free(ret_str);
7872         return ret_conv;
7873 }
7874
7875 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
7876         LDKTransaction _res_ref;
7877         _res_ref.datalen = *((uint32_t*)_res);
7878         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
7879         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
7880         _res_ref.data_is_owned = true;
7881         Transaction_free(_res_ref);
7882 }
7883
7884 uint32_t  __attribute__((visibility("default"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
7885         LDKCVec_u8Z script_pubkey_ref;
7886         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
7887         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
7888         memcpy(script_pubkey_ref.data, (uint8_t*)(script_pubkey + 4), script_pubkey_ref.datalen);
7889         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7890         *ret_ref = TxOut_new(script_pubkey_ref, value);
7891         return (uint64_t)ret_ref;
7892 }
7893
7894 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
7895         if ((_res & 1) != 0) return;
7896         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
7897         CHECK_ACCESS(_res_ptr);
7898         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
7899         FREE((void*)_res);
7900         TxOut_free(_res_conv);
7901 }
7902
7903 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
7904         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7905         *ret_ref = TxOut_clone(arg);
7906         return (uint64_t)ret_ref;
7907 }
7908 int64_t  __attribute__((visibility("default"))) TS_TxOut_clone_ptr(uint32_t arg) {
7909         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
7910         int64_t ret_val = TxOut_clone_ptr(arg_conv);
7911         return ret_val;
7912 }
7913
7914 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
7915         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
7916         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7917         *ret_ref = TxOut_clone(orig_conv);
7918         return (uint64_t)ret_ref;
7919 }
7920
7921 void  __attribute__((visibility("default"))) TS_Str_free(jstring _res) {
7922         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
7923         Str_free(dummy);
7924 }
7925
7926 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
7927         LDKSecretKey o_ref;
7928         CHECK(*((uint32_t*)o) == 32);
7929         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
7930         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
7931         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
7932         return (uint64_t)ret_conv;
7933 }
7934
7935 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
7936         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
7937         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
7938         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
7939         return (uint64_t)ret_conv;
7940 }
7941
7942 jboolean  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
7943         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
7944         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
7945         return ret_val;
7946 }
7947
7948 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
7949         if ((_res & 1) != 0) return;
7950         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
7951         CHECK_ACCESS(_res_ptr);
7952         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
7953         FREE((void*)_res);
7954         CResult_SecretKeyErrorZ_free(_res_conv);
7955 }
7956
7957 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
7958         LDKPublicKey o_ref;
7959         CHECK(*((uint32_t*)o) == 33);
7960         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
7961         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
7962         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
7963         return (uint64_t)ret_conv;
7964 }
7965
7966 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
7967         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
7968         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
7969         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
7970         return (uint64_t)ret_conv;
7971 }
7972
7973 jboolean  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
7974         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
7975         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
7976         return ret_val;
7977 }
7978
7979 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
7980         if ((_res & 1) != 0) return;
7981         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
7982         CHECK_ACCESS(_res_ptr);
7983         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
7984         FREE((void*)_res);
7985         CResult_PublicKeyErrorZ_free(_res_conv);
7986 }
7987
7988 static inline uint64_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
7989         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
7990         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
7991         return (uint64_t)ret_conv;
7992 }
7993 int64_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
7994         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
7995         int64_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
7996         return ret_val;
7997 }
7998
7999 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
8000         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
8001         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8002         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
8003         return (uint64_t)ret_conv;
8004 }
8005
8006 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
8007         LDKTxCreationKeys o_conv;
8008         o_conv.inner = (void*)(o & (~1));
8009         o_conv.is_owned = (o & 1) || (o == 0);
8010         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8011         o_conv = TxCreationKeys_clone(&o_conv);
8012         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8013         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
8014         return (uint64_t)ret_conv;
8015 }
8016
8017 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
8018         LDKDecodeError e_conv;
8019         e_conv.inner = (void*)(e & (~1));
8020         e_conv.is_owned = (e & 1) || (e == 0);
8021         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8022         e_conv = DecodeError_clone(&e_conv);
8023         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8024         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
8025         return (uint64_t)ret_conv;
8026 }
8027
8028 jboolean  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
8029         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
8030         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
8031         return ret_val;
8032 }
8033
8034 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
8035         if ((_res & 1) != 0) return;
8036         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8037         CHECK_ACCESS(_res_ptr);
8038         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
8039         FREE((void*)_res);
8040         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
8041 }
8042
8043 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
8044         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8045         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
8046         return (uint64_t)ret_conv;
8047 }
8048 int64_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
8049         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
8050         int64_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
8051         return ret_val;
8052 }
8053
8054 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
8055         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
8056         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8057         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
8058         return (uint64_t)ret_conv;
8059 }
8060
8061 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
8062         LDKChannelPublicKeys o_conv;
8063         o_conv.inner = (void*)(o & (~1));
8064         o_conv.is_owned = (o & 1) || (o == 0);
8065         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8066         o_conv = ChannelPublicKeys_clone(&o_conv);
8067         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8068         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
8069         return (uint64_t)ret_conv;
8070 }
8071
8072 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
8073         LDKDecodeError e_conv;
8074         e_conv.inner = (void*)(e & (~1));
8075         e_conv.is_owned = (e & 1) || (e == 0);
8076         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8077         e_conv = DecodeError_clone(&e_conv);
8078         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8079         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
8080         return (uint64_t)ret_conv;
8081 }
8082
8083 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
8084         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
8085         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
8086         return ret_val;
8087 }
8088
8089 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
8090         if ((_res & 1) != 0) return;
8091         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8092         CHECK_ACCESS(_res_ptr);
8093         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
8094         FREE((void*)_res);
8095         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
8096 }
8097
8098 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
8099         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8100         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
8101         return (uint64_t)ret_conv;
8102 }
8103 int64_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
8104         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
8105         int64_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
8106         return ret_val;
8107 }
8108
8109 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
8110         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
8111         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8112         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
8113         return (uint64_t)ret_conv;
8114 }
8115
8116 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
8117         LDKTxCreationKeys o_conv;
8118         o_conv.inner = (void*)(o & (~1));
8119         o_conv.is_owned = (o & 1) || (o == 0);
8120         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8121         o_conv = TxCreationKeys_clone(&o_conv);
8122         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8123         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
8124         return (uint64_t)ret_conv;
8125 }
8126
8127 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
8128         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8129         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8130         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
8131         return (uint64_t)ret_conv;
8132 }
8133
8134 jboolean  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
8135         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
8136         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
8137         return ret_val;
8138 }
8139
8140 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
8141         if ((_res & 1) != 0) return;
8142         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8143         CHECK_ACCESS(_res_ptr);
8144         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
8145         FREE((void*)_res);
8146         CResult_TxCreationKeysErrorZ_free(_res_conv);
8147 }
8148
8149 static inline uint64_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
8150         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8151         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
8152         return (uint64_t)ret_conv;
8153 }
8154 int64_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
8155         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
8156         int64_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
8157         return ret_val;
8158 }
8159
8160 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
8161         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
8162         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8163         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
8164         return (uint64_t)ret_conv;
8165 }
8166
8167 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_some(int32_t o) {
8168         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8169         *ret_copy = COption_u32Z_some(o);
8170         uint64_t ret_ref = (uint64_t)ret_copy;
8171         return ret_ref;
8172 }
8173
8174 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_none() {
8175         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8176         *ret_copy = COption_u32Z_none();
8177         uint64_t ret_ref = (uint64_t)ret_copy;
8178         return ret_ref;
8179 }
8180
8181 void  __attribute__((visibility("default"))) TS_COption_u32Z_free(uint32_t _res) {
8182         if ((_res & 1) != 0) return;
8183         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8184         CHECK_ACCESS(_res_ptr);
8185         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
8186         FREE((void*)_res);
8187         COption_u32Z_free(_res_conv);
8188 }
8189
8190 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
8191         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8192         *ret_copy = COption_u32Z_clone(arg);
8193 uint64_t ret_ref = (uint64_t)ret_copy;
8194         return ret_ref;
8195 }
8196 int64_t  __attribute__((visibility("default"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
8197         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
8198         int64_t ret_val = COption_u32Z_clone_ptr(arg_conv);
8199         return ret_val;
8200 }
8201
8202 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_clone(uint32_t orig) {
8203         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
8204         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8205         *ret_copy = COption_u32Z_clone(orig_conv);
8206         uint64_t ret_ref = (uint64_t)ret_copy;
8207         return ret_ref;
8208 }
8209
8210 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
8211         LDKHTLCOutputInCommitment o_conv;
8212         o_conv.inner = (void*)(o & (~1));
8213         o_conv.is_owned = (o & 1) || (o == 0);
8214         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8215         o_conv = HTLCOutputInCommitment_clone(&o_conv);
8216         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8217         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
8218         return (uint64_t)ret_conv;
8219 }
8220
8221 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
8222         LDKDecodeError e_conv;
8223         e_conv.inner = (void*)(e & (~1));
8224         e_conv.is_owned = (e & 1) || (e == 0);
8225         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8226         e_conv = DecodeError_clone(&e_conv);
8227         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8228         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
8229         return (uint64_t)ret_conv;
8230 }
8231
8232 jboolean  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
8233         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
8234         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
8235         return ret_val;
8236 }
8237
8238 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
8239         if ((_res & 1) != 0) return;
8240         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8241         CHECK_ACCESS(_res_ptr);
8242         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
8243         FREE((void*)_res);
8244         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
8245 }
8246
8247 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
8248         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8249         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
8250         return (uint64_t)ret_conv;
8251 }
8252 int64_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
8253         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
8254         int64_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
8255         return ret_val;
8256 }
8257
8258 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
8259         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
8260         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8261         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
8262         return (uint64_t)ret_conv;
8263 }
8264
8265 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
8266         LDKCounterpartyChannelTransactionParameters o_conv;
8267         o_conv.inner = (void*)(o & (~1));
8268         o_conv.is_owned = (o & 1) || (o == 0);
8269         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8270         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
8271         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8272         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
8273         return (uint64_t)ret_conv;
8274 }
8275
8276 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
8277         LDKDecodeError e_conv;
8278         e_conv.inner = (void*)(e & (~1));
8279         e_conv.is_owned = (e & 1) || (e == 0);
8280         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8281         e_conv = DecodeError_clone(&e_conv);
8282         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8283         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
8284         return (uint64_t)ret_conv;
8285 }
8286
8287 jboolean  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
8288         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
8289         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
8290         return ret_val;
8291 }
8292
8293 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
8294         if ((_res & 1) != 0) return;
8295         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8296         CHECK_ACCESS(_res_ptr);
8297         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
8298         FREE((void*)_res);
8299         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
8300 }
8301
8302 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
8303         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8304         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
8305         return (uint64_t)ret_conv;
8306 }
8307 int64_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
8308         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
8309         int64_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
8310         return ret_val;
8311 }
8312
8313 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
8314         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
8315         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8316         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
8317         return (uint64_t)ret_conv;
8318 }
8319
8320 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
8321         LDKChannelTransactionParameters o_conv;
8322         o_conv.inner = (void*)(o & (~1));
8323         o_conv.is_owned = (o & 1) || (o == 0);
8324         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8325         o_conv = ChannelTransactionParameters_clone(&o_conv);
8326         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8327         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
8328         return (uint64_t)ret_conv;
8329 }
8330
8331 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
8332         LDKDecodeError e_conv;
8333         e_conv.inner = (void*)(e & (~1));
8334         e_conv.is_owned = (e & 1) || (e == 0);
8335         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8336         e_conv = DecodeError_clone(&e_conv);
8337         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8338         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
8339         return (uint64_t)ret_conv;
8340 }
8341
8342 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
8343         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
8344         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
8345         return ret_val;
8346 }
8347
8348 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
8349         if ((_res & 1) != 0) return;
8350         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8351         CHECK_ACCESS(_res_ptr);
8352         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
8353         FREE((void*)_res);
8354         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
8355 }
8356
8357 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
8358         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8359         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
8360         return (uint64_t)ret_conv;
8361 }
8362 int64_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
8363         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
8364         int64_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
8365         return ret_val;
8366 }
8367
8368 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
8369         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
8370         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8371         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
8372         return (uint64_t)ret_conv;
8373 }
8374
8375 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
8376         LDKCVec_SignatureZ _res_constr;
8377         _res_constr.datalen = *((uint32_t*)_res);
8378         if (_res_constr.datalen > 0)
8379                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8380         else
8381                 _res_constr.data = NULL;
8382         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
8383         for (size_t m = 0; m < _res_constr.datalen; m++) {
8384                 int8_tArray _res_conv_12 = _res_vals[m];
8385                 LDKSignature _res_conv_12_ref;
8386                 CHECK(*((uint32_t*)_res_conv_12) == 64);
8387                 memcpy(_res_conv_12_ref.compact_form, (uint8_t*)(_res_conv_12 + 4), 64);
8388                 _res_constr.data[m] = _res_conv_12_ref;
8389         }
8390         CVec_SignatureZ_free(_res_constr);
8391 }
8392
8393 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
8394         LDKHolderCommitmentTransaction o_conv;
8395         o_conv.inner = (void*)(o & (~1));
8396         o_conv.is_owned = (o & 1) || (o == 0);
8397         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8398         o_conv = HolderCommitmentTransaction_clone(&o_conv);
8399         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8400         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
8401         return (uint64_t)ret_conv;
8402 }
8403
8404 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
8405         LDKDecodeError e_conv;
8406         e_conv.inner = (void*)(e & (~1));
8407         e_conv.is_owned = (e & 1) || (e == 0);
8408         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8409         e_conv = DecodeError_clone(&e_conv);
8410         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8411         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
8412         return (uint64_t)ret_conv;
8413 }
8414
8415 jboolean  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
8416         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
8417         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
8418         return ret_val;
8419 }
8420
8421 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
8422         if ((_res & 1) != 0) return;
8423         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8424         CHECK_ACCESS(_res_ptr);
8425         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
8426         FREE((void*)_res);
8427         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
8428 }
8429
8430 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
8431         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8432         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
8433         return (uint64_t)ret_conv;
8434 }
8435 int64_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
8436         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
8437         int64_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
8438         return ret_val;
8439 }
8440
8441 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
8442         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
8443         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8444         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
8445         return (uint64_t)ret_conv;
8446 }
8447
8448 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
8449         LDKBuiltCommitmentTransaction o_conv;
8450         o_conv.inner = (void*)(o & (~1));
8451         o_conv.is_owned = (o & 1) || (o == 0);
8452         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8453         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
8454         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8455         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
8456         return (uint64_t)ret_conv;
8457 }
8458
8459 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
8460         LDKDecodeError e_conv;
8461         e_conv.inner = (void*)(e & (~1));
8462         e_conv.is_owned = (e & 1) || (e == 0);
8463         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8464         e_conv = DecodeError_clone(&e_conv);
8465         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8466         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
8467         return (uint64_t)ret_conv;
8468 }
8469
8470 jboolean  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
8471         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
8472         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
8473         return ret_val;
8474 }
8475
8476 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
8477         if ((_res & 1) != 0) return;
8478         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8479         CHECK_ACCESS(_res_ptr);
8480         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
8481         FREE((void*)_res);
8482         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
8483 }
8484
8485 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
8486         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8487         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
8488         return (uint64_t)ret_conv;
8489 }
8490 int64_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
8491         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
8492         int64_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
8493         return ret_val;
8494 }
8495
8496 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
8497         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
8498         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8499         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
8500         return (uint64_t)ret_conv;
8501 }
8502
8503 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
8504         LDKTrustedClosingTransaction o_conv;
8505         o_conv.inner = (void*)(o & (~1));
8506         o_conv.is_owned = (o & 1) || (o == 0);
8507         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8508         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
8509         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
8510         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
8511         return (uint64_t)ret_conv;
8512 }
8513
8514 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
8515         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
8516         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
8517         return (uint64_t)ret_conv;
8518 }
8519
8520 jboolean  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
8521         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
8522         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
8523         return ret_val;
8524 }
8525
8526 void  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
8527         if ((_res & 1) != 0) return;
8528         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8529         CHECK_ACCESS(_res_ptr);
8530         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
8531         FREE((void*)_res);
8532         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
8533 }
8534
8535 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
8536         LDKCommitmentTransaction o_conv;
8537         o_conv.inner = (void*)(o & (~1));
8538         o_conv.is_owned = (o & 1) || (o == 0);
8539         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8540         o_conv = CommitmentTransaction_clone(&o_conv);
8541         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
8542         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
8543         return (uint64_t)ret_conv;
8544 }
8545
8546 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
8547         LDKDecodeError e_conv;
8548         e_conv.inner = (void*)(e & (~1));
8549         e_conv.is_owned = (e & 1) || (e == 0);
8550         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8551         e_conv = DecodeError_clone(&e_conv);
8552         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
8553         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
8554         return (uint64_t)ret_conv;
8555 }
8556
8557 jboolean  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
8558         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
8559         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
8560         return ret_val;
8561 }
8562
8563 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
8564         if ((_res & 1) != 0) return;
8565         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8566         CHECK_ACCESS(_res_ptr);
8567         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
8568         FREE((void*)_res);
8569         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
8570 }
8571
8572 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
8573         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
8574         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
8575         return (uint64_t)ret_conv;
8576 }
8577 int64_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
8578         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
8579         int64_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
8580         return ret_val;
8581 }
8582
8583 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
8584         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
8585         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
8586         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
8587         return (uint64_t)ret_conv;
8588 }
8589
8590 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
8591         LDKTrustedCommitmentTransaction o_conv;
8592         o_conv.inner = (void*)(o & (~1));
8593         o_conv.is_owned = (o & 1) || (o == 0);
8594         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8595         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
8596         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
8597         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
8598         return (uint64_t)ret_conv;
8599 }
8600
8601 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
8602         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
8603         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
8604         return (uint64_t)ret_conv;
8605 }
8606
8607 jboolean  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
8608         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
8609         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
8610         return ret_val;
8611 }
8612
8613 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
8614         if ((_res & 1) != 0) return;
8615         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8616         CHECK_ACCESS(_res_ptr);
8617         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
8618         FREE((void*)_res);
8619         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
8620 }
8621
8622 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
8623         LDKCVec_SignatureZ o_constr;
8624         o_constr.datalen = *((uint32_t*)o);
8625         if (o_constr.datalen > 0)
8626                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8627         else
8628                 o_constr.data = NULL;
8629         int8_tArray* o_vals = (int8_tArray*)(o + 4);
8630         for (size_t m = 0; m < o_constr.datalen; m++) {
8631                 int8_tArray o_conv_12 = o_vals[m];
8632                 LDKSignature o_conv_12_ref;
8633                 CHECK(*((uint32_t*)o_conv_12) == 64);
8634                 memcpy(o_conv_12_ref.compact_form, (uint8_t*)(o_conv_12 + 4), 64);
8635                 o_constr.data[m] = o_conv_12_ref;
8636         }
8637         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
8638         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
8639         return (uint64_t)ret_conv;
8640 }
8641
8642 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
8643         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
8644         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
8645         return (uint64_t)ret_conv;
8646 }
8647
8648 jboolean  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
8649         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
8650         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
8651         return ret_val;
8652 }
8653
8654 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
8655         if ((_res & 1) != 0) return;
8656         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8657         CHECK_ACCESS(_res_ptr);
8658         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
8659         FREE((void*)_res);
8660         CResult_CVec_SignatureZNoneZ_free(_res_conv);
8661 }
8662
8663 static inline uint64_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
8664         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
8665         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
8666         return (uint64_t)ret_conv;
8667 }
8668 int64_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
8669         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
8670         int64_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
8671         return ret_val;
8672 }
8673
8674 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
8675         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
8676         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
8677         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
8678         return (uint64_t)ret_conv;
8679 }
8680
8681 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
8682         LDKShutdownScript o_conv;
8683         o_conv.inner = (void*)(o & (~1));
8684         o_conv.is_owned = (o & 1) || (o == 0);
8685         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8686         o_conv = ShutdownScript_clone(&o_conv);
8687         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
8688         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
8689         return (uint64_t)ret_conv;
8690 }
8691
8692 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
8693         LDKDecodeError e_conv;
8694         e_conv.inner = (void*)(e & (~1));
8695         e_conv.is_owned = (e & 1) || (e == 0);
8696         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8697         e_conv = DecodeError_clone(&e_conv);
8698         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
8699         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
8700         return (uint64_t)ret_conv;
8701 }
8702
8703 jboolean  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
8704         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
8705         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
8706         return ret_val;
8707 }
8708
8709 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
8710         if ((_res & 1) != 0) return;
8711         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8712         CHECK_ACCESS(_res_ptr);
8713         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
8714         FREE((void*)_res);
8715         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
8716 }
8717
8718 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
8719         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
8720         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
8721         return (uint64_t)ret_conv;
8722 }
8723 int64_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
8724         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
8725         int64_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
8726         return ret_val;
8727 }
8728
8729 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
8730         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
8731         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
8732         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
8733         return (uint64_t)ret_conv;
8734 }
8735
8736 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
8737         LDKShutdownScript o_conv;
8738         o_conv.inner = (void*)(o & (~1));
8739         o_conv.is_owned = (o & 1) || (o == 0);
8740         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8741         o_conv = ShutdownScript_clone(&o_conv);
8742         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
8743         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
8744         return (uint64_t)ret_conv;
8745 }
8746
8747 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
8748         LDKInvalidShutdownScript e_conv;
8749         e_conv.inner = (void*)(e & (~1));
8750         e_conv.is_owned = (e & 1) || (e == 0);
8751         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8752         e_conv = InvalidShutdownScript_clone(&e_conv);
8753         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
8754         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
8755         return (uint64_t)ret_conv;
8756 }
8757
8758 jboolean  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
8759         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
8760         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
8761         return ret_val;
8762 }
8763
8764 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
8765         if ((_res & 1) != 0) return;
8766         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8767         CHECK_ACCESS(_res_ptr);
8768         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
8769         FREE((void*)_res);
8770         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
8771 }
8772
8773 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
8774         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
8775         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
8776         return (uint64_t)ret_conv;
8777 }
8778 int64_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
8779         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
8780         int64_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
8781         return ret_val;
8782 }
8783
8784 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
8785         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
8786         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
8787         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
8788         return (uint64_t)ret_conv;
8789 }
8790
8791 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() {
8792         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8793         *ret_conv = CResult_NoneErrorZ_ok();
8794         return (uint64_t)ret_conv;
8795 }
8796
8797 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
8798         LDKIOError e_conv = LDKIOError_from_js(e);
8799         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8800         *ret_conv = CResult_NoneErrorZ_err(e_conv);
8801         return (uint64_t)ret_conv;
8802 }
8803
8804 jboolean  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_is_ok(uint32_t o) {
8805         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
8806         jboolean ret_val = CResult_NoneErrorZ_is_ok(o_conv);
8807         return ret_val;
8808 }
8809
8810 void  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
8811         if ((_res & 1) != 0) return;
8812         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8813         CHECK_ACCESS(_res_ptr);
8814         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
8815         FREE((void*)_res);
8816         CResult_NoneErrorZ_free(_res_conv);
8817 }
8818
8819 static inline uint64_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
8820         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8821         *ret_conv = CResult_NoneErrorZ_clone(arg);
8822         return (uint64_t)ret_conv;
8823 }
8824 int64_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_clone_ptr(uint32_t arg) {
8825         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
8826         int64_t ret_val = CResult_NoneErrorZ_clone_ptr(arg_conv);
8827         return ret_val;
8828 }
8829
8830 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
8831         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
8832         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8833         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
8834         return (uint64_t)ret_conv;
8835 }
8836
8837 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
8838         LDKRouteHop o_conv;
8839         o_conv.inner = (void*)(o & (~1));
8840         o_conv.is_owned = (o & 1) || (o == 0);
8841         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8842         o_conv = RouteHop_clone(&o_conv);
8843         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
8844         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
8845         return (uint64_t)ret_conv;
8846 }
8847
8848 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
8849         LDKDecodeError e_conv;
8850         e_conv.inner = (void*)(e & (~1));
8851         e_conv.is_owned = (e & 1) || (e == 0);
8852         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8853         e_conv = DecodeError_clone(&e_conv);
8854         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
8855         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
8856         return (uint64_t)ret_conv;
8857 }
8858
8859 jboolean  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
8860         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
8861         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
8862         return ret_val;
8863 }
8864
8865 void  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
8866         if ((_res & 1) != 0) return;
8867         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8868         CHECK_ACCESS(_res_ptr);
8869         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
8870         FREE((void*)_res);
8871         CResult_RouteHopDecodeErrorZ_free(_res_conv);
8872 }
8873
8874 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
8875         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
8876         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
8877         return (uint64_t)ret_conv;
8878 }
8879 int64_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
8880         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
8881         int64_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
8882         return ret_val;
8883 }
8884
8885 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
8886         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
8887         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
8888         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
8889         return (uint64_t)ret_conv;
8890 }
8891
8892 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
8893         LDKCVec_RouteHopZ _res_constr;
8894         _res_constr.datalen = *((uint32_t*)_res);
8895         if (_res_constr.datalen > 0)
8896                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8897         else
8898                 _res_constr.data = NULL;
8899         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8900         for (size_t k = 0; k < _res_constr.datalen; k++) {
8901                 uint32_t _res_conv_10 = _res_vals[k];
8902                 LDKRouteHop _res_conv_10_conv;
8903                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
8904                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
8905                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
8906                 _res_constr.data[k] = _res_conv_10_conv;
8907         }
8908         CVec_RouteHopZ_free(_res_constr);
8909 }
8910
8911 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
8912         LDKCVec_CVec_RouteHopZZ _res_constr;
8913         _res_constr.datalen = *((uint32_t*)_res);
8914         if (_res_constr.datalen > 0)
8915                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
8916         else
8917                 _res_constr.data = NULL;
8918         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
8919         for (size_t m = 0; m < _res_constr.datalen; m++) {
8920                 uint32_tArray _res_conv_12 = _res_vals[m];
8921                 LDKCVec_RouteHopZ _res_conv_12_constr;
8922                 _res_conv_12_constr.datalen = *((uint32_t*)_res_conv_12);
8923                 if (_res_conv_12_constr.datalen > 0)
8924                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8925                 else
8926                         _res_conv_12_constr.data = NULL;
8927                 uint32_t* _res_conv_12_vals = (uint32_t*)(_res_conv_12 + 4);
8928                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
8929                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
8930                         LDKRouteHop _res_conv_12_conv_10_conv;
8931                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
8932                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
8933                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
8934                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
8935                 }
8936                 _res_constr.data[m] = _res_conv_12_constr;
8937         }
8938         CVec_CVec_RouteHopZZ_free(_res_constr);
8939 }
8940
8941 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
8942         LDKRoute o_conv;
8943         o_conv.inner = (void*)(o & (~1));
8944         o_conv.is_owned = (o & 1) || (o == 0);
8945         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8946         o_conv = Route_clone(&o_conv);
8947         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
8948         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
8949         return (uint64_t)ret_conv;
8950 }
8951
8952 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
8953         LDKDecodeError e_conv;
8954         e_conv.inner = (void*)(e & (~1));
8955         e_conv.is_owned = (e & 1) || (e == 0);
8956         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8957         e_conv = DecodeError_clone(&e_conv);
8958         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
8959         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
8960         return (uint64_t)ret_conv;
8961 }
8962
8963 jboolean  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
8964         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
8965         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
8966         return ret_val;
8967 }
8968
8969 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
8970         if ((_res & 1) != 0) return;
8971         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8972         CHECK_ACCESS(_res_ptr);
8973         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
8974         FREE((void*)_res);
8975         CResult_RouteDecodeErrorZ_free(_res_conv);
8976 }
8977
8978 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
8979         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
8980         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
8981         return (uint64_t)ret_conv;
8982 }
8983 int64_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
8984         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
8985         int64_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
8986         return ret_val;
8987 }
8988
8989 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
8990         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
8991         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
8992         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
8993         return (uint64_t)ret_conv;
8994 }
8995
8996 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
8997         LDKRouteParameters o_conv;
8998         o_conv.inner = (void*)(o & (~1));
8999         o_conv.is_owned = (o & 1) || (o == 0);
9000         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9001         o_conv = RouteParameters_clone(&o_conv);
9002         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
9003         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
9004         return (uint64_t)ret_conv;
9005 }
9006
9007 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
9008         LDKDecodeError e_conv;
9009         e_conv.inner = (void*)(e & (~1));
9010         e_conv.is_owned = (e & 1) || (e == 0);
9011         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9012         e_conv = DecodeError_clone(&e_conv);
9013         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
9014         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
9015         return (uint64_t)ret_conv;
9016 }
9017
9018 jboolean  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
9019         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
9020         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
9021         return ret_val;
9022 }
9023
9024 void  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
9025         if ((_res & 1) != 0) return;
9026         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9027         CHECK_ACCESS(_res_ptr);
9028         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
9029         FREE((void*)_res);
9030         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
9031 }
9032
9033 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
9034         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
9035         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
9036         return (uint64_t)ret_conv;
9037 }
9038 int64_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
9039         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
9040         int64_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
9041         return ret_val;
9042 }
9043
9044 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
9045         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
9046         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
9047         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
9048         return (uint64_t)ret_conv;
9049 }
9050
9051 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
9052         LDKCVec_RouteHintZ _res_constr;
9053         _res_constr.datalen = *((uint32_t*)_res);
9054         if (_res_constr.datalen > 0)
9055                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
9056         else
9057                 _res_constr.data = NULL;
9058         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9059         for (size_t l = 0; l < _res_constr.datalen; l++) {
9060                 uint32_t _res_conv_11 = _res_vals[l];
9061                 LDKRouteHint _res_conv_11_conv;
9062                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
9063                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
9064                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
9065                 _res_constr.data[l] = _res_conv_11_conv;
9066         }
9067         CVec_RouteHintZ_free(_res_constr);
9068 }
9069
9070 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_some(int64_t o) {
9071         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9072         *ret_copy = COption_u64Z_some(o);
9073         uint64_t ret_ref = (uint64_t)ret_copy;
9074         return ret_ref;
9075 }
9076
9077 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_none() {
9078         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9079         *ret_copy = COption_u64Z_none();
9080         uint64_t ret_ref = (uint64_t)ret_copy;
9081         return ret_ref;
9082 }
9083
9084 void  __attribute__((visibility("default"))) TS_COption_u64Z_free(uint32_t _res) {
9085         if ((_res & 1) != 0) return;
9086         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9087         CHECK_ACCESS(_res_ptr);
9088         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
9089         FREE((void*)_res);
9090         COption_u64Z_free(_res_conv);
9091 }
9092
9093 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
9094         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9095         *ret_copy = COption_u64Z_clone(arg);
9096 uint64_t ret_ref = (uint64_t)ret_copy;
9097         return ret_ref;
9098 }
9099 int64_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
9100         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
9101         int64_t ret_val = COption_u64Z_clone_ptr(arg_conv);
9102         return ret_val;
9103 }
9104
9105 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone(uint32_t orig) {
9106         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
9107         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9108         *ret_copy = COption_u64Z_clone(orig_conv);
9109         uint64_t ret_ref = (uint64_t)ret_copy;
9110         return ret_ref;
9111 }
9112
9113 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_ok(uint32_t o) {
9114         LDKPayee o_conv;
9115         o_conv.inner = (void*)(o & (~1));
9116         o_conv.is_owned = (o & 1) || (o == 0);
9117         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9118         o_conv = Payee_clone(&o_conv);
9119         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
9120         *ret_conv = CResult_PayeeDecodeErrorZ_ok(o_conv);
9121         return (uint64_t)ret_conv;
9122 }
9123
9124 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_err(uint32_t e) {
9125         LDKDecodeError e_conv;
9126         e_conv.inner = (void*)(e & (~1));
9127         e_conv.is_owned = (e & 1) || (e == 0);
9128         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9129         e_conv = DecodeError_clone(&e_conv);
9130         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
9131         *ret_conv = CResult_PayeeDecodeErrorZ_err(e_conv);
9132         return (uint64_t)ret_conv;
9133 }
9134
9135 jboolean  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_is_ok(uint32_t o) {
9136         LDKCResult_PayeeDecodeErrorZ* o_conv = (LDKCResult_PayeeDecodeErrorZ*)(o & ~1);
9137         jboolean ret_val = CResult_PayeeDecodeErrorZ_is_ok(o_conv);
9138         return ret_val;
9139 }
9140
9141 void  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_free(uint32_t _res) {
9142         if ((_res & 1) != 0) return;
9143         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9144         CHECK_ACCESS(_res_ptr);
9145         LDKCResult_PayeeDecodeErrorZ _res_conv = *(LDKCResult_PayeeDecodeErrorZ*)(_res_ptr);
9146         FREE((void*)_res);
9147         CResult_PayeeDecodeErrorZ_free(_res_conv);
9148 }
9149
9150 static inline uint64_t CResult_PayeeDecodeErrorZ_clone_ptr(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR arg) {
9151         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
9152         *ret_conv = CResult_PayeeDecodeErrorZ_clone(arg);
9153         return (uint64_t)ret_conv;
9154 }
9155 int64_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_clone_ptr(uint32_t arg) {
9156         LDKCResult_PayeeDecodeErrorZ* arg_conv = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
9157         int64_t ret_val = CResult_PayeeDecodeErrorZ_clone_ptr(arg_conv);
9158         return ret_val;
9159 }
9160
9161 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_clone(uint32_t orig) {
9162         LDKCResult_PayeeDecodeErrorZ* orig_conv = (LDKCResult_PayeeDecodeErrorZ*)(orig & ~1);
9163         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
9164         *ret_conv = CResult_PayeeDecodeErrorZ_clone(orig_conv);
9165         return (uint64_t)ret_conv;
9166 }
9167
9168 void  __attribute__((visibility("default"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
9169         LDKCVec_RouteHintHopZ _res_constr;
9170         _res_constr.datalen = *((uint32_t*)_res);
9171         if (_res_constr.datalen > 0)
9172                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
9173         else
9174                 _res_constr.data = NULL;
9175         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9176         for (size_t o = 0; o < _res_constr.datalen; o++) {
9177                 uint32_t _res_conv_14 = _res_vals[o];
9178                 LDKRouteHintHop _res_conv_14_conv;
9179                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
9180                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
9181                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
9182                 _res_constr.data[o] = _res_conv_14_conv;
9183         }
9184         CVec_RouteHintHopZ_free(_res_constr);
9185 }
9186
9187 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
9188         LDKRouteHint o_conv;
9189         o_conv.inner = (void*)(o & (~1));
9190         o_conv.is_owned = (o & 1) || (o == 0);
9191         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9192         o_conv = RouteHint_clone(&o_conv);
9193         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
9194         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
9195         return (uint64_t)ret_conv;
9196 }
9197
9198 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
9199         LDKDecodeError e_conv;
9200         e_conv.inner = (void*)(e & (~1));
9201         e_conv.is_owned = (e & 1) || (e == 0);
9202         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9203         e_conv = DecodeError_clone(&e_conv);
9204         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
9205         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
9206         return (uint64_t)ret_conv;
9207 }
9208
9209 jboolean  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
9210         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
9211         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
9212         return ret_val;
9213 }
9214
9215 void  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
9216         if ((_res & 1) != 0) return;
9217         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9218         CHECK_ACCESS(_res_ptr);
9219         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
9220         FREE((void*)_res);
9221         CResult_RouteHintDecodeErrorZ_free(_res_conv);
9222 }
9223
9224 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
9225         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
9226         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
9227         return (uint64_t)ret_conv;
9228 }
9229 int64_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
9230         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
9231         int64_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
9232         return ret_val;
9233 }
9234
9235 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
9236         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
9237         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
9238         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
9239         return (uint64_t)ret_conv;
9240 }
9241
9242 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
9243         LDKRouteHintHop o_conv;
9244         o_conv.inner = (void*)(o & (~1));
9245         o_conv.is_owned = (o & 1) || (o == 0);
9246         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9247         o_conv = RouteHintHop_clone(&o_conv);
9248         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
9249         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
9250         return (uint64_t)ret_conv;
9251 }
9252
9253 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
9254         LDKDecodeError e_conv;
9255         e_conv.inner = (void*)(e & (~1));
9256         e_conv.is_owned = (e & 1) || (e == 0);
9257         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9258         e_conv = DecodeError_clone(&e_conv);
9259         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
9260         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
9261         return (uint64_t)ret_conv;
9262 }
9263
9264 jboolean  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
9265         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
9266         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
9267         return ret_val;
9268 }
9269
9270 void  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
9271         if ((_res & 1) != 0) return;
9272         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9273         CHECK_ACCESS(_res_ptr);
9274         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
9275         FREE((void*)_res);
9276         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
9277 }
9278
9279 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
9280         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
9281         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
9282         return (uint64_t)ret_conv;
9283 }
9284 int64_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
9285         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
9286         int64_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
9287         return ret_val;
9288 }
9289
9290 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
9291         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
9292         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
9293         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
9294         return (uint64_t)ret_conv;
9295 }
9296
9297 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
9298         LDKCVec_ChannelDetailsZ _res_constr;
9299         _res_constr.datalen = *((uint32_t*)_res);
9300         if (_res_constr.datalen > 0)
9301                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
9302         else
9303                 _res_constr.data = NULL;
9304         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9305         for (size_t q = 0; q < _res_constr.datalen; q++) {
9306                 uint32_t _res_conv_16 = _res_vals[q];
9307                 LDKChannelDetails _res_conv_16_conv;
9308                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9309                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9310                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
9311                 _res_constr.data[q] = _res_conv_16_conv;
9312         }
9313         CVec_ChannelDetailsZ_free(_res_constr);
9314 }
9315
9316 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
9317         LDKRoute o_conv;
9318         o_conv.inner = (void*)(o & (~1));
9319         o_conv.is_owned = (o & 1) || (o == 0);
9320         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9321         o_conv = Route_clone(&o_conv);
9322         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9323         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
9324         return (uint64_t)ret_conv;
9325 }
9326
9327 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
9328         LDKLightningError e_conv;
9329         e_conv.inner = (void*)(e & (~1));
9330         e_conv.is_owned = (e & 1) || (e == 0);
9331         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9332         e_conv = LightningError_clone(&e_conv);
9333         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9334         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
9335         return (uint64_t)ret_conv;
9336 }
9337
9338 jboolean  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
9339         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
9340         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
9341         return ret_val;
9342 }
9343
9344 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
9345         if ((_res & 1) != 0) return;
9346         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9347         CHECK_ACCESS(_res_ptr);
9348         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
9349         FREE((void*)_res);
9350         CResult_RouteLightningErrorZ_free(_res_conv);
9351 }
9352
9353 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
9354         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9355         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
9356         return (uint64_t)ret_conv;
9357 }
9358 int64_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
9359         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
9360         int64_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
9361         return ret_val;
9362 }
9363
9364 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
9365         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
9366         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9367         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
9368         return (uint64_t)ret_conv;
9369 }
9370
9371 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
9372         void* o_ptr = (void*)(((uint64_t)o) & ~1);
9373         CHECK_ACCESS(o_ptr);
9374         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
9375         o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1));
9376         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9377         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
9378         return (uint64_t)ret_conv;
9379 }
9380
9381 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
9382         LDKAccessError e_conv = LDKAccessError_from_js(e);
9383         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9384         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
9385         return (uint64_t)ret_conv;
9386 }
9387
9388 jboolean  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
9389         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
9390         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
9391         return ret_val;
9392 }
9393
9394 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
9395         if ((_res & 1) != 0) return;
9396         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9397         CHECK_ACCESS(_res_ptr);
9398         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
9399         FREE((void*)_res);
9400         CResult_TxOutAccessErrorZ_free(_res_conv);
9401 }
9402
9403 static inline uint64_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
9404         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9405         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
9406         return (uint64_t)ret_conv;
9407 }
9408 int64_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
9409         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
9410         int64_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
9411         return ret_val;
9412 }
9413
9414 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
9415         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
9416         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9417         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
9418         return (uint64_t)ret_conv;
9419 }
9420
9421 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
9422         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9423         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
9424         return ((uint64_t)ret_conv);
9425 }
9426 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
9427         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
9428         int64_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
9429         return ret_val;
9430 }
9431
9432 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
9433         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
9434         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9435         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
9436         return ((uint64_t)ret_conv);
9437 }
9438
9439 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
9440         LDKTransaction b_ref;
9441         b_ref.datalen = *((uint32_t*)b);
9442         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
9443         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
9444         b_ref.data_is_owned = true;
9445         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9446         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
9447         return ((uint64_t)ret_conv);
9448 }
9449
9450 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
9451         if ((_res & 1) != 0) return;
9452         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9453         CHECK_ACCESS(_res_ptr);
9454         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
9455         FREE((void*)_res);
9456         C2Tuple_usizeTransactionZ_free(_res_conv);
9457 }
9458
9459 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
9460         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
9461         _res_constr.datalen = *((uint32_t*)_res);
9462         if (_res_constr.datalen > 0)
9463                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9464         else
9465                 _res_constr.data = NULL;
9466         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9467         for (size_t c = 0; c < _res_constr.datalen; c++) {
9468                 uint32_t _res_conv_28 = _res_vals[c];
9469                 void* _res_conv_28_ptr = (void*)(((uint64_t)_res_conv_28) & ~1);
9470                 CHECK_ACCESS(_res_conv_28_ptr);
9471                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
9472                 FREE((void*)_res_conv_28);
9473                 _res_constr.data[c] = _res_conv_28_conv;
9474         }
9475         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
9476 }
9477
9478 void  __attribute__((visibility("default"))) TS_CVec_TxidZ_free(ptrArray _res) {
9479         LDKCVec_TxidZ _res_constr;
9480         _res_constr.datalen = *((uint32_t*)_res);
9481         if (_res_constr.datalen > 0)
9482                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9483         else
9484                 _res_constr.data = NULL;
9485         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
9486         for (size_t m = 0; m < _res_constr.datalen; m++) {
9487                 int8_tArray _res_conv_12 = _res_vals[m];
9488                 LDKThirtyTwoBytes _res_conv_12_ref;
9489                 CHECK(*((uint32_t*)_res_conv_12) == 32);
9490                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), 32);
9491                 _res_constr.data[m] = _res_conv_12_ref;
9492         }
9493         CVec_TxidZ_free(_res_constr);
9494 }
9495
9496 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
9497         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9498         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
9499         return (uint64_t)ret_conv;
9500 }
9501
9502 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
9503         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
9504         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9505         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
9506         return (uint64_t)ret_conv;
9507 }
9508
9509 jboolean  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
9510         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
9511         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
9512         return ret_val;
9513 }
9514
9515 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
9516         if ((_res & 1) != 0) return;
9517         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9518         CHECK_ACCESS(_res_ptr);
9519         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
9520         FREE((void*)_res);
9521         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
9522 }
9523
9524 static inline uint64_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
9525         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9526         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
9527         return (uint64_t)ret_conv;
9528 }
9529 int64_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
9530         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
9531         int64_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
9532         return ret_val;
9533 }
9534
9535 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
9536         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
9537         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9538         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
9539         return (uint64_t)ret_conv;
9540 }
9541
9542 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
9543         LDKCVec_MonitorEventZ _res_constr;
9544         _res_constr.datalen = *((uint32_t*)_res);
9545         if (_res_constr.datalen > 0)
9546                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
9547         else
9548                 _res_constr.data = NULL;
9549         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9550         for (size_t o = 0; o < _res_constr.datalen; o++) {
9551                 uint32_t _res_conv_14 = _res_vals[o];
9552                 void* _res_conv_14_ptr = (void*)(((uint64_t)_res_conv_14) & ~1);
9553                 CHECK_ACCESS(_res_conv_14_ptr);
9554                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
9555                 FREE((void*)_res_conv_14);
9556                 _res_constr.data[o] = _res_conv_14_conv;
9557         }
9558         CVec_MonitorEventZ_free(_res_constr);
9559 }
9560
9561 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
9562         void* o_ptr = (void*)(((uint64_t)o) & ~1);
9563         CHECK_ACCESS(o_ptr);
9564         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
9565         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1));
9566         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9567         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
9568         uint64_t ret_ref = (uint64_t)ret_copy;
9569         return ret_ref;
9570 }
9571
9572 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
9573         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9574         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
9575         uint64_t ret_ref = (uint64_t)ret_copy;
9576         return ret_ref;
9577 }
9578
9579 void  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
9580         if ((_res & 1) != 0) return;
9581         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9582         CHECK_ACCESS(_res_ptr);
9583         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
9584         FREE((void*)_res);
9585         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
9586 }
9587
9588 static inline uint64_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
9589         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9590         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
9591 uint64_t ret_ref = (uint64_t)ret_copy;
9592         return ret_ref;
9593 }
9594 int64_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
9595         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
9596         int64_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
9597         return ret_val;
9598 }
9599
9600 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
9601         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
9602         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9603         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
9604         uint64_t ret_ref = (uint64_t)ret_copy;
9605         return ret_ref;
9606 }
9607
9608 uint32_t  __attribute__((visibility("default"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
9609         void* o_ptr = (void*)(((uint64_t)o) & ~1);
9610         CHECK_ACCESS(o_ptr);
9611         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
9612         o_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)o) & ~1));
9613         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
9614         *ret_copy = COption_ClosureReasonZ_some(o_conv);
9615         uint64_t ret_ref = (uint64_t)ret_copy;
9616         return ret_ref;
9617 }
9618
9619 uint32_t  __attribute__((visibility("default"))) TS_COption_ClosureReasonZ_none() {
9620         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
9621         *ret_copy = COption_ClosureReasonZ_none();
9622         uint64_t ret_ref = (uint64_t)ret_copy;
9623         return ret_ref;
9624 }
9625
9626 void  __attribute__((visibility("default"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
9627         if ((_res & 1) != 0) return;
9628         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9629         CHECK_ACCESS(_res_ptr);
9630         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
9631         FREE((void*)_res);
9632         COption_ClosureReasonZ_free(_res_conv);
9633 }
9634
9635 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
9636         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
9637         *ret_copy = COption_ClosureReasonZ_clone(arg);
9638 uint64_t ret_ref = (uint64_t)ret_copy;
9639         return ret_ref;
9640 }
9641 int64_t  __attribute__((visibility("default"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
9642         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
9643         int64_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
9644         return ret_val;
9645 }
9646
9647 uint32_t  __attribute__((visibility("default"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
9648         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
9649         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
9650         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
9651         uint64_t ret_ref = (uint64_t)ret_copy;
9652         return ret_ref;
9653 }
9654
9655 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
9656         void* o_ptr = (void*)(((uint64_t)o) & ~1);
9657         CHECK_ACCESS(o_ptr);
9658         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
9659         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uint64_t)o) & ~1));
9660         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
9661         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
9662         return (uint64_t)ret_conv;
9663 }
9664
9665 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
9666         LDKDecodeError e_conv;
9667         e_conv.inner = (void*)(e & (~1));
9668         e_conv.is_owned = (e & 1) || (e == 0);
9669         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9670         e_conv = DecodeError_clone(&e_conv);
9671         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
9672         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
9673         return (uint64_t)ret_conv;
9674 }
9675
9676 jboolean  __attribute__((visibility("default"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
9677         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
9678         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
9679         return ret_val;
9680 }
9681
9682 void  __attribute__((visibility("default"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
9683         if ((_res & 1) != 0) return;
9684         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9685         CHECK_ACCESS(_res_ptr);
9686         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
9687         FREE((void*)_res);
9688         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
9689 }
9690
9691 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
9692         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
9693         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
9694         return (uint64_t)ret_conv;
9695 }
9696 int64_t  __attribute__((visibility("default"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
9697         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
9698         int64_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
9699         return ret_val;
9700 }
9701
9702 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
9703         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
9704         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
9705         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
9706         return (uint64_t)ret_conv;
9707 }
9708
9709 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
9710         void* o_ptr = (void*)(((uint64_t)o) & ~1);
9711         CHECK_ACCESS(o_ptr);
9712         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
9713         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1));
9714         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
9715         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
9716         uint64_t ret_ref = (uint64_t)ret_copy;
9717         return ret_ref;
9718 }
9719
9720 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_none() {
9721         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
9722         *ret_copy = COption_NetworkUpdateZ_none();
9723         uint64_t ret_ref = (uint64_t)ret_copy;
9724         return ret_ref;
9725 }
9726
9727 void  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
9728         if ((_res & 1) != 0) return;
9729         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9730         CHECK_ACCESS(_res_ptr);
9731         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
9732         FREE((void*)_res);
9733         COption_NetworkUpdateZ_free(_res_conv);
9734 }
9735
9736 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
9737         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
9738         *ret_copy = COption_NetworkUpdateZ_clone(arg);
9739 uint64_t ret_ref = (uint64_t)ret_copy;
9740         return ret_ref;
9741 }
9742 int64_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
9743         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
9744         int64_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
9745         return ret_val;
9746 }
9747
9748 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
9749         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
9750         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
9751         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
9752         uint64_t ret_ref = (uint64_t)ret_copy;
9753         return ret_ref;
9754 }
9755
9756 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
9757         LDKCVec_SpendableOutputDescriptorZ _res_constr;
9758         _res_constr.datalen = *((uint32_t*)_res);
9759         if (_res_constr.datalen > 0)
9760                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
9761         else
9762                 _res_constr.data = NULL;
9763         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9764         for (size_t b = 0; b < _res_constr.datalen; b++) {
9765                 uint32_t _res_conv_27 = _res_vals[b];
9766                 void* _res_conv_27_ptr = (void*)(((uint64_t)_res_conv_27) & ~1);
9767                 CHECK_ACCESS(_res_conv_27_ptr);
9768                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
9769                 FREE((void*)_res_conv_27);
9770                 _res_constr.data[b] = _res_conv_27_conv;
9771         }
9772         CVec_SpendableOutputDescriptorZ_free(_res_constr);
9773 }
9774
9775 uint32_t  __attribute__((visibility("default"))) TS_COption_EventZ_some(uint32_t o) {
9776         void* o_ptr = (void*)(((uint64_t)o) & ~1);
9777         CHECK_ACCESS(o_ptr);
9778         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
9779         o_conv = Event_clone((LDKEvent*)(((uint64_t)o) & ~1));
9780         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
9781         *ret_copy = COption_EventZ_some(o_conv);
9782         uint64_t ret_ref = (uint64_t)ret_copy;
9783         return ret_ref;
9784 }
9785
9786 uint32_t  __attribute__((visibility("default"))) TS_COption_EventZ_none() {
9787         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
9788         *ret_copy = COption_EventZ_none();
9789         uint64_t ret_ref = (uint64_t)ret_copy;
9790         return ret_ref;
9791 }
9792
9793 void  __attribute__((visibility("default"))) TS_COption_EventZ_free(uint32_t _res) {
9794         if ((_res & 1) != 0) return;
9795         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9796         CHECK_ACCESS(_res_ptr);
9797         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
9798         FREE((void*)_res);
9799         COption_EventZ_free(_res_conv);
9800 }
9801
9802 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
9803         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
9804         *ret_copy = COption_EventZ_clone(arg);
9805 uint64_t ret_ref = (uint64_t)ret_copy;
9806         return ret_ref;
9807 }
9808 int64_t  __attribute__((visibility("default"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
9809         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
9810         int64_t ret_val = COption_EventZ_clone_ptr(arg_conv);
9811         return ret_val;
9812 }
9813
9814 uint32_t  __attribute__((visibility("default"))) TS_COption_EventZ_clone(uint32_t orig) {
9815         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
9816         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
9817         *ret_copy = COption_EventZ_clone(orig_conv);
9818         uint64_t ret_ref = (uint64_t)ret_copy;
9819         return ret_ref;
9820 }
9821
9822 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
9823         void* o_ptr = (void*)(((uint64_t)o) & ~1);
9824         CHECK_ACCESS(o_ptr);
9825         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
9826         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uint64_t)o) & ~1));
9827         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
9828         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
9829         return (uint64_t)ret_conv;
9830 }
9831
9832 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
9833         LDKDecodeError e_conv;
9834         e_conv.inner = (void*)(e & (~1));
9835         e_conv.is_owned = (e & 1) || (e == 0);
9836         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9837         e_conv = DecodeError_clone(&e_conv);
9838         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
9839         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
9840         return (uint64_t)ret_conv;
9841 }
9842
9843 jboolean  __attribute__((visibility("default"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
9844         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
9845         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
9846         return ret_val;
9847 }
9848
9849 void  __attribute__((visibility("default"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
9850         if ((_res & 1) != 0) return;
9851         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9852         CHECK_ACCESS(_res_ptr);
9853         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
9854         FREE((void*)_res);
9855         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
9856 }
9857
9858 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
9859         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
9860         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
9861         return (uint64_t)ret_conv;
9862 }
9863 int64_t  __attribute__((visibility("default"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
9864         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
9865         int64_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
9866         return ret_val;
9867 }
9868
9869 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
9870         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
9871         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
9872         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
9873         return (uint64_t)ret_conv;
9874 }
9875
9876 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
9877         LDKCVec_MessageSendEventZ _res_constr;
9878         _res_constr.datalen = *((uint32_t*)_res);
9879         if (_res_constr.datalen > 0)
9880                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
9881         else
9882                 _res_constr.data = NULL;
9883         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9884         for (size_t s = 0; s < _res_constr.datalen; s++) {
9885                 uint32_t _res_conv_18 = _res_vals[s];
9886                 void* _res_conv_18_ptr = (void*)(((uint64_t)_res_conv_18) & ~1);
9887                 CHECK_ACCESS(_res_conv_18_ptr);
9888                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
9889                 FREE((void*)_res_conv_18);
9890                 _res_constr.data[s] = _res_conv_18_conv;
9891         }
9892         CVec_MessageSendEventZ_free(_res_constr);
9893 }
9894
9895 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
9896         LDKInitFeatures o_conv;
9897         o_conv.inner = (void*)(o & (~1));
9898         o_conv.is_owned = (o & 1) || (o == 0);
9899         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9900         o_conv = InitFeatures_clone(&o_conv);
9901         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9902         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
9903         return (uint64_t)ret_conv;
9904 }
9905
9906 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
9907         LDKDecodeError e_conv;
9908         e_conv.inner = (void*)(e & (~1));
9909         e_conv.is_owned = (e & 1) || (e == 0);
9910         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9911         e_conv = DecodeError_clone(&e_conv);
9912         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9913         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
9914         return (uint64_t)ret_conv;
9915 }
9916
9917 jboolean  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
9918         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
9919         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
9920         return ret_val;
9921 }
9922
9923 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
9924         if ((_res & 1) != 0) return;
9925         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9926         CHECK_ACCESS(_res_ptr);
9927         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
9928         FREE((void*)_res);
9929         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
9930 }
9931
9932 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
9933         LDKNodeFeatures o_conv;
9934         o_conv.inner = (void*)(o & (~1));
9935         o_conv.is_owned = (o & 1) || (o == 0);
9936         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9937         o_conv = NodeFeatures_clone(&o_conv);
9938         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9939         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
9940         return (uint64_t)ret_conv;
9941 }
9942
9943 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
9944         LDKDecodeError e_conv;
9945         e_conv.inner = (void*)(e & (~1));
9946         e_conv.is_owned = (e & 1) || (e == 0);
9947         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9948         e_conv = DecodeError_clone(&e_conv);
9949         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9950         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
9951         return (uint64_t)ret_conv;
9952 }
9953
9954 jboolean  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
9955         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
9956         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
9957         return ret_val;
9958 }
9959
9960 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
9961         if ((_res & 1) != 0) return;
9962         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9963         CHECK_ACCESS(_res_ptr);
9964         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
9965         FREE((void*)_res);
9966         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
9967 }
9968
9969 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
9970         LDKChannelFeatures o_conv;
9971         o_conv.inner = (void*)(o & (~1));
9972         o_conv.is_owned = (o & 1) || (o == 0);
9973         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9974         o_conv = ChannelFeatures_clone(&o_conv);
9975         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9976         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
9977         return (uint64_t)ret_conv;
9978 }
9979
9980 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
9981         LDKDecodeError e_conv;
9982         e_conv.inner = (void*)(e & (~1));
9983         e_conv.is_owned = (e & 1) || (e == 0);
9984         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9985         e_conv = DecodeError_clone(&e_conv);
9986         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9987         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
9988         return (uint64_t)ret_conv;
9989 }
9990
9991 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
9992         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
9993         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
9994         return ret_val;
9995 }
9996
9997 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
9998         if ((_res & 1) != 0) return;
9999         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10000         CHECK_ACCESS(_res_ptr);
10001         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
10002         FREE((void*)_res);
10003         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
10004 }
10005
10006 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
10007         LDKInvoiceFeatures o_conv;
10008         o_conv.inner = (void*)(o & (~1));
10009         o_conv.is_owned = (o & 1) || (o == 0);
10010         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10011         o_conv = InvoiceFeatures_clone(&o_conv);
10012         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
10013         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
10014         return (uint64_t)ret_conv;
10015 }
10016
10017 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
10018         LDKDecodeError e_conv;
10019         e_conv.inner = (void*)(e & (~1));
10020         e_conv.is_owned = (e & 1) || (e == 0);
10021         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10022         e_conv = DecodeError_clone(&e_conv);
10023         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
10024         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
10025         return (uint64_t)ret_conv;
10026 }
10027
10028 jboolean  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
10029         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
10030         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
10031         return ret_val;
10032 }
10033
10034 void  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
10035         if ((_res & 1) != 0) return;
10036         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10037         CHECK_ACCESS(_res_ptr);
10038         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
10039         FREE((void*)_res);
10040         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
10041 }
10042
10043 uint32_t  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_ok(uint32_t o) {
10044         LDKScoringParameters o_conv;
10045         o_conv.inner = (void*)(o & (~1));
10046         o_conv.is_owned = (o & 1) || (o == 0);
10047         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10048         // Warning: we need a move here but no clone is available for LDKScoringParameters
10049         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
10050         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
10051         return (uint64_t)ret_conv;
10052 }
10053
10054 uint32_t  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_err(uint32_t e) {
10055         LDKDecodeError e_conv;
10056         e_conv.inner = (void*)(e & (~1));
10057         e_conv.is_owned = (e & 1) || (e == 0);
10058         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10059         e_conv = DecodeError_clone(&e_conv);
10060         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
10061         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
10062         return (uint64_t)ret_conv;
10063 }
10064
10065 jboolean  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_is_ok(uint32_t o) {
10066         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
10067         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
10068         return ret_val;
10069 }
10070
10071 void  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_free(uint32_t _res) {
10072         if ((_res & 1) != 0) return;
10073         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10074         CHECK_ACCESS(_res_ptr);
10075         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
10076         FREE((void*)_res);
10077         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
10078 }
10079
10080 uint32_t  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_ok(uint32_t o) {
10081         LDKScorer o_conv;
10082         o_conv.inner = (void*)(o & (~1));
10083         o_conv.is_owned = (o & 1) || (o == 0);
10084         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10085         // Warning: we need a move here but no clone is available for LDKScorer
10086         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
10087         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
10088         return (uint64_t)ret_conv;
10089 }
10090
10091 uint32_t  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_err(uint32_t e) {
10092         LDKDecodeError e_conv;
10093         e_conv.inner = (void*)(e & (~1));
10094         e_conv.is_owned = (e & 1) || (e == 0);
10095         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10096         e_conv = DecodeError_clone(&e_conv);
10097         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
10098         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
10099         return (uint64_t)ret_conv;
10100 }
10101
10102 jboolean  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_is_ok(uint32_t o) {
10103         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
10104         jboolean ret_val = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
10105         return ret_val;
10106 }
10107
10108 void  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_free(uint32_t _res) {
10109         if ((_res & 1) != 0) return;
10110         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10111         CHECK_ACCESS(_res_ptr);
10112         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
10113         FREE((void*)_res);
10114         CResult_ScorerDecodeErrorZ_free(_res_conv);
10115 }
10116
10117 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
10118         LDKDelayedPaymentOutputDescriptor o_conv;
10119         o_conv.inner = (void*)(o & (~1));
10120         o_conv.is_owned = (o & 1) || (o == 0);
10121         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10122         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
10123         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10124         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10125         return (uint64_t)ret_conv;
10126 }
10127
10128 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
10129         LDKDecodeError e_conv;
10130         e_conv.inner = (void*)(e & (~1));
10131         e_conv.is_owned = (e & 1) || (e == 0);
10132         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10133         e_conv = DecodeError_clone(&e_conv);
10134         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10135         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10136         return (uint64_t)ret_conv;
10137 }
10138
10139 jboolean  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
10140         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
10141         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
10142         return ret_val;
10143 }
10144
10145 void  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
10146         if ((_res & 1) != 0) return;
10147         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10148         CHECK_ACCESS(_res_ptr);
10149         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
10150         FREE((void*)_res);
10151         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10152 }
10153
10154 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
10155         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10156         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
10157         return (uint64_t)ret_conv;
10158 }
10159 int64_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
10160         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
10161         int64_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
10162         return ret_val;
10163 }
10164
10165 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
10166         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10167         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10168         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10169         return (uint64_t)ret_conv;
10170 }
10171
10172 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
10173         LDKStaticPaymentOutputDescriptor o_conv;
10174         o_conv.inner = (void*)(o & (~1));
10175         o_conv.is_owned = (o & 1) || (o == 0);
10176         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10177         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
10178         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10179         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10180         return (uint64_t)ret_conv;
10181 }
10182
10183 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
10184         LDKDecodeError e_conv;
10185         e_conv.inner = (void*)(e & (~1));
10186         e_conv.is_owned = (e & 1) || (e == 0);
10187         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10188         e_conv = DecodeError_clone(&e_conv);
10189         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10190         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10191         return (uint64_t)ret_conv;
10192 }
10193
10194 jboolean  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
10195         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
10196         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
10197         return ret_val;
10198 }
10199
10200 void  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
10201         if ((_res & 1) != 0) return;
10202         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10203         CHECK_ACCESS(_res_ptr);
10204         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
10205         FREE((void*)_res);
10206         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10207 }
10208
10209 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
10210         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10211         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
10212         return (uint64_t)ret_conv;
10213 }
10214 int64_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
10215         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
10216         int64_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
10217         return ret_val;
10218 }
10219
10220 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
10221         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10222         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10223         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10224         return (uint64_t)ret_conv;
10225 }
10226
10227 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
10228         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10229         CHECK_ACCESS(o_ptr);
10230         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
10231         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1));
10232         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10233         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
10234         return (uint64_t)ret_conv;
10235 }
10236
10237 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
10238         LDKDecodeError e_conv;
10239         e_conv.inner = (void*)(e & (~1));
10240         e_conv.is_owned = (e & 1) || (e == 0);
10241         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10242         e_conv = DecodeError_clone(&e_conv);
10243         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10244         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
10245         return (uint64_t)ret_conv;
10246 }
10247
10248 jboolean  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
10249         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
10250         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
10251         return ret_val;
10252 }
10253
10254 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
10255         if ((_res & 1) != 0) return;
10256         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10257         CHECK_ACCESS(_res_ptr);
10258         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
10259         FREE((void*)_res);
10260         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
10261 }
10262
10263 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
10264         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10265         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
10266         return (uint64_t)ret_conv;
10267 }
10268 int64_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
10269         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
10270         int64_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
10271         return ret_val;
10272 }
10273
10274 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
10275         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
10276         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10277         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
10278         return (uint64_t)ret_conv;
10279 }
10280
10281 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_ok() {
10282         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10283         *ret_conv = CResult_NoneNoneZ_ok();
10284         return (uint64_t)ret_conv;
10285 }
10286
10287 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_err() {
10288         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10289         *ret_conv = CResult_NoneNoneZ_err();
10290         return (uint64_t)ret_conv;
10291 }
10292
10293 jboolean  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
10294         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
10295         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
10296         return ret_val;
10297 }
10298
10299 void  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
10300         if ((_res & 1) != 0) return;
10301         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10302         CHECK_ACCESS(_res_ptr);
10303         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
10304         FREE((void*)_res);
10305         CResult_NoneNoneZ_free(_res_conv);
10306 }
10307
10308 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
10309         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10310         *ret_conv = CResult_NoneNoneZ_clone(arg);
10311         return (uint64_t)ret_conv;
10312 }
10313 int64_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
10314         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
10315         int64_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
10316         return ret_val;
10317 }
10318
10319 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
10320         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
10321         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10322         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
10323         return (uint64_t)ret_conv;
10324 }
10325
10326 static inline uint64_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
10327         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10328         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
10329         return ((uint64_t)ret_conv);
10330 }
10331 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
10332         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
10333         int64_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
10334         return ret_val;
10335 }
10336
10337 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
10338         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
10339         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10340         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
10341         return ((uint64_t)ret_conv);
10342 }
10343
10344 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
10345         LDKSignature a_ref;
10346         CHECK(*((uint32_t*)a) == 64);
10347         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
10348         LDKCVec_SignatureZ b_constr;
10349         b_constr.datalen = *((uint32_t*)b);
10350         if (b_constr.datalen > 0)
10351                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10352         else
10353                 b_constr.data = NULL;
10354         int8_tArray* b_vals = (int8_tArray*)(b + 4);
10355         for (size_t m = 0; m < b_constr.datalen; m++) {
10356                 int8_tArray b_conv_12 = b_vals[m];
10357                 LDKSignature b_conv_12_ref;
10358                 CHECK(*((uint32_t*)b_conv_12) == 64);
10359                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
10360                 b_constr.data[m] = b_conv_12_ref;
10361         }
10362         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10363         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
10364         return ((uint64_t)ret_conv);
10365 }
10366
10367 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
10368         if ((_res & 1) != 0) return;
10369         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10370         CHECK_ACCESS(_res_ptr);
10371         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
10372         FREE((void*)_res);
10373         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
10374 }
10375
10376 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
10377         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10378         CHECK_ACCESS(o_ptr);
10379         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
10380         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1));
10381         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10382         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
10383         return (uint64_t)ret_conv;
10384 }
10385
10386 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
10387         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10388         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
10389         return (uint64_t)ret_conv;
10390 }
10391
10392 jboolean  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
10393         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
10394         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
10395         return ret_val;
10396 }
10397
10398 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
10399         if ((_res & 1) != 0) return;
10400         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10401         CHECK_ACCESS(_res_ptr);
10402         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
10403         FREE((void*)_res);
10404         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
10405 }
10406
10407 static inline uint64_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
10408         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10409         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
10410         return (uint64_t)ret_conv;
10411 }
10412 int64_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
10413         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
10414         int64_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
10415         return ret_val;
10416 }
10417
10418 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
10419         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
10420         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10421         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
10422         return (uint64_t)ret_conv;
10423 }
10424
10425 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
10426         LDKSignature o_ref;
10427         CHECK(*((uint32_t*)o) == 64);
10428         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
10429         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10430         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
10431         return (uint64_t)ret_conv;
10432 }
10433
10434 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
10435         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10436         *ret_conv = CResult_SignatureNoneZ_err();
10437         return (uint64_t)ret_conv;
10438 }
10439
10440 jboolean  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
10441         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
10442         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
10443         return ret_val;
10444 }
10445
10446 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
10447         if ((_res & 1) != 0) return;
10448         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10449         CHECK_ACCESS(_res_ptr);
10450         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
10451         FREE((void*)_res);
10452         CResult_SignatureNoneZ_free(_res_conv);
10453 }
10454
10455 static inline uint64_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
10456         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10457         *ret_conv = CResult_SignatureNoneZ_clone(arg);
10458         return (uint64_t)ret_conv;
10459 }
10460 int64_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
10461         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
10462         int64_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
10463         return ret_val;
10464 }
10465
10466 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
10467         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
10468         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10469         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
10470         return (uint64_t)ret_conv;
10471 }
10472
10473 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
10474         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10475         CHECK_ACCESS(o_ptr);
10476         LDKSign o_conv = *(LDKSign*)(o_ptr);
10477         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10478         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
10479         return (uint64_t)ret_conv;
10480 }
10481
10482 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
10483         LDKDecodeError e_conv;
10484         e_conv.inner = (void*)(e & (~1));
10485         e_conv.is_owned = (e & 1) || (e == 0);
10486         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10487         e_conv = DecodeError_clone(&e_conv);
10488         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10489         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
10490         return (uint64_t)ret_conv;
10491 }
10492
10493 jboolean  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
10494         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
10495         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
10496         return ret_val;
10497 }
10498
10499 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
10500         if ((_res & 1) != 0) return;
10501         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10502         CHECK_ACCESS(_res_ptr);
10503         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
10504         FREE((void*)_res);
10505         CResult_SignDecodeErrorZ_free(_res_conv);
10506 }
10507
10508 static inline uint64_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
10509         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10510         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
10511         return (uint64_t)ret_conv;
10512 }
10513 int64_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
10514         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
10515         int64_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
10516         return ret_val;
10517 }
10518
10519 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
10520         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
10521         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10522         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
10523         return (uint64_t)ret_conv;
10524 }
10525
10526 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
10527         LDKCVec_u8Z _res_ref;
10528         _res_ref.datalen = *((uint32_t*)_res);
10529         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
10530         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
10531         CVec_u8Z_free(_res_ref);
10532 }
10533
10534 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray arg) {
10535         LDKRecoverableSignature arg_ref;
10536         CHECK(*((uint32_t*)arg) == 68);
10537         memcpy(arg_ref.serialized_form, (uint8_t*)(arg + 4), 68);
10538         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10539         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
10540         return (uint64_t)ret_conv;
10541 }
10542
10543 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_err() {
10544         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10545         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
10546         return (uint64_t)ret_conv;
10547 }
10548
10549 jboolean  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
10550         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
10551         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
10552         return ret_val;
10553 }
10554
10555 void  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
10556         if ((_res & 1) != 0) return;
10557         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10558         CHECK_ACCESS(_res_ptr);
10559         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
10560         FREE((void*)_res);
10561         CResult_RecoverableSignatureNoneZ_free(_res_conv);
10562 }
10563
10564 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
10565         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10566         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
10567         return (uint64_t)ret_conv;
10568 }
10569 int64_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
10570         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
10571         int64_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
10572         return ret_val;
10573 }
10574
10575 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
10576         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
10577         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10578         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
10579         return (uint64_t)ret_conv;
10580 }
10581
10582 void  __attribute__((visibility("default"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
10583         LDKCVec_CVec_u8ZZ _res_constr;
10584         _res_constr.datalen = *((uint32_t*)_res);
10585         if (_res_constr.datalen > 0)
10586                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10587         else
10588                 _res_constr.data = NULL;
10589         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
10590         for (size_t m = 0; m < _res_constr.datalen; m++) {
10591                 int8_tArray _res_conv_12 = _res_vals[m];
10592                 LDKCVec_u8Z _res_conv_12_ref;
10593                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
10594                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
10595                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
10596                 _res_constr.data[m] = _res_conv_12_ref;
10597         }
10598         CVec_CVec_u8ZZ_free(_res_constr);
10599 }
10600
10601 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
10602         LDKCVec_CVec_u8ZZ o_constr;
10603         o_constr.datalen = *((uint32_t*)o);
10604         if (o_constr.datalen > 0)
10605                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10606         else
10607                 o_constr.data = NULL;
10608         int8_tArray* o_vals = (int8_tArray*)(o + 4);
10609         for (size_t m = 0; m < o_constr.datalen; m++) {
10610                 int8_tArray o_conv_12 = o_vals[m];
10611                 LDKCVec_u8Z o_conv_12_ref;
10612                 o_conv_12_ref.datalen = *((uint32_t*)o_conv_12);
10613                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
10614                 memcpy(o_conv_12_ref.data, (uint8_t*)(o_conv_12 + 4), o_conv_12_ref.datalen);
10615                 o_constr.data[m] = o_conv_12_ref;
10616         }
10617         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10618         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
10619         return (uint64_t)ret_conv;
10620 }
10621
10622 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
10623         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10624         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
10625         return (uint64_t)ret_conv;
10626 }
10627
10628 jboolean  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
10629         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
10630         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
10631         return ret_val;
10632 }
10633
10634 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
10635         if ((_res & 1) != 0) return;
10636         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10637         CHECK_ACCESS(_res_ptr);
10638         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
10639         FREE((void*)_res);
10640         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
10641 }
10642
10643 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
10644         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10645         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
10646         return (uint64_t)ret_conv;
10647 }
10648 int64_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
10649         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
10650         int64_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
10651         return ret_val;
10652 }
10653
10654 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
10655         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
10656         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10657         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
10658         return (uint64_t)ret_conv;
10659 }
10660
10661 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
10662         LDKInMemorySigner o_conv;
10663         o_conv.inner = (void*)(o & (~1));
10664         o_conv.is_owned = (o & 1) || (o == 0);
10665         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10666         o_conv = InMemorySigner_clone(&o_conv);
10667         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10668         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
10669         return (uint64_t)ret_conv;
10670 }
10671
10672 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
10673         LDKDecodeError e_conv;
10674         e_conv.inner = (void*)(e & (~1));
10675         e_conv.is_owned = (e & 1) || (e == 0);
10676         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10677         e_conv = DecodeError_clone(&e_conv);
10678         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10679         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
10680         return (uint64_t)ret_conv;
10681 }
10682
10683 jboolean  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
10684         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
10685         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
10686         return ret_val;
10687 }
10688
10689 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
10690         if ((_res & 1) != 0) return;
10691         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10692         CHECK_ACCESS(_res_ptr);
10693         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
10694         FREE((void*)_res);
10695         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
10696 }
10697
10698 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
10699         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10700         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
10701         return (uint64_t)ret_conv;
10702 }
10703 int64_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
10704         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
10705         int64_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
10706         return ret_val;
10707 }
10708
10709 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
10710         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
10711         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10712         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
10713         return (uint64_t)ret_conv;
10714 }
10715
10716 void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
10717         LDKCVec_TxOutZ _res_constr;
10718         _res_constr.datalen = *((uint32_t*)_res);
10719         if (_res_constr.datalen > 0)
10720                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10721         else
10722                 _res_constr.data = NULL;
10723         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10724         for (size_t h = 0; h < _res_constr.datalen; h++) {
10725                 uint32_t _res_conv_7 = _res_vals[h];
10726                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
10727                 CHECK_ACCESS(_res_conv_7_ptr);
10728                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
10729                 FREE((void*)_res_conv_7);
10730                 _res_constr.data[h] = _res_conv_7_conv;
10731         }
10732         CVec_TxOutZ_free(_res_constr);
10733 }
10734
10735 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
10736         LDKTransaction o_ref;
10737         o_ref.datalen = *((uint32_t*)o);
10738         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
10739         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
10740         o_ref.data_is_owned = true;
10741         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10742         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
10743         return (uint64_t)ret_conv;
10744 }
10745
10746 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err() {
10747         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10748         *ret_conv = CResult_TransactionNoneZ_err();
10749         return (uint64_t)ret_conv;
10750 }
10751
10752 jboolean  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
10753         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
10754         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
10755         return ret_val;
10756 }
10757
10758 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
10759         if ((_res & 1) != 0) return;
10760         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10761         CHECK_ACCESS(_res_ptr);
10762         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
10763         FREE((void*)_res);
10764         CResult_TransactionNoneZ_free(_res_conv);
10765 }
10766
10767 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
10768         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10769         *ret_conv = CResult_TransactionNoneZ_clone(arg);
10770         return (uint64_t)ret_conv;
10771 }
10772 int64_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
10773         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
10774         int64_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
10775         return ret_val;
10776 }
10777
10778 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
10779         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
10780         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10781         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
10782         return (uint64_t)ret_conv;
10783 }
10784
10785 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
10786         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10787         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
10788         return ((uint64_t)ret_conv);
10789 }
10790 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
10791         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
10792         int64_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
10793         return ret_val;
10794 }
10795
10796 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
10797         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
10798         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10799         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
10800         return ((uint64_t)ret_conv);
10801 }
10802
10803 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
10804         LDKThirtyTwoBytes a_ref;
10805         CHECK(*((uint32_t*)a) == 32);
10806         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
10807         LDKChannelMonitor b_conv;
10808         b_conv.inner = (void*)(b & (~1));
10809         b_conv.is_owned = (b & 1) || (b == 0);
10810         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
10811         b_conv = ChannelMonitor_clone(&b_conv);
10812         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10813         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
10814         return ((uint64_t)ret_conv);
10815 }
10816
10817 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
10818         if ((_res & 1) != 0) return;
10819         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10820         CHECK_ACCESS(_res_ptr);
10821         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
10822         FREE((void*)_res);
10823         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
10824 }
10825
10826 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_BlockHashChannelMonitorZZ_free(uint32_tArray _res) {
10827         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
10828         _res_constr.datalen = *((uint32_t*)_res);
10829         if (_res_constr.datalen > 0)
10830                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10831         else
10832                 _res_constr.data = NULL;
10833         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10834         for (size_t j = 0; j < _res_constr.datalen; j++) {
10835                 uint32_t _res_conv_35 = _res_vals[j];
10836                 void* _res_conv_35_ptr = (void*)(((uint64_t)_res_conv_35) & ~1);
10837                 CHECK_ACCESS(_res_conv_35_ptr);
10838                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
10839                 FREE((void*)_res_conv_35);
10840                 _res_constr.data[j] = _res_conv_35_conv;
10841         }
10842         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
10843 }
10844
10845 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(uint32_tArray o) {
10846         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
10847         o_constr.datalen = *((uint32_t*)o);
10848         if (o_constr.datalen > 0)
10849                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10850         else
10851                 o_constr.data = NULL;
10852         uint32_t* o_vals = (uint32_t*)(o + 4);
10853         for (size_t j = 0; j < o_constr.datalen; j++) {
10854                 uint32_t o_conv_35 = o_vals[j];
10855                 void* o_conv_35_ptr = (void*)(((uint64_t)o_conv_35) & ~1);
10856                 CHECK_ACCESS(o_conv_35_ptr);
10857                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
10858                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1));
10859                 o_constr.data[j] = o_conv_35_conv;
10860         }
10861         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10862         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
10863         return (uint64_t)ret_conv;
10864 }
10865
10866 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(uint32_t e) {
10867         LDKIOError e_conv = LDKIOError_from_js(e);
10868         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10869         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
10870         return (uint64_t)ret_conv;
10871 }
10872
10873 jboolean  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(uint32_t o) {
10874         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
10875         jboolean ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
10876         return ret_val;
10877 }
10878
10879 void  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(uint32_t _res) {
10880         if ((_res & 1) != 0) return;
10881         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10882         CHECK_ACCESS(_res_ptr);
10883         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
10884         FREE((void*)_res);
10885         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
10886 }
10887
10888 static inline uint64_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
10889         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10890         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
10891         return (uint64_t)ret_conv;
10892 }
10893 int64_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(uint32_t arg) {
10894         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
10895         int64_t ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
10896         return ret_val;
10897 }
10898
10899 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(uint32_t orig) {
10900         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
10901         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10902         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
10903         return (uint64_t)ret_conv;
10904 }
10905
10906 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_some(int16_t o) {
10907         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10908         *ret_copy = COption_u16Z_some(o);
10909         uint64_t ret_ref = (uint64_t)ret_copy;
10910         return ret_ref;
10911 }
10912
10913 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_none() {
10914         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10915         *ret_copy = COption_u16Z_none();
10916         uint64_t ret_ref = (uint64_t)ret_copy;
10917         return ret_ref;
10918 }
10919
10920 void  __attribute__((visibility("default"))) TS_COption_u16Z_free(uint32_t _res) {
10921         if ((_res & 1) != 0) return;
10922         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10923         CHECK_ACCESS(_res_ptr);
10924         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
10925         FREE((void*)_res);
10926         COption_u16Z_free(_res_conv);
10927 }
10928
10929 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
10930         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10931         *ret_copy = COption_u16Z_clone(arg);
10932 uint64_t ret_ref = (uint64_t)ret_copy;
10933         return ret_ref;
10934 }
10935 int64_t  __attribute__((visibility("default"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
10936         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
10937         int64_t ret_val = COption_u16Z_clone_ptr(arg_conv);
10938         return ret_val;
10939 }
10940
10941 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_clone(uint32_t orig) {
10942         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
10943         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10944         *ret_copy = COption_u16Z_clone(orig_conv);
10945         uint64_t ret_ref = (uint64_t)ret_copy;
10946         return ret_ref;
10947 }
10948
10949 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
10950         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10951         *ret_conv = CResult_NoneAPIErrorZ_ok();
10952         return (uint64_t)ret_conv;
10953 }
10954
10955 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
10956         void* e_ptr = (void*)(((uint64_t)e) & ~1);
10957         CHECK_ACCESS(e_ptr);
10958         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
10959         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
10960         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10961         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
10962         return (uint64_t)ret_conv;
10963 }
10964
10965 jboolean  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
10966         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
10967         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
10968         return ret_val;
10969 }
10970
10971 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
10972         if ((_res & 1) != 0) return;
10973         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10974         CHECK_ACCESS(_res_ptr);
10975         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
10976         FREE((void*)_res);
10977         CResult_NoneAPIErrorZ_free(_res_conv);
10978 }
10979
10980 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
10981         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10982         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
10983         return (uint64_t)ret_conv;
10984 }
10985 int64_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
10986         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
10987         int64_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
10988         return ret_val;
10989 }
10990
10991 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
10992         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
10993         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10994         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
10995         return (uint64_t)ret_conv;
10996 }
10997
10998 void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
10999         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
11000         _res_constr.datalen = *((uint32_t*)_res);
11001         if (_res_constr.datalen > 0)
11002                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
11003         else
11004                 _res_constr.data = NULL;
11005         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11006         for (size_t w = 0; w < _res_constr.datalen; w++) {
11007                 uint32_t _res_conv_22 = _res_vals[w];
11008                 void* _res_conv_22_ptr = (void*)(((uint64_t)_res_conv_22) & ~1);
11009                 CHECK_ACCESS(_res_conv_22_ptr);
11010                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
11011                 FREE((void*)_res_conv_22);
11012                 _res_constr.data[w] = _res_conv_22_conv;
11013         }
11014         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
11015 }
11016
11017 void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
11018         LDKCVec_APIErrorZ _res_constr;
11019         _res_constr.datalen = *((uint32_t*)_res);
11020         if (_res_constr.datalen > 0)
11021                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
11022         else
11023                 _res_constr.data = NULL;
11024         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11025         for (size_t k = 0; k < _res_constr.datalen; k++) {
11026                 uint32_t _res_conv_10 = _res_vals[k];
11027                 void* _res_conv_10_ptr = (void*)(((uint64_t)_res_conv_10) & ~1);
11028                 CHECK_ACCESS(_res_conv_10_ptr);
11029                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
11030                 FREE((void*)_res_conv_10);
11031                 _res_constr.data[k] = _res_conv_10_conv;
11032         }
11033         CVec_APIErrorZ_free(_res_constr);
11034 }
11035
11036 uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
11037         LDKThirtyTwoBytes o_ref;
11038         CHECK(*((uint32_t*)o) == 32);
11039         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
11040         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
11041         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
11042         return (uint64_t)ret_conv;
11043 }
11044
11045 uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
11046         void* e_ptr = (void*)(((uint64_t)e) & ~1);
11047         CHECK_ACCESS(e_ptr);
11048         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
11049         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
11050         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
11051         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
11052         return (uint64_t)ret_conv;
11053 }
11054
11055 jboolean  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
11056         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
11057         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
11058         return ret_val;
11059 }
11060
11061 void  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
11062         if ((_res & 1) != 0) return;
11063         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11064         CHECK_ACCESS(_res_ptr);
11065         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
11066         FREE((void*)_res);
11067         CResult__u832APIErrorZ_free(_res_conv);
11068 }
11069
11070 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
11071         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
11072         *ret_conv = CResult__u832APIErrorZ_clone(arg);
11073         return (uint64_t)ret_conv;
11074 }
11075 int64_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
11076         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
11077         int64_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
11078         return ret_val;
11079 }
11080
11081 uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
11082         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
11083         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
11084         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
11085         return (uint64_t)ret_conv;
11086 }
11087
11088 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
11089         LDKThirtyTwoBytes o_ref;
11090         CHECK(*((uint32_t*)o) == 32);
11091         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
11092         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11093         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
11094         return (uint64_t)ret_conv;
11095 }
11096
11097 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
11098         void* e_ptr = (void*)(((uint64_t)e) & ~1);
11099         CHECK_ACCESS(e_ptr);
11100         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
11101         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
11102         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11103         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
11104         return (uint64_t)ret_conv;
11105 }
11106
11107 jboolean  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
11108         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
11109         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
11110         return ret_val;
11111 }
11112
11113 void  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
11114         if ((_res & 1) != 0) return;
11115         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11116         CHECK_ACCESS(_res_ptr);
11117         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
11118         FREE((void*)_res);
11119         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
11120 }
11121
11122 static inline uint64_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
11123         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11124         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
11125         return (uint64_t)ret_conv;
11126 }
11127 int64_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
11128         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
11129         int64_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
11130         return ret_val;
11131 }
11132
11133 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
11134         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
11135         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11136         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
11137         return (uint64_t)ret_conv;
11138 }
11139
11140 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
11141         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11142         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
11143         return (uint64_t)ret_conv;
11144 }
11145
11146 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
11147         void* e_ptr = (void*)(((uint64_t)e) & ~1);
11148         CHECK_ACCESS(e_ptr);
11149         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
11150         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
11151         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11152         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
11153         return (uint64_t)ret_conv;
11154 }
11155
11156 jboolean  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
11157         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
11158         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
11159         return ret_val;
11160 }
11161
11162 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
11163         if ((_res & 1) != 0) return;
11164         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11165         CHECK_ACCESS(_res_ptr);
11166         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
11167         FREE((void*)_res);
11168         CResult_NonePaymentSendFailureZ_free(_res_conv);
11169 }
11170
11171 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
11172         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11173         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
11174         return (uint64_t)ret_conv;
11175 }
11176 int64_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
11177         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
11178         int64_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
11179         return ret_val;
11180 }
11181
11182 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
11183         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
11184         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11185         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
11186         return (uint64_t)ret_conv;
11187 }
11188
11189 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
11190         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
11191         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
11192         return ((uint64_t)ret_conv);
11193 }
11194 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
11195         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
11196         int64_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
11197         return ret_val;
11198 }
11199
11200 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
11201         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
11202         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
11203         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
11204         return ((uint64_t)ret_conv);
11205 }
11206
11207 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
11208         LDKThirtyTwoBytes a_ref;
11209         CHECK(*((uint32_t*)a) == 32);
11210         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
11211         LDKThirtyTwoBytes b_ref;
11212         CHECK(*((uint32_t*)b) == 32);
11213         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
11214         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
11215         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
11216         return ((uint64_t)ret_conv);
11217 }
11218
11219 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
11220         if ((_res & 1) != 0) return;
11221         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11222         CHECK_ACCESS(_res_ptr);
11223         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
11224         FREE((void*)_res);
11225         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
11226 }
11227
11228 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
11229         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11230         CHECK_ACCESS(o_ptr);
11231         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
11232         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1));
11233         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
11234         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
11235         return (uint64_t)ret_conv;
11236 }
11237
11238 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
11239         void* e_ptr = (void*)(((uint64_t)e) & ~1);
11240         CHECK_ACCESS(e_ptr);
11241         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
11242         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
11243         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
11244         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
11245         return (uint64_t)ret_conv;
11246 }
11247
11248 jboolean  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
11249         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
11250         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
11251         return ret_val;
11252 }
11253
11254 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
11255         if ((_res & 1) != 0) return;
11256         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11257         CHECK_ACCESS(_res_ptr);
11258         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
11259         FREE((void*)_res);
11260         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
11261 }
11262
11263 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
11264         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
11265         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
11266         return (uint64_t)ret_conv;
11267 }
11268 int64_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
11269         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
11270         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
11271         return ret_val;
11272 }
11273
11274 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
11275         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
11276         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
11277         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
11278         return (uint64_t)ret_conv;
11279 }
11280
11281 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
11282         LDKCVec_NetAddressZ _res_constr;
11283         _res_constr.datalen = *((uint32_t*)_res);
11284         if (_res_constr.datalen > 0)
11285                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
11286         else
11287                 _res_constr.data = NULL;
11288         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11289         for (size_t m = 0; m < _res_constr.datalen; m++) {
11290                 uint32_t _res_conv_12 = _res_vals[m];
11291                 void* _res_conv_12_ptr = (void*)(((uint64_t)_res_conv_12) & ~1);
11292                 CHECK_ACCESS(_res_conv_12_ptr);
11293                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
11294                 FREE((void*)_res_conv_12);
11295                 _res_constr.data[m] = _res_conv_12_conv;
11296         }
11297         CVec_NetAddressZ_free(_res_constr);
11298 }
11299
11300 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
11301         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
11302         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
11303         return ((uint64_t)ret_conv);
11304 }
11305 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
11306         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
11307         int64_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
11308         return ret_val;
11309 }
11310
11311 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
11312         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
11313         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
11314         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
11315         return ((uint64_t)ret_conv);
11316 }
11317
11318 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
11319         LDKThirtyTwoBytes a_ref;
11320         CHECK(*((uint32_t*)a) == 32);
11321         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
11322         LDKThirtyTwoBytes b_ref;
11323         CHECK(*((uint32_t*)b) == 32);
11324         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
11325         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
11326         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
11327         return ((uint64_t)ret_conv);
11328 }
11329
11330 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
11331         if ((_res & 1) != 0) return;
11332         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11333         CHECK_ACCESS(_res_ptr);
11334         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
11335         FREE((void*)_res);
11336         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
11337 }
11338
11339 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
11340         LDKThirtyTwoBytes o_ref;
11341         CHECK(*((uint32_t*)o) == 32);
11342         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
11343         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
11344         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
11345         return (uint64_t)ret_conv;
11346 }
11347
11348 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
11349         void* e_ptr = (void*)(((uint64_t)e) & ~1);
11350         CHECK_ACCESS(e_ptr);
11351         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
11352         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
11353         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
11354         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
11355         return (uint64_t)ret_conv;
11356 }
11357
11358 jboolean  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
11359         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
11360         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
11361         return ret_val;
11362 }
11363
11364 void  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
11365         if ((_res & 1) != 0) return;
11366         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11367         CHECK_ACCESS(_res_ptr);
11368         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
11369         FREE((void*)_res);
11370         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
11371 }
11372
11373 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
11374         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
11375         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
11376         return (uint64_t)ret_conv;
11377 }
11378 int64_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
11379         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
11380         int64_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
11381         return ret_val;
11382 }
11383
11384 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
11385         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
11386         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
11387         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
11388         return (uint64_t)ret_conv;
11389 }
11390
11391 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
11392         LDKCVec_ChannelMonitorZ _res_constr;
11393         _res_constr.datalen = *((uint32_t*)_res);
11394         if (_res_constr.datalen > 0)
11395                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
11396         else
11397                 _res_constr.data = NULL;
11398         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11399         for (size_t q = 0; q < _res_constr.datalen; q++) {
11400                 uint32_t _res_conv_16 = _res_vals[q];
11401                 LDKChannelMonitor _res_conv_16_conv;
11402                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
11403                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
11404                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
11405                 _res_constr.data[q] = _res_conv_16_conv;
11406         }
11407         CVec_ChannelMonitorZ_free(_res_constr);
11408 }
11409
11410 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
11411         LDKThirtyTwoBytes a_ref;
11412         CHECK(*((uint32_t*)a) == 32);
11413         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
11414         LDKChannelManager b_conv;
11415         b_conv.inner = (void*)(b & (~1));
11416         b_conv.is_owned = (b & 1) || (b == 0);
11417         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
11418         // Warning: we need a move here but no clone is available for LDKChannelManager
11419         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
11420         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
11421         return ((uint64_t)ret_conv);
11422 }
11423
11424 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
11425         if ((_res & 1) != 0) return;
11426         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11427         CHECK_ACCESS(_res_ptr);
11428         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
11429         FREE((void*)_res);
11430         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
11431 }
11432
11433 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
11434         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11435         CHECK_ACCESS(o_ptr);
11436         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
11437         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
11438         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
11439         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
11440         return (uint64_t)ret_conv;
11441 }
11442
11443 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
11444         LDKDecodeError e_conv;
11445         e_conv.inner = (void*)(e & (~1));
11446         e_conv.is_owned = (e & 1) || (e == 0);
11447         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11448         e_conv = DecodeError_clone(&e_conv);
11449         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
11450         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
11451         return (uint64_t)ret_conv;
11452 }
11453
11454 jboolean  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
11455         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
11456         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
11457         return ret_val;
11458 }
11459
11460 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
11461         if ((_res & 1) != 0) return;
11462         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11463         CHECK_ACCESS(_res_ptr);
11464         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
11465         FREE((void*)_res);
11466         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
11467 }
11468
11469 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
11470         LDKChannelConfig o_conv;
11471         o_conv.inner = (void*)(o & (~1));
11472         o_conv.is_owned = (o & 1) || (o == 0);
11473         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11474         o_conv = ChannelConfig_clone(&o_conv);
11475         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
11476         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
11477         return (uint64_t)ret_conv;
11478 }
11479
11480 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
11481         LDKDecodeError e_conv;
11482         e_conv.inner = (void*)(e & (~1));
11483         e_conv.is_owned = (e & 1) || (e == 0);
11484         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11485         e_conv = DecodeError_clone(&e_conv);
11486         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
11487         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
11488         return (uint64_t)ret_conv;
11489 }
11490
11491 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
11492         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
11493         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
11494         return ret_val;
11495 }
11496
11497 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
11498         if ((_res & 1) != 0) return;
11499         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11500         CHECK_ACCESS(_res_ptr);
11501         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
11502         FREE((void*)_res);
11503         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
11504 }
11505
11506 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
11507         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
11508         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
11509         return (uint64_t)ret_conv;
11510 }
11511 int64_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
11512         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
11513         int64_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
11514         return ret_val;
11515 }
11516
11517 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
11518         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
11519         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
11520         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
11521         return (uint64_t)ret_conv;
11522 }
11523
11524 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
11525         LDKOutPoint o_conv;
11526         o_conv.inner = (void*)(o & (~1));
11527         o_conv.is_owned = (o & 1) || (o == 0);
11528         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11529         o_conv = OutPoint_clone(&o_conv);
11530         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
11531         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
11532         return (uint64_t)ret_conv;
11533 }
11534
11535 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
11536         LDKDecodeError e_conv;
11537         e_conv.inner = (void*)(e & (~1));
11538         e_conv.is_owned = (e & 1) || (e == 0);
11539         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11540         e_conv = DecodeError_clone(&e_conv);
11541         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
11542         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
11543         return (uint64_t)ret_conv;
11544 }
11545
11546 jboolean  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
11547         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
11548         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
11549         return ret_val;
11550 }
11551
11552 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
11553         if ((_res & 1) != 0) return;
11554         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11555         CHECK_ACCESS(_res_ptr);
11556         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
11557         FREE((void*)_res);
11558         CResult_OutPointDecodeErrorZ_free(_res_conv);
11559 }
11560
11561 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
11562         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
11563         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
11564         return (uint64_t)ret_conv;
11565 }
11566 int64_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
11567         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
11568         int64_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
11569         return ret_val;
11570 }
11571
11572 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
11573         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
11574         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
11575         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
11576         return (uint64_t)ret_conv;
11577 }
11578
11579 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_some(uint32_t o) {
11580         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11581         CHECK_ACCESS(o_ptr);
11582         LDKType o_conv = *(LDKType*)(o_ptr);
11583         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
11584         *ret_copy = COption_TypeZ_some(o_conv);
11585         uint64_t ret_ref = (uint64_t)ret_copy;
11586         return ret_ref;
11587 }
11588
11589 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_none() {
11590         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
11591         *ret_copy = COption_TypeZ_none();
11592         uint64_t ret_ref = (uint64_t)ret_copy;
11593         return ret_ref;
11594 }
11595
11596 void  __attribute__((visibility("default"))) TS_COption_TypeZ_free(uint32_t _res) {
11597         if ((_res & 1) != 0) return;
11598         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11599         CHECK_ACCESS(_res_ptr);
11600         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
11601         FREE((void*)_res);
11602         COption_TypeZ_free(_res_conv);
11603 }
11604
11605 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
11606         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
11607         *ret_copy = COption_TypeZ_clone(arg);
11608 uint64_t ret_ref = (uint64_t)ret_copy;
11609         return ret_ref;
11610 }
11611 int64_t  __attribute__((visibility("default"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
11612         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
11613         int64_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
11614         return ret_val;
11615 }
11616
11617 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_clone(uint32_t orig) {
11618         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
11619         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
11620         *ret_copy = COption_TypeZ_clone(orig_conv);
11621         uint64_t ret_ref = (uint64_t)ret_copy;
11622         return ret_ref;
11623 }
11624
11625 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
11626         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11627         CHECK_ACCESS(o_ptr);
11628         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
11629         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1));
11630         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
11631         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
11632         return (uint64_t)ret_conv;
11633 }
11634
11635 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
11636         LDKDecodeError e_conv;
11637         e_conv.inner = (void*)(e & (~1));
11638         e_conv.is_owned = (e & 1) || (e == 0);
11639         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11640         e_conv = DecodeError_clone(&e_conv);
11641         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
11642         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
11643         return (uint64_t)ret_conv;
11644 }
11645
11646 jboolean  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
11647         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
11648         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
11649         return ret_val;
11650 }
11651
11652 void  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
11653         if ((_res & 1) != 0) return;
11654         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11655         CHECK_ACCESS(_res_ptr);
11656         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
11657         FREE((void*)_res);
11658         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
11659 }
11660
11661 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
11662         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
11663         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
11664         return (uint64_t)ret_conv;
11665 }
11666 int64_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
11667         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
11668         int64_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
11669         return ret_val;
11670 }
11671
11672 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
11673         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
11674         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
11675         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
11676         return (uint64_t)ret_conv;
11677 }
11678
11679 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
11680         LDKThirtyTwoBytes o_ref;
11681         CHECK(*((uint32_t*)o) == 32);
11682         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
11683         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
11684         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
11685         return (uint64_t)ret_conv;
11686 }
11687
11688 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
11689         void* e_ptr = (void*)(((uint64_t)e) & ~1);
11690         CHECK_ACCESS(e_ptr);
11691         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
11692         e_conv = PaymentError_clone((LDKPaymentError*)(((uint64_t)e) & ~1));
11693         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
11694         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
11695         return (uint64_t)ret_conv;
11696 }
11697
11698 jboolean  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_is_ok(uint32_t o) {
11699         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
11700         jboolean ret_val = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
11701         return ret_val;
11702 }
11703
11704 void  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
11705         if ((_res & 1) != 0) return;
11706         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11707         CHECK_ACCESS(_res_ptr);
11708         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
11709         FREE((void*)_res);
11710         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
11711 }
11712
11713 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
11714         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
11715         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
11716         return (uint64_t)ret_conv;
11717 }
11718 int64_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_clone_ptr(uint32_t arg) {
11719         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
11720         int64_t ret_val = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
11721         return ret_val;
11722 }
11723
11724 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
11725         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
11726         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
11727         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
11728         return (uint64_t)ret_conv;
11729 }
11730
11731 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_ok(uint32_t o) {
11732         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
11733         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
11734         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
11735         return (uint64_t)ret_conv;
11736 }
11737
11738 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_err() {
11739         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
11740         *ret_conv = CResult_SiPrefixNoneZ_err();
11741         return (uint64_t)ret_conv;
11742 }
11743
11744 jboolean  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_is_ok(uint32_t o) {
11745         LDKCResult_SiPrefixNoneZ* o_conv = (LDKCResult_SiPrefixNoneZ*)(o & ~1);
11746         jboolean ret_val = CResult_SiPrefixNoneZ_is_ok(o_conv);
11747         return ret_val;
11748 }
11749
11750 void  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_free(uint32_t _res) {
11751         if ((_res & 1) != 0) return;
11752         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11753         CHECK_ACCESS(_res_ptr);
11754         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
11755         FREE((void*)_res);
11756         CResult_SiPrefixNoneZ_free(_res_conv);
11757 }
11758
11759 static inline uint64_t CResult_SiPrefixNoneZ_clone_ptr(LDKCResult_SiPrefixNoneZ *NONNULL_PTR arg) {
11760         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
11761         *ret_conv = CResult_SiPrefixNoneZ_clone(arg);
11762         return (uint64_t)ret_conv;
11763 }
11764 int64_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_clone_ptr(uint32_t arg) {
11765         LDKCResult_SiPrefixNoneZ* arg_conv = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
11766         int64_t ret_val = CResult_SiPrefixNoneZ_clone_ptr(arg_conv);
11767         return ret_val;
11768 }
11769
11770 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_clone(uint32_t orig) {
11771         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
11772         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
11773         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
11774         return (uint64_t)ret_conv;
11775 }
11776
11777 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_ok(uint32_t o) {
11778         LDKInvoice o_conv;
11779         o_conv.inner = (void*)(o & (~1));
11780         o_conv.is_owned = (o & 1) || (o == 0);
11781         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11782         o_conv = Invoice_clone(&o_conv);
11783         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11784         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
11785         return (uint64_t)ret_conv;
11786 }
11787
11788 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_err() {
11789         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11790         *ret_conv = CResult_InvoiceNoneZ_err();
11791         return (uint64_t)ret_conv;
11792 }
11793
11794 jboolean  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_is_ok(uint32_t o) {
11795         LDKCResult_InvoiceNoneZ* o_conv = (LDKCResult_InvoiceNoneZ*)(o & ~1);
11796         jboolean ret_val = CResult_InvoiceNoneZ_is_ok(o_conv);
11797         return ret_val;
11798 }
11799
11800 void  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_free(uint32_t _res) {
11801         if ((_res & 1) != 0) return;
11802         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11803         CHECK_ACCESS(_res_ptr);
11804         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
11805         FREE((void*)_res);
11806         CResult_InvoiceNoneZ_free(_res_conv);
11807 }
11808
11809 static inline uint64_t CResult_InvoiceNoneZ_clone_ptr(LDKCResult_InvoiceNoneZ *NONNULL_PTR arg) {
11810         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11811         *ret_conv = CResult_InvoiceNoneZ_clone(arg);
11812         return (uint64_t)ret_conv;
11813 }
11814 int64_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_clone_ptr(uint32_t arg) {
11815         LDKCResult_InvoiceNoneZ* arg_conv = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
11816         int64_t ret_val = CResult_InvoiceNoneZ_clone_ptr(arg_conv);
11817         return ret_val;
11818 }
11819
11820 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_clone(uint32_t orig) {
11821         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
11822         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
11823         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
11824         return (uint64_t)ret_conv;
11825 }
11826
11827 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_ok(uint32_t o) {
11828         LDKSignedRawInvoice o_conv;
11829         o_conv.inner = (void*)(o & (~1));
11830         o_conv.is_owned = (o & 1) || (o == 0);
11831         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11832         o_conv = SignedRawInvoice_clone(&o_conv);
11833         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11834         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
11835         return (uint64_t)ret_conv;
11836 }
11837
11838 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_err() {
11839         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11840         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
11841         return (uint64_t)ret_conv;
11842 }
11843
11844 jboolean  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_is_ok(uint32_t o) {
11845         LDKCResult_SignedRawInvoiceNoneZ* o_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(o & ~1);
11846         jboolean ret_val = CResult_SignedRawInvoiceNoneZ_is_ok(o_conv);
11847         return ret_val;
11848 }
11849
11850 void  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_free(uint32_t _res) {
11851         if ((_res & 1) != 0) return;
11852         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11853         CHECK_ACCESS(_res_ptr);
11854         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
11855         FREE((void*)_res);
11856         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
11857 }
11858
11859 static inline uint64_t CResult_SignedRawInvoiceNoneZ_clone_ptr(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR arg) {
11860         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11861         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(arg);
11862         return (uint64_t)ret_conv;
11863 }
11864 int64_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_clone_ptr(uint32_t arg) {
11865         LDKCResult_SignedRawInvoiceNoneZ* arg_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
11866         int64_t ret_val = CResult_SignedRawInvoiceNoneZ_clone_ptr(arg_conv);
11867         return ret_val;
11868 }
11869
11870 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_clone(uint32_t orig) {
11871         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
11872         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
11873         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
11874         return (uint64_t)ret_conv;
11875 }
11876
11877 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
11878         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
11879         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
11880         return ((uint64_t)ret_conv);
11881 }
11882 int64_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(uint32_t arg) {
11883         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
11884         int64_t ret_val = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
11885         return ret_val;
11886 }
11887
11888 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
11889         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
11890         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
11891         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
11892         return ((uint64_t)ret_conv);
11893 }
11894
11895 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
11896         LDKRawInvoice a_conv;
11897         a_conv.inner = (void*)(a & (~1));
11898         a_conv.is_owned = (a & 1) || (a == 0);
11899         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
11900         a_conv = RawInvoice_clone(&a_conv);
11901         LDKThirtyTwoBytes b_ref;
11902         CHECK(*((uint32_t*)b) == 32);
11903         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
11904         LDKInvoiceSignature c_conv;
11905         c_conv.inner = (void*)(c & (~1));
11906         c_conv.is_owned = (c & 1) || (c == 0);
11907         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
11908         c_conv = InvoiceSignature_clone(&c_conv);
11909         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
11910         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
11911         return ((uint64_t)ret_conv);
11912 }
11913
11914 void  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
11915         if ((_res & 1) != 0) return;
11916         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11917         CHECK_ACCESS(_res_ptr);
11918         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
11919         FREE((void*)_res);
11920         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
11921 }
11922
11923 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
11924         LDKPayeePubKey o_conv;
11925         o_conv.inner = (void*)(o & (~1));
11926         o_conv.is_owned = (o & 1) || (o == 0);
11927         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11928         o_conv = PayeePubKey_clone(&o_conv);
11929         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11930         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
11931         return (uint64_t)ret_conv;
11932 }
11933
11934 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
11935         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11936         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11937         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
11938         return (uint64_t)ret_conv;
11939 }
11940
11941 jboolean  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_is_ok(uint32_t o) {
11942         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
11943         jboolean ret_val = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
11944         return ret_val;
11945 }
11946
11947 void  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
11948         if ((_res & 1) != 0) return;
11949         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11950         CHECK_ACCESS(_res_ptr);
11951         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
11952         FREE((void*)_res);
11953         CResult_PayeePubKeyErrorZ_free(_res_conv);
11954 }
11955
11956 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
11957         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11958         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
11959         return (uint64_t)ret_conv;
11960 }
11961 int64_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_clone_ptr(uint32_t arg) {
11962         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
11963         int64_t ret_val = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
11964         return ret_val;
11965 }
11966
11967 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
11968         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
11969         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
11970         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
11971         return (uint64_t)ret_conv;
11972 }
11973
11974 void  __attribute__((visibility("default"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
11975         LDKCVec_PrivateRouteZ _res_constr;
11976         _res_constr.datalen = *((uint32_t*)_res);
11977         if (_res_constr.datalen > 0)
11978                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
11979         else
11980                 _res_constr.data = NULL;
11981         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11982         for (size_t o = 0; o < _res_constr.datalen; o++) {
11983                 uint32_t _res_conv_14 = _res_vals[o];
11984                 LDKPrivateRoute _res_conv_14_conv;
11985                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
11986                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
11987                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
11988                 _res_constr.data[o] = _res_conv_14_conv;
11989         }
11990         CVec_PrivateRouteZ_free(_res_constr);
11991 }
11992
11993 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
11994         LDKPositiveTimestamp o_conv;
11995         o_conv.inner = (void*)(o & (~1));
11996         o_conv.is_owned = (o & 1) || (o == 0);
11997         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11998         o_conv = PositiveTimestamp_clone(&o_conv);
11999         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
12000         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
12001         return (uint64_t)ret_conv;
12002 }
12003
12004 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
12005         LDKCreationError e_conv = LDKCreationError_from_js(e);
12006         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
12007         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
12008         return (uint64_t)ret_conv;
12009 }
12010
12011 jboolean  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_is_ok(uint32_t o) {
12012         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
12013         jboolean ret_val = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
12014         return ret_val;
12015 }
12016
12017 void  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
12018         if ((_res & 1) != 0) return;
12019         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12020         CHECK_ACCESS(_res_ptr);
12021         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
12022         FREE((void*)_res);
12023         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
12024 }
12025
12026 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
12027         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
12028         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
12029         return (uint64_t)ret_conv;
12030 }
12031 int64_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr(uint32_t arg) {
12032         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
12033         int64_t ret_val = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
12034         return ret_val;
12035 }
12036
12037 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
12038         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
12039         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
12040         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
12041         return (uint64_t)ret_conv;
12042 }
12043
12044 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_ok() {
12045         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
12046         *ret_conv = CResult_NoneSemanticErrorZ_ok();
12047         return (uint64_t)ret_conv;
12048 }
12049
12050 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
12051         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
12052         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
12053         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
12054         return (uint64_t)ret_conv;
12055 }
12056
12057 jboolean  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_is_ok(uint32_t o) {
12058         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
12059         jboolean ret_val = CResult_NoneSemanticErrorZ_is_ok(o_conv);
12060         return ret_val;
12061 }
12062
12063 void  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
12064         if ((_res & 1) != 0) return;
12065         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12066         CHECK_ACCESS(_res_ptr);
12067         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
12068         FREE((void*)_res);
12069         CResult_NoneSemanticErrorZ_free(_res_conv);
12070 }
12071
12072 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
12073         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
12074         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
12075         return (uint64_t)ret_conv;
12076 }
12077 int64_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_clone_ptr(uint32_t arg) {
12078         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
12079         int64_t ret_val = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
12080         return ret_val;
12081 }
12082
12083 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
12084         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
12085         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
12086         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
12087         return (uint64_t)ret_conv;
12088 }
12089
12090 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
12091         LDKInvoice o_conv;
12092         o_conv.inner = (void*)(o & (~1));
12093         o_conv.is_owned = (o & 1) || (o == 0);
12094         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12095         o_conv = Invoice_clone(&o_conv);
12096         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
12097         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
12098         return (uint64_t)ret_conv;
12099 }
12100
12101 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
12102         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
12103         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
12104         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
12105         return (uint64_t)ret_conv;
12106 }
12107
12108 jboolean  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_is_ok(uint32_t o) {
12109         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
12110         jboolean ret_val = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
12111         return ret_val;
12112 }
12113
12114 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
12115         if ((_res & 1) != 0) return;
12116         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12117         CHECK_ACCESS(_res_ptr);
12118         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
12119         FREE((void*)_res);
12120         CResult_InvoiceSemanticErrorZ_free(_res_conv);
12121 }
12122
12123 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
12124         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
12125         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
12126         return (uint64_t)ret_conv;
12127 }
12128 int64_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_clone_ptr(uint32_t arg) {
12129         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
12130         int64_t ret_val = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
12131         return ret_val;
12132 }
12133
12134 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
12135         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
12136         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
12137         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
12138         return (uint64_t)ret_conv;
12139 }
12140
12141 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
12142         LDKDescription o_conv;
12143         o_conv.inner = (void*)(o & (~1));
12144         o_conv.is_owned = (o & 1) || (o == 0);
12145         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12146         o_conv = Description_clone(&o_conv);
12147         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
12148         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
12149         return (uint64_t)ret_conv;
12150 }
12151
12152 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
12153         LDKCreationError e_conv = LDKCreationError_from_js(e);
12154         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
12155         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
12156         return (uint64_t)ret_conv;
12157 }
12158
12159 jboolean  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_is_ok(uint32_t o) {
12160         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
12161         jboolean ret_val = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
12162         return ret_val;
12163 }
12164
12165 void  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
12166         if ((_res & 1) != 0) return;
12167         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12168         CHECK_ACCESS(_res_ptr);
12169         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
12170         FREE((void*)_res);
12171         CResult_DescriptionCreationErrorZ_free(_res_conv);
12172 }
12173
12174 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
12175         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
12176         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
12177         return (uint64_t)ret_conv;
12178 }
12179 int64_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_clone_ptr(uint32_t arg) {
12180         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
12181         int64_t ret_val = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
12182         return ret_val;
12183 }
12184
12185 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
12186         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
12187         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
12188         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
12189         return (uint64_t)ret_conv;
12190 }
12191
12192 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_ok(uint32_t o) {
12193         LDKExpiryTime o_conv;
12194         o_conv.inner = (void*)(o & (~1));
12195         o_conv.is_owned = (o & 1) || (o == 0);
12196         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12197         o_conv = ExpiryTime_clone(&o_conv);
12198         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
12199         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
12200         return (uint64_t)ret_conv;
12201 }
12202
12203 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_err(uint32_t e) {
12204         LDKCreationError e_conv = LDKCreationError_from_js(e);
12205         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
12206         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
12207         return (uint64_t)ret_conv;
12208 }
12209
12210 jboolean  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_is_ok(uint32_t o) {
12211         LDKCResult_ExpiryTimeCreationErrorZ* o_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(o & ~1);
12212         jboolean ret_val = CResult_ExpiryTimeCreationErrorZ_is_ok(o_conv);
12213         return ret_val;
12214 }
12215
12216 void  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_free(uint32_t _res) {
12217         if ((_res & 1) != 0) return;
12218         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12219         CHECK_ACCESS(_res_ptr);
12220         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(_res_ptr);
12221         FREE((void*)_res);
12222         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
12223 }
12224
12225 static inline uint64_t CResult_ExpiryTimeCreationErrorZ_clone_ptr(LDKCResult_ExpiryTimeCreationErrorZ *NONNULL_PTR arg) {
12226         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
12227         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(arg);
12228         return (uint64_t)ret_conv;
12229 }
12230 int64_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_clone_ptr(uint32_t arg) {
12231         LDKCResult_ExpiryTimeCreationErrorZ* arg_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
12232         int64_t ret_val = CResult_ExpiryTimeCreationErrorZ_clone_ptr(arg_conv);
12233         return ret_val;
12234 }
12235
12236 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_clone(uint32_t orig) {
12237         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
12238         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
12239         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
12240         return (uint64_t)ret_conv;
12241 }
12242
12243 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
12244         LDKPrivateRoute o_conv;
12245         o_conv.inner = (void*)(o & (~1));
12246         o_conv.is_owned = (o & 1) || (o == 0);
12247         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12248         o_conv = PrivateRoute_clone(&o_conv);
12249         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
12250         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
12251         return (uint64_t)ret_conv;
12252 }
12253
12254 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
12255         LDKCreationError e_conv = LDKCreationError_from_js(e);
12256         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
12257         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
12258         return (uint64_t)ret_conv;
12259 }
12260
12261 jboolean  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_is_ok(uint32_t o) {
12262         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
12263         jboolean ret_val = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
12264         return ret_val;
12265 }
12266
12267 void  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
12268         if ((_res & 1) != 0) return;
12269         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12270         CHECK_ACCESS(_res_ptr);
12271         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
12272         FREE((void*)_res);
12273         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
12274 }
12275
12276 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
12277         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
12278         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
12279         return (uint64_t)ret_conv;
12280 }
12281 int64_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_clone_ptr(uint32_t arg) {
12282         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
12283         int64_t ret_val = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
12284         return ret_val;
12285 }
12286
12287 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
12288         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
12289         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
12290         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
12291         return (uint64_t)ret_conv;
12292 }
12293
12294 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_ok(jstring o) {
12295         LDKStr o_conv = str_ref_to_owned_c(o);
12296         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
12297         *ret_conv = CResult_StringErrorZ_ok(o_conv);
12298         return (uint64_t)ret_conv;
12299 }
12300
12301 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_err(uint32_t e) {
12302         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
12303         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
12304         *ret_conv = CResult_StringErrorZ_err(e_conv);
12305         return (uint64_t)ret_conv;
12306 }
12307
12308 jboolean  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
12309         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
12310         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
12311         return ret_val;
12312 }
12313
12314 void  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
12315         if ((_res & 1) != 0) return;
12316         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12317         CHECK_ACCESS(_res_ptr);
12318         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
12319         FREE((void*)_res);
12320         CResult_StringErrorZ_free(_res_conv);
12321 }
12322
12323 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
12324         LDKChannelMonitorUpdate o_conv;
12325         o_conv.inner = (void*)(o & (~1));
12326         o_conv.is_owned = (o & 1) || (o == 0);
12327         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12328         o_conv = ChannelMonitorUpdate_clone(&o_conv);
12329         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
12330         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
12331         return (uint64_t)ret_conv;
12332 }
12333
12334 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
12335         LDKDecodeError e_conv;
12336         e_conv.inner = (void*)(e & (~1));
12337         e_conv.is_owned = (e & 1) || (e == 0);
12338         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12339         e_conv = DecodeError_clone(&e_conv);
12340         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
12341         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
12342         return (uint64_t)ret_conv;
12343 }
12344
12345 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
12346         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
12347         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
12348         return ret_val;
12349 }
12350
12351 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
12352         if ((_res & 1) != 0) return;
12353         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12354         CHECK_ACCESS(_res_ptr);
12355         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
12356         FREE((void*)_res);
12357         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
12358 }
12359
12360 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
12361         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
12362         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
12363         return (uint64_t)ret_conv;
12364 }
12365 int64_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
12366         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
12367         int64_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
12368         return ret_val;
12369 }
12370
12371 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
12372         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
12373         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
12374         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
12375         return (uint64_t)ret_conv;
12376 }
12377
12378 uint32_t  __attribute__((visibility("default"))) TS_COption_MonitorEventZ_some(uint32_t o) {
12379         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12380         CHECK_ACCESS(o_ptr);
12381         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
12382         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)o) & ~1));
12383         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
12384         *ret_copy = COption_MonitorEventZ_some(o_conv);
12385         uint64_t ret_ref = (uint64_t)ret_copy;
12386         return ret_ref;
12387 }
12388
12389 uint32_t  __attribute__((visibility("default"))) TS_COption_MonitorEventZ_none() {
12390         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
12391         *ret_copy = COption_MonitorEventZ_none();
12392         uint64_t ret_ref = (uint64_t)ret_copy;
12393         return ret_ref;
12394 }
12395
12396 void  __attribute__((visibility("default"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
12397         if ((_res & 1) != 0) return;
12398         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12399         CHECK_ACCESS(_res_ptr);
12400         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
12401         FREE((void*)_res);
12402         COption_MonitorEventZ_free(_res_conv);
12403 }
12404
12405 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
12406         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
12407         *ret_copy = COption_MonitorEventZ_clone(arg);
12408 uint64_t ret_ref = (uint64_t)ret_copy;
12409         return ret_ref;
12410 }
12411 int64_t  __attribute__((visibility("default"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
12412         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
12413         int64_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
12414         return ret_val;
12415 }
12416
12417 uint32_t  __attribute__((visibility("default"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
12418         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
12419         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
12420         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
12421         uint64_t ret_ref = (uint64_t)ret_copy;
12422         return ret_ref;
12423 }
12424
12425 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
12426         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12427         CHECK_ACCESS(o_ptr);
12428         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
12429         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uint64_t)o) & ~1));
12430         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
12431         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
12432         return (uint64_t)ret_conv;
12433 }
12434
12435 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
12436         LDKDecodeError e_conv;
12437         e_conv.inner = (void*)(e & (~1));
12438         e_conv.is_owned = (e & 1) || (e == 0);
12439         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12440         e_conv = DecodeError_clone(&e_conv);
12441         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
12442         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
12443         return (uint64_t)ret_conv;
12444 }
12445
12446 jboolean  __attribute__((visibility("default"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
12447         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
12448         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
12449         return ret_val;
12450 }
12451
12452 void  __attribute__((visibility("default"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
12453         if ((_res & 1) != 0) return;
12454         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12455         CHECK_ACCESS(_res_ptr);
12456         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
12457         FREE((void*)_res);
12458         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
12459 }
12460
12461 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
12462         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
12463         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
12464         return (uint64_t)ret_conv;
12465 }
12466 int64_t  __attribute__((visibility("default"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
12467         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
12468         int64_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
12469         return ret_val;
12470 }
12471
12472 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
12473         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
12474         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
12475         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
12476         return (uint64_t)ret_conv;
12477 }
12478
12479 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
12480         LDKHTLCUpdate o_conv;
12481         o_conv.inner = (void*)(o & (~1));
12482         o_conv.is_owned = (o & 1) || (o == 0);
12483         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12484         o_conv = HTLCUpdate_clone(&o_conv);
12485         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
12486         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
12487         return (uint64_t)ret_conv;
12488 }
12489
12490 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
12491         LDKDecodeError e_conv;
12492         e_conv.inner = (void*)(e & (~1));
12493         e_conv.is_owned = (e & 1) || (e == 0);
12494         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12495         e_conv = DecodeError_clone(&e_conv);
12496         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
12497         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
12498         return (uint64_t)ret_conv;
12499 }
12500
12501 jboolean  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
12502         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
12503         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
12504         return ret_val;
12505 }
12506
12507 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
12508         if ((_res & 1) != 0) return;
12509         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12510         CHECK_ACCESS(_res_ptr);
12511         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
12512         FREE((void*)_res);
12513         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
12514 }
12515
12516 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
12517         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
12518         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
12519         return (uint64_t)ret_conv;
12520 }
12521 int64_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
12522         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
12523         int64_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
12524         return ret_val;
12525 }
12526
12527 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
12528         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
12529         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
12530         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
12531         return (uint64_t)ret_conv;
12532 }
12533
12534 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
12535         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
12536         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
12537         return (uint64_t)ret_conv;
12538 }
12539
12540 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
12541         LDKMonitorUpdateError e_conv;
12542         e_conv.inner = (void*)(e & (~1));
12543         e_conv.is_owned = (e & 1) || (e == 0);
12544         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12545         e_conv = MonitorUpdateError_clone(&e_conv);
12546         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
12547         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
12548         return (uint64_t)ret_conv;
12549 }
12550
12551 jboolean  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_is_ok(uint32_t o) {
12552         LDKCResult_NoneMonitorUpdateErrorZ* o_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(o & ~1);
12553         jboolean ret_val = CResult_NoneMonitorUpdateErrorZ_is_ok(o_conv);
12554         return ret_val;
12555 }
12556
12557 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
12558         if ((_res & 1) != 0) return;
12559         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12560         CHECK_ACCESS(_res_ptr);
12561         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(_res_ptr);
12562         FREE((void*)_res);
12563         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
12564 }
12565
12566 static inline uint64_t CResult_NoneMonitorUpdateErrorZ_clone_ptr(LDKCResult_NoneMonitorUpdateErrorZ *NONNULL_PTR arg) {
12567         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
12568         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(arg);
12569         return (uint64_t)ret_conv;
12570 }
12571 int64_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_clone_ptr(uint32_t arg) {
12572         LDKCResult_NoneMonitorUpdateErrorZ* arg_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
12573         int64_t ret_val = CResult_NoneMonitorUpdateErrorZ_clone_ptr(arg_conv);
12574         return ret_val;
12575 }
12576
12577 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_clone(uint32_t orig) {
12578         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
12579         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
12580         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
12581         return (uint64_t)ret_conv;
12582 }
12583
12584 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
12585         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
12586         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
12587         return ((uint64_t)ret_conv);
12588 }
12589 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_clone_ptr(uint32_t arg) {
12590         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
12591         int64_t ret_val = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
12592         return ret_val;
12593 }
12594
12595 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
12596         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
12597         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
12598         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
12599         return ((uint64_t)ret_conv);
12600 }
12601
12602 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
12603         LDKOutPoint a_conv;
12604         a_conv.inner = (void*)(a & (~1));
12605         a_conv.is_owned = (a & 1) || (a == 0);
12606         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
12607         a_conv = OutPoint_clone(&a_conv);
12608         LDKCVec_u8Z b_ref;
12609         b_ref.datalen = *((uint32_t*)b);
12610         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
12611         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
12612         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
12613         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
12614         return ((uint64_t)ret_conv);
12615 }
12616
12617 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
12618         if ((_res & 1) != 0) return;
12619         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12620         CHECK_ACCESS(_res_ptr);
12621         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
12622         FREE((void*)_res);
12623         C2Tuple_OutPointScriptZ_free(_res_conv);
12624 }
12625
12626 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
12627         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
12628         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
12629         return ((uint64_t)ret_conv);
12630 }
12631 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_clone_ptr(uint32_t arg) {
12632         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
12633         int64_t ret_val = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
12634         return ret_val;
12635 }
12636
12637 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
12638         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
12639         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
12640         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
12641         return ((uint64_t)ret_conv);
12642 }
12643
12644 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
12645         LDKCVec_u8Z b_ref;
12646         b_ref.datalen = *((uint32_t*)b);
12647         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
12648         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
12649         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
12650         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
12651         return ((uint64_t)ret_conv);
12652 }
12653
12654 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
12655         if ((_res & 1) != 0) return;
12656         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12657         CHECK_ACCESS(_res_ptr);
12658         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
12659         FREE((void*)_res);
12660         C2Tuple_u32ScriptZ_free(_res_conv);
12661 }
12662
12663 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
12664         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
12665         _res_constr.datalen = *((uint32_t*)_res);
12666         if (_res_constr.datalen > 0)
12667                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
12668         else
12669                 _res_constr.data = NULL;
12670         uint32_t* _res_vals = (uint32_t*)(_res + 4);
12671         for (size_t v = 0; v < _res_constr.datalen; v++) {
12672                 uint32_t _res_conv_21 = _res_vals[v];
12673                 void* _res_conv_21_ptr = (void*)(((uint64_t)_res_conv_21) & ~1);
12674                 CHECK_ACCESS(_res_conv_21_ptr);
12675                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
12676                 FREE((void*)_res_conv_21);
12677                 _res_constr.data[v] = _res_conv_21_conv;
12678         }
12679         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
12680 }
12681
12682 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
12683         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
12684         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
12685         return ((uint64_t)ret_conv);
12686 }
12687 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(uint32_t arg) {
12688         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
12689         int64_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
12690         return ret_val;
12691 }
12692
12693 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
12694         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
12695         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
12696         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
12697         return ((uint64_t)ret_conv);
12698 }
12699
12700 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
12701         LDKThirtyTwoBytes a_ref;
12702         CHECK(*((uint32_t*)a) == 32);
12703         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
12704         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
12705         b_constr.datalen = *((uint32_t*)b);
12706         if (b_constr.datalen > 0)
12707                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
12708         else
12709                 b_constr.data = NULL;
12710         uint32_t* b_vals = (uint32_t*)(b + 4);
12711         for (size_t v = 0; v < b_constr.datalen; v++) {
12712                 uint32_t b_conv_21 = b_vals[v];
12713                 void* b_conv_21_ptr = (void*)(((uint64_t)b_conv_21) & ~1);
12714                 CHECK_ACCESS(b_conv_21_ptr);
12715                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
12716                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
12717                 b_constr.data[v] = b_conv_21_conv;
12718         }
12719         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
12720         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
12721         return ((uint64_t)ret_conv);
12722 }
12723
12724 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
12725         if ((_res & 1) != 0) return;
12726         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12727         CHECK_ACCESS(_res_ptr);
12728         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
12729         FREE((void*)_res);
12730         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
12731 }
12732
12733 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
12734         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
12735         _res_constr.datalen = *((uint32_t*)_res);
12736         if (_res_constr.datalen > 0)
12737                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
12738         else
12739                 _res_constr.data = NULL;
12740         uint32_t* _res_vals = (uint32_t*)(_res + 4);
12741         for (size_t o = 0; o < _res_constr.datalen; o++) {
12742                 uint32_t _res_conv_40 = _res_vals[o];
12743                 void* _res_conv_40_ptr = (void*)(((uint64_t)_res_conv_40) & ~1);
12744                 CHECK_ACCESS(_res_conv_40_ptr);
12745                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
12746                 FREE((void*)_res_conv_40);
12747                 _res_constr.data[o] = _res_conv_40_conv;
12748         }
12749         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
12750 }
12751
12752 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
12753         LDKCVec_EventZ _res_constr;
12754         _res_constr.datalen = *((uint32_t*)_res);
12755         if (_res_constr.datalen > 0)
12756                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
12757         else
12758                 _res_constr.data = NULL;
12759         uint32_t* _res_vals = (uint32_t*)(_res + 4);
12760         for (size_t h = 0; h < _res_constr.datalen; h++) {
12761                 uint32_t _res_conv_7 = _res_vals[h];
12762                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
12763                 CHECK_ACCESS(_res_conv_7_ptr);
12764                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
12765                 FREE((void*)_res_conv_7);
12766                 _res_constr.data[h] = _res_conv_7_conv;
12767         }
12768         CVec_EventZ_free(_res_constr);
12769 }
12770
12771 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
12772         LDKCVec_TransactionZ _res_constr;
12773         _res_constr.datalen = *((uint32_t*)_res);
12774         if (_res_constr.datalen > 0)
12775                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
12776         else
12777                 _res_constr.data = NULL;
12778         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
12779         for (size_t m = 0; m < _res_constr.datalen; m++) {
12780                 int8_tArray _res_conv_12 = _res_vals[m];
12781                 LDKTransaction _res_conv_12_ref;
12782                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
12783                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
12784                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
12785                 _res_conv_12_ref.data_is_owned = true;
12786                 _res_constr.data[m] = _res_conv_12_ref;
12787         }
12788         CVec_TransactionZ_free(_res_constr);
12789 }
12790
12791 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
12792         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
12793         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
12794         return ((uint64_t)ret_conv);
12795 }
12796 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
12797         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
12798         int64_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
12799         return ret_val;
12800 }
12801
12802 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
12803         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
12804         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
12805         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
12806         return ((uint64_t)ret_conv);
12807 }
12808
12809 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
12810         void* b_ptr = (void*)(((uint64_t)b) & ~1);
12811         CHECK_ACCESS(b_ptr);
12812         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
12813         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
12814         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
12815         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
12816         return ((uint64_t)ret_conv);
12817 }
12818
12819 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
12820         if ((_res & 1) != 0) return;
12821         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12822         CHECK_ACCESS(_res_ptr);
12823         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
12824         FREE((void*)_res);
12825         C2Tuple_u32TxOutZ_free(_res_conv);
12826 }
12827
12828 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
12829         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
12830         _res_constr.datalen = *((uint32_t*)_res);
12831         if (_res_constr.datalen > 0)
12832                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
12833         else
12834                 _res_constr.data = NULL;
12835         uint32_t* _res_vals = (uint32_t*)(_res + 4);
12836         for (size_t u = 0; u < _res_constr.datalen; u++) {
12837                 uint32_t _res_conv_20 = _res_vals[u];
12838                 void* _res_conv_20_ptr = (void*)(((uint64_t)_res_conv_20) & ~1);
12839                 CHECK_ACCESS(_res_conv_20_ptr);
12840                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
12841                 FREE((void*)_res_conv_20);
12842                 _res_constr.data[u] = _res_conv_20_conv;
12843         }
12844         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
12845 }
12846
12847 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
12848         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
12849         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
12850         return ((uint64_t)ret_conv);
12851 }
12852 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
12853         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
12854         int64_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
12855         return ret_val;
12856 }
12857
12858 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
12859         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
12860         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
12861         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
12862         return ((uint64_t)ret_conv);
12863 }
12864
12865 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
12866         LDKThirtyTwoBytes a_ref;
12867         CHECK(*((uint32_t*)a) == 32);
12868         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
12869         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
12870         b_constr.datalen = *((uint32_t*)b);
12871         if (b_constr.datalen > 0)
12872                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
12873         else
12874                 b_constr.data = NULL;
12875         uint32_t* b_vals = (uint32_t*)(b + 4);
12876         for (size_t u = 0; u < b_constr.datalen; u++) {
12877                 uint32_t b_conv_20 = b_vals[u];
12878                 void* b_conv_20_ptr = (void*)(((uint64_t)b_conv_20) & ~1);
12879                 CHECK_ACCESS(b_conv_20_ptr);
12880                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
12881                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
12882                 b_constr.data[u] = b_conv_20_conv;
12883         }
12884         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
12885         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
12886         return ((uint64_t)ret_conv);
12887 }
12888
12889 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
12890         if ((_res & 1) != 0) return;
12891         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12892         CHECK_ACCESS(_res_ptr);
12893         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
12894         FREE((void*)_res);
12895         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
12896 }
12897
12898 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
12899         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
12900         _res_constr.datalen = *((uint32_t*)_res);
12901         if (_res_constr.datalen > 0)
12902                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
12903         else
12904                 _res_constr.data = NULL;
12905         uint32_t* _res_vals = (uint32_t*)(_res + 4);
12906         for (size_t n = 0; n < _res_constr.datalen; n++) {
12907                 uint32_t _res_conv_39 = _res_vals[n];
12908                 void* _res_conv_39_ptr = (void*)(((uint64_t)_res_conv_39) & ~1);
12909                 CHECK_ACCESS(_res_conv_39_ptr);
12910                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
12911                 FREE((void*)_res_conv_39);
12912                 _res_constr.data[n] = _res_conv_39_conv;
12913         }
12914         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
12915 }
12916
12917 void  __attribute__((visibility("default"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
12918         LDKCVec_BalanceZ _res_constr;
12919         _res_constr.datalen = *((uint32_t*)_res);
12920         if (_res_constr.datalen > 0)
12921                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
12922         else
12923                 _res_constr.data = NULL;
12924         uint32_t* _res_vals = (uint32_t*)(_res + 4);
12925         for (size_t j = 0; j < _res_constr.datalen; j++) {
12926                 uint32_t _res_conv_9 = _res_vals[j];
12927                 void* _res_conv_9_ptr = (void*)(((uint64_t)_res_conv_9) & ~1);
12928                 CHECK_ACCESS(_res_conv_9_ptr);
12929                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
12930                 FREE((void*)_res_conv_9);
12931                 _res_constr.data[j] = _res_conv_9_conv;
12932         }
12933         CVec_BalanceZ_free(_res_constr);
12934 }
12935
12936 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
12937         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12938         CHECK_ACCESS(o_ptr);
12939         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
12940         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
12941         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
12942         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
12943         return (uint64_t)ret_conv;
12944 }
12945
12946 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
12947         LDKDecodeError e_conv;
12948         e_conv.inner = (void*)(e & (~1));
12949         e_conv.is_owned = (e & 1) || (e == 0);
12950         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12951         e_conv = DecodeError_clone(&e_conv);
12952         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
12953         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
12954         return (uint64_t)ret_conv;
12955 }
12956
12957 jboolean  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
12958         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
12959         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
12960         return ret_val;
12961 }
12962
12963 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
12964         if ((_res & 1) != 0) return;
12965         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12966         CHECK_ACCESS(_res_ptr);
12967         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
12968         FREE((void*)_res);
12969         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
12970 }
12971
12972 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
12973         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
12974         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
12975         return (uint64_t)ret_conv;
12976 }
12977 int64_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
12978         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
12979         int64_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
12980         return ret_val;
12981 }
12982
12983 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
12984         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
12985         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
12986         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
12987         return (uint64_t)ret_conv;
12988 }
12989
12990 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
12991         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12992         *ret_conv = CResult_NoneLightningErrorZ_ok();
12993         return (uint64_t)ret_conv;
12994 }
12995
12996 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
12997         LDKLightningError e_conv;
12998         e_conv.inner = (void*)(e & (~1));
12999         e_conv.is_owned = (e & 1) || (e == 0);
13000         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13001         e_conv = LightningError_clone(&e_conv);
13002         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13003         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
13004         return (uint64_t)ret_conv;
13005 }
13006
13007 jboolean  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
13008         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
13009         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
13010         return ret_val;
13011 }
13012
13013 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
13014         if ((_res & 1) != 0) return;
13015         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13016         CHECK_ACCESS(_res_ptr);
13017         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
13018         FREE((void*)_res);
13019         CResult_NoneLightningErrorZ_free(_res_conv);
13020 }
13021
13022 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
13023         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13024         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
13025         return (uint64_t)ret_conv;
13026 }
13027 int64_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
13028         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
13029         int64_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
13030         return ret_val;
13031 }
13032
13033 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
13034         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
13035         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13036         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
13037         return (uint64_t)ret_conv;
13038 }
13039
13040 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
13041         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13042         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
13043         return ((uint64_t)ret_conv);
13044 }
13045 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
13046         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
13047         int64_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
13048         return ret_val;
13049 }
13050
13051 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
13052         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
13053         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13054         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
13055         return ((uint64_t)ret_conv);
13056 }
13057
13058 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
13059         LDKPublicKey a_ref;
13060         CHECK(*((uint32_t*)a) == 33);
13061         memcpy(a_ref.compressed_form, (uint8_t*)(a + 4), 33);
13062         void* b_ptr = (void*)(((uint64_t)b) & ~1);
13063         CHECK_ACCESS(b_ptr);
13064         LDKType b_conv = *(LDKType*)(b_ptr);
13065         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13066         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
13067         return ((uint64_t)ret_conv);
13068 }
13069
13070 void  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
13071         if ((_res & 1) != 0) return;
13072         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13073         CHECK_ACCESS(_res_ptr);
13074         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
13075         FREE((void*)_res);
13076         C2Tuple_PublicKeyTypeZ_free(_res_conv);
13077 }
13078
13079 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
13080         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
13081         _res_constr.datalen = *((uint32_t*)_res);
13082         if (_res_constr.datalen > 0)
13083                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
13084         else
13085                 _res_constr.data = NULL;
13086         uint32_t* _res_vals = (uint32_t*)(_res + 4);
13087         for (size_t z = 0; z < _res_constr.datalen; z++) {
13088                 uint32_t _res_conv_25 = _res_vals[z];
13089                 void* _res_conv_25_ptr = (void*)(((uint64_t)_res_conv_25) & ~1);
13090                 CHECK_ACCESS(_res_conv_25_ptr);
13091                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
13092                 FREE((void*)_res_conv_25);
13093                 _res_constr.data[z] = _res_conv_25_conv;
13094         }
13095         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
13096 }
13097
13098 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
13099         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13100         *ret_conv = CResult_boolLightningErrorZ_ok(o);
13101         return (uint64_t)ret_conv;
13102 }
13103
13104 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
13105         LDKLightningError e_conv;
13106         e_conv.inner = (void*)(e & (~1));
13107         e_conv.is_owned = (e & 1) || (e == 0);
13108         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13109         e_conv = LightningError_clone(&e_conv);
13110         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13111         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
13112         return (uint64_t)ret_conv;
13113 }
13114
13115 jboolean  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
13116         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
13117         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
13118         return ret_val;
13119 }
13120
13121 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
13122         if ((_res & 1) != 0) return;
13123         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13124         CHECK_ACCESS(_res_ptr);
13125         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
13126         FREE((void*)_res);
13127         CResult_boolLightningErrorZ_free(_res_conv);
13128 }
13129
13130 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
13131         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13132         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
13133         return (uint64_t)ret_conv;
13134 }
13135 int64_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
13136         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
13137         int64_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
13138         return ret_val;
13139 }
13140
13141 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
13142         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
13143         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13144         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
13145         return (uint64_t)ret_conv;
13146 }
13147
13148 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
13149         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13150         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
13151         return ((uint64_t)ret_conv);
13152 }
13153 int64_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
13154         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
13155         int64_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
13156         return ret_val;
13157 }
13158
13159 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
13160         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
13161         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13162         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
13163         return ((uint64_t)ret_conv);
13164 }
13165
13166 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
13167         LDKChannelAnnouncement a_conv;
13168         a_conv.inner = (void*)(a & (~1));
13169         a_conv.is_owned = (a & 1) || (a == 0);
13170         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
13171         a_conv = ChannelAnnouncement_clone(&a_conv);
13172         LDKChannelUpdate b_conv;
13173         b_conv.inner = (void*)(b & (~1));
13174         b_conv.is_owned = (b & 1) || (b == 0);
13175         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
13176         b_conv = ChannelUpdate_clone(&b_conv);
13177         LDKChannelUpdate c_conv;
13178         c_conv.inner = (void*)(c & (~1));
13179         c_conv.is_owned = (c & 1) || (c == 0);
13180         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
13181         c_conv = ChannelUpdate_clone(&c_conv);
13182         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13183         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
13184         return ((uint64_t)ret_conv);
13185 }
13186
13187 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
13188         if ((_res & 1) != 0) return;
13189         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13190         CHECK_ACCESS(_res_ptr);
13191         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
13192         FREE((void*)_res);
13193         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
13194 }
13195
13196 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
13197         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
13198         _res_constr.datalen = *((uint32_t*)_res);
13199         if (_res_constr.datalen > 0)
13200                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
13201         else
13202                 _res_constr.data = NULL;
13203         uint32_t* _res_vals = (uint32_t*)(_res + 4);
13204         for (size_t h = 0; h < _res_constr.datalen; h++) {
13205                 uint32_t _res_conv_59 = _res_vals[h];
13206                 void* _res_conv_59_ptr = (void*)(((uint64_t)_res_conv_59) & ~1);
13207                 CHECK_ACCESS(_res_conv_59_ptr);
13208                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
13209                 FREE((void*)_res_conv_59);
13210                 _res_constr.data[h] = _res_conv_59_conv;
13211         }
13212         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
13213 }
13214
13215 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
13216         LDKCVec_NodeAnnouncementZ _res_constr;
13217         _res_constr.datalen = *((uint32_t*)_res);
13218         if (_res_constr.datalen > 0)
13219                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
13220         else
13221                 _res_constr.data = NULL;
13222         uint32_t* _res_vals = (uint32_t*)(_res + 4);
13223         for (size_t s = 0; s < _res_constr.datalen; s++) {
13224                 uint32_t _res_conv_18 = _res_vals[s];
13225                 LDKNodeAnnouncement _res_conv_18_conv;
13226                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
13227                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
13228                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
13229                 _res_constr.data[s] = _res_conv_18_conv;
13230         }
13231         CVec_NodeAnnouncementZ_free(_res_constr);
13232 }
13233
13234 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
13235         LDKCVec_PublicKeyZ _res_constr;
13236         _res_constr.datalen = *((uint32_t*)_res);
13237         if (_res_constr.datalen > 0)
13238                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
13239         else
13240                 _res_constr.data = NULL;
13241         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
13242         for (size_t m = 0; m < _res_constr.datalen; m++) {
13243                 int8_tArray _res_conv_12 = _res_vals[m];
13244                 LDKPublicKey _res_conv_12_ref;
13245                 CHECK(*((uint32_t*)_res_conv_12) == 33);
13246                 memcpy(_res_conv_12_ref.compressed_form, (uint8_t*)(_res_conv_12 + 4), 33);
13247                 _res_constr.data[m] = _res_conv_12_ref;
13248         }
13249         CVec_PublicKeyZ_free(_res_constr);
13250 }
13251
13252 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
13253         LDKCVec_u8Z o_ref;
13254         o_ref.datalen = *((uint32_t*)o);
13255         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
13256         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
13257         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13258         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
13259         return (uint64_t)ret_conv;
13260 }
13261
13262 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
13263         LDKPeerHandleError e_conv;
13264         e_conv.inner = (void*)(e & (~1));
13265         e_conv.is_owned = (e & 1) || (e == 0);
13266         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13267         e_conv = PeerHandleError_clone(&e_conv);
13268         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13269         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
13270         return (uint64_t)ret_conv;
13271 }
13272
13273 jboolean  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
13274         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
13275         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
13276         return ret_val;
13277 }
13278
13279 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
13280         if ((_res & 1) != 0) return;
13281         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13282         CHECK_ACCESS(_res_ptr);
13283         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
13284         FREE((void*)_res);
13285         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
13286 }
13287
13288 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
13289         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13290         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
13291         return (uint64_t)ret_conv;
13292 }
13293 int64_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
13294         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
13295         int64_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
13296         return ret_val;
13297 }
13298
13299 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
13300         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
13301         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13302         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
13303         return (uint64_t)ret_conv;
13304 }
13305
13306 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
13307         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13308         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
13309         return (uint64_t)ret_conv;
13310 }
13311
13312 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
13313         LDKPeerHandleError e_conv;
13314         e_conv.inner = (void*)(e & (~1));
13315         e_conv.is_owned = (e & 1) || (e == 0);
13316         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13317         e_conv = PeerHandleError_clone(&e_conv);
13318         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13319         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
13320         return (uint64_t)ret_conv;
13321 }
13322
13323 jboolean  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
13324         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
13325         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
13326         return ret_val;
13327 }
13328
13329 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
13330         if ((_res & 1) != 0) return;
13331         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13332         CHECK_ACCESS(_res_ptr);
13333         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
13334         FREE((void*)_res);
13335         CResult_NonePeerHandleErrorZ_free(_res_conv);
13336 }
13337
13338 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
13339         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13340         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
13341         return (uint64_t)ret_conv;
13342 }
13343 int64_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
13344         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
13345         int64_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
13346         return ret_val;
13347 }
13348
13349 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
13350         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
13351         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13352         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
13353         return (uint64_t)ret_conv;
13354 }
13355
13356 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
13357         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
13358         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
13359         return (uint64_t)ret_conv;
13360 }
13361
13362 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
13363         LDKPeerHandleError e_conv;
13364         e_conv.inner = (void*)(e & (~1));
13365         e_conv.is_owned = (e & 1) || (e == 0);
13366         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13367         e_conv = PeerHandleError_clone(&e_conv);
13368         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
13369         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
13370         return (uint64_t)ret_conv;
13371 }
13372
13373 jboolean  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
13374         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
13375         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
13376         return ret_val;
13377 }
13378
13379 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
13380         if ((_res & 1) != 0) return;
13381         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13382         CHECK_ACCESS(_res_ptr);
13383         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
13384         FREE((void*)_res);
13385         CResult_boolPeerHandleErrorZ_free(_res_conv);
13386 }
13387
13388 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
13389         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
13390         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
13391         return (uint64_t)ret_conv;
13392 }
13393 int64_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
13394         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
13395         int64_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
13396         return ret_val;
13397 }
13398
13399 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
13400         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
13401         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
13402         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
13403         return (uint64_t)ret_conv;
13404 }
13405
13406 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
13407         LDKNodeId o_conv;
13408         o_conv.inner = (void*)(o & (~1));
13409         o_conv.is_owned = (o & 1) || (o == 0);
13410         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13411         o_conv = NodeId_clone(&o_conv);
13412         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13413         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
13414         return (uint64_t)ret_conv;
13415 }
13416
13417 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
13418         LDKDecodeError e_conv;
13419         e_conv.inner = (void*)(e & (~1));
13420         e_conv.is_owned = (e & 1) || (e == 0);
13421         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13422         e_conv = DecodeError_clone(&e_conv);
13423         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13424         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
13425         return (uint64_t)ret_conv;
13426 }
13427
13428 jboolean  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
13429         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
13430         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
13431         return ret_val;
13432 }
13433
13434 void  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
13435         if ((_res & 1) != 0) return;
13436         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13437         CHECK_ACCESS(_res_ptr);
13438         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
13439         FREE((void*)_res);
13440         CResult_NodeIdDecodeErrorZ_free(_res_conv);
13441 }
13442
13443 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
13444         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13445         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
13446         return (uint64_t)ret_conv;
13447 }
13448 int64_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
13449         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
13450         int64_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
13451         return ret_val;
13452 }
13453
13454 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
13455         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
13456         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13457         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
13458         return (uint64_t)ret_conv;
13459 }
13460
13461 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
13462         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13463         CHECK_ACCESS(o_ptr);
13464         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
13465         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)o) & ~1));
13466         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13467         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
13468         return (uint64_t)ret_conv;
13469 }
13470
13471 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
13472         LDKDecodeError e_conv;
13473         e_conv.inner = (void*)(e & (~1));
13474         e_conv.is_owned = (e & 1) || (e == 0);
13475         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13476         e_conv = DecodeError_clone(&e_conv);
13477         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13478         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
13479         return (uint64_t)ret_conv;
13480 }
13481
13482 jboolean  __attribute__((visibility("default"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
13483         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
13484         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
13485         return ret_val;
13486 }
13487
13488 void  __attribute__((visibility("default"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
13489         if ((_res & 1) != 0) return;
13490         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13491         CHECK_ACCESS(_res_ptr);
13492         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
13493         FREE((void*)_res);
13494         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
13495 }
13496
13497 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
13498         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13499         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
13500         return (uint64_t)ret_conv;
13501 }
13502 int64_t  __attribute__((visibility("default"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
13503         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
13504         int64_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
13505         return ret_val;
13506 }
13507
13508 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
13509         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
13510         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13511         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
13512         return (uint64_t)ret_conv;
13513 }
13514
13515 uint32_t  __attribute__((visibility("default"))) TS_COption_AccessZ_some(uint32_t o) {
13516         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13517         CHECK_ACCESS(o_ptr);
13518         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
13519         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
13520         *ret_copy = COption_AccessZ_some(o_conv);
13521         uint64_t ret_ref = (uint64_t)ret_copy;
13522         return ret_ref;
13523 }
13524
13525 uint32_t  __attribute__((visibility("default"))) TS_COption_AccessZ_none() {
13526         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
13527         *ret_copy = COption_AccessZ_none();
13528         uint64_t ret_ref = (uint64_t)ret_copy;
13529         return ret_ref;
13530 }
13531
13532 void  __attribute__((visibility("default"))) TS_COption_AccessZ_free(uint32_t _res) {
13533         if ((_res & 1) != 0) return;
13534         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13535         CHECK_ACCESS(_res_ptr);
13536         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
13537         FREE((void*)_res);
13538         COption_AccessZ_free(_res_conv);
13539 }
13540
13541 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
13542         LDKDirectionalChannelInfo o_conv;
13543         o_conv.inner = (void*)(o & (~1));
13544         o_conv.is_owned = (o & 1) || (o == 0);
13545         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13546         o_conv = DirectionalChannelInfo_clone(&o_conv);
13547         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
13548         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
13549         return (uint64_t)ret_conv;
13550 }
13551
13552 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
13553         LDKDecodeError e_conv;
13554         e_conv.inner = (void*)(e & (~1));
13555         e_conv.is_owned = (e & 1) || (e == 0);
13556         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13557         e_conv = DecodeError_clone(&e_conv);
13558         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
13559         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
13560         return (uint64_t)ret_conv;
13561 }
13562
13563 jboolean  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
13564         LDKCResult_DirectionalChannelInfoDecodeErrorZ* o_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(o & ~1);
13565         jboolean ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(o_conv);
13566         return ret_val;
13567 }
13568
13569 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
13570         if ((_res & 1) != 0) return;
13571         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13572         CHECK_ACCESS(_res_ptr);
13573         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(_res_ptr);
13574         FREE((void*)_res);
13575         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
13576 }
13577
13578 static inline uint64_t CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
13579         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
13580         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(arg);
13581         return (uint64_t)ret_conv;
13582 }
13583 int64_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
13584         LDKCResult_DirectionalChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
13585         int64_t ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
13586         return ret_val;
13587 }
13588
13589 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
13590         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
13591         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
13592         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
13593         return (uint64_t)ret_conv;
13594 }
13595
13596 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
13597         LDKChannelInfo o_conv;
13598         o_conv.inner = (void*)(o & (~1));
13599         o_conv.is_owned = (o & 1) || (o == 0);
13600         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13601         o_conv = ChannelInfo_clone(&o_conv);
13602         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
13603         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
13604         return (uint64_t)ret_conv;
13605 }
13606
13607 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
13608         LDKDecodeError e_conv;
13609         e_conv.inner = (void*)(e & (~1));
13610         e_conv.is_owned = (e & 1) || (e == 0);
13611         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13612         e_conv = DecodeError_clone(&e_conv);
13613         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
13614         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
13615         return (uint64_t)ret_conv;
13616 }
13617
13618 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
13619         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
13620         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
13621         return ret_val;
13622 }
13623
13624 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
13625         if ((_res & 1) != 0) return;
13626         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13627         CHECK_ACCESS(_res_ptr);
13628         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
13629         FREE((void*)_res);
13630         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
13631 }
13632
13633 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
13634         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
13635         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
13636         return (uint64_t)ret_conv;
13637 }
13638 int64_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
13639         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
13640         int64_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
13641         return ret_val;
13642 }
13643
13644 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
13645         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
13646         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
13647         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
13648         return (uint64_t)ret_conv;
13649 }
13650
13651 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
13652         LDKRoutingFees o_conv;
13653         o_conv.inner = (void*)(o & (~1));
13654         o_conv.is_owned = (o & 1) || (o == 0);
13655         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13656         o_conv = RoutingFees_clone(&o_conv);
13657         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
13658         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
13659         return (uint64_t)ret_conv;
13660 }
13661
13662 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
13663         LDKDecodeError e_conv;
13664         e_conv.inner = (void*)(e & (~1));
13665         e_conv.is_owned = (e & 1) || (e == 0);
13666         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13667         e_conv = DecodeError_clone(&e_conv);
13668         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
13669         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
13670         return (uint64_t)ret_conv;
13671 }
13672
13673 jboolean  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
13674         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
13675         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
13676         return ret_val;
13677 }
13678
13679 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
13680         if ((_res & 1) != 0) return;
13681         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13682         CHECK_ACCESS(_res_ptr);
13683         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
13684         FREE((void*)_res);
13685         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
13686 }
13687
13688 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
13689         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
13690         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
13691         return (uint64_t)ret_conv;
13692 }
13693 int64_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
13694         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
13695         int64_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
13696         return ret_val;
13697 }
13698
13699 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
13700         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
13701         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
13702         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
13703         return (uint64_t)ret_conv;
13704 }
13705
13706 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
13707         LDKNodeAnnouncementInfo o_conv;
13708         o_conv.inner = (void*)(o & (~1));
13709         o_conv.is_owned = (o & 1) || (o == 0);
13710         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13711         o_conv = NodeAnnouncementInfo_clone(&o_conv);
13712         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
13713         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
13714         return (uint64_t)ret_conv;
13715 }
13716
13717 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
13718         LDKDecodeError e_conv;
13719         e_conv.inner = (void*)(e & (~1));
13720         e_conv.is_owned = (e & 1) || (e == 0);
13721         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13722         e_conv = DecodeError_clone(&e_conv);
13723         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
13724         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
13725         return (uint64_t)ret_conv;
13726 }
13727
13728 jboolean  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
13729         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
13730         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
13731         return ret_val;
13732 }
13733
13734 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
13735         if ((_res & 1) != 0) return;
13736         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13737         CHECK_ACCESS(_res_ptr);
13738         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
13739         FREE((void*)_res);
13740         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
13741 }
13742
13743 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
13744         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
13745         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
13746         return (uint64_t)ret_conv;
13747 }
13748 int64_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
13749         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
13750         int64_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
13751         return ret_val;
13752 }
13753
13754 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
13755         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
13756         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
13757         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
13758         return (uint64_t)ret_conv;
13759 }
13760
13761 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
13762         LDKCVec_u64Z _res_constr;
13763         _res_constr.datalen = *((uint32_t*)_res);
13764         if (_res_constr.datalen > 0)
13765                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
13766         else
13767                 _res_constr.data = NULL;
13768         int64_t* _res_vals = (int64_t*)(_res + 4);
13769         for (size_t i = 0; i < _res_constr.datalen; i++) {
13770                 int64_t _res_conv_8 = _res_vals[i];
13771                 _res_constr.data[i] = _res_conv_8;
13772         }
13773         CVec_u64Z_free(_res_constr);
13774 }
13775
13776 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
13777         LDKNodeInfo o_conv;
13778         o_conv.inner = (void*)(o & (~1));
13779         o_conv.is_owned = (o & 1) || (o == 0);
13780         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13781         o_conv = NodeInfo_clone(&o_conv);
13782         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
13783         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
13784         return (uint64_t)ret_conv;
13785 }
13786
13787 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
13788         LDKDecodeError e_conv;
13789         e_conv.inner = (void*)(e & (~1));
13790         e_conv.is_owned = (e & 1) || (e == 0);
13791         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13792         e_conv = DecodeError_clone(&e_conv);
13793         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
13794         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
13795         return (uint64_t)ret_conv;
13796 }
13797
13798 jboolean  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
13799         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
13800         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
13801         return ret_val;
13802 }
13803
13804 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
13805         if ((_res & 1) != 0) return;
13806         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13807         CHECK_ACCESS(_res_ptr);
13808         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
13809         FREE((void*)_res);
13810         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
13811 }
13812
13813 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
13814         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
13815         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
13816         return (uint64_t)ret_conv;
13817 }
13818 int64_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
13819         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
13820         int64_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
13821         return ret_val;
13822 }
13823
13824 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
13825         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
13826         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
13827         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
13828         return (uint64_t)ret_conv;
13829 }
13830
13831 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
13832         LDKNetworkGraph o_conv;
13833         o_conv.inner = (void*)(o & (~1));
13834         o_conv.is_owned = (o & 1) || (o == 0);
13835         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13836         o_conv = NetworkGraph_clone(&o_conv);
13837         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
13838         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
13839         return (uint64_t)ret_conv;
13840 }
13841
13842 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
13843         LDKDecodeError e_conv;
13844         e_conv.inner = (void*)(e & (~1));
13845         e_conv.is_owned = (e & 1) || (e == 0);
13846         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13847         e_conv = DecodeError_clone(&e_conv);
13848         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
13849         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
13850         return (uint64_t)ret_conv;
13851 }
13852
13853 jboolean  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
13854         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
13855         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
13856         return ret_val;
13857 }
13858
13859 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
13860         if ((_res & 1) != 0) return;
13861         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13862         CHECK_ACCESS(_res_ptr);
13863         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
13864         FREE((void*)_res);
13865         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
13866 }
13867
13868 static inline uint64_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
13869         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
13870         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
13871         return (uint64_t)ret_conv;
13872 }
13873 int64_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr(uint32_t arg) {
13874         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
13875         int64_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
13876         return ret_val;
13877 }
13878
13879 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
13880         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
13881         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
13882         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
13883         return (uint64_t)ret_conv;
13884 }
13885
13886 uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
13887         LDKCVec_NetAddressZ o_constr;
13888         o_constr.datalen = *((uint32_t*)o);
13889         if (o_constr.datalen > 0)
13890                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
13891         else
13892                 o_constr.data = NULL;
13893         uint32_t* o_vals = (uint32_t*)(o + 4);
13894         for (size_t m = 0; m < o_constr.datalen; m++) {
13895                 uint32_t o_conv_12 = o_vals[m];
13896                 void* o_conv_12_ptr = (void*)(((uint64_t)o_conv_12) & ~1);
13897                 CHECK_ACCESS(o_conv_12_ptr);
13898                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
13899                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o_conv_12) & ~1));
13900                 o_constr.data[m] = o_conv_12_conv;
13901         }
13902         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
13903         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
13904         uint64_t ret_ref = (uint64_t)ret_copy;
13905         return ret_ref;
13906 }
13907
13908 uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_none() {
13909         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
13910         *ret_copy = COption_CVec_NetAddressZZ_none();
13911         uint64_t ret_ref = (uint64_t)ret_copy;
13912         return ret_ref;
13913 }
13914
13915 void  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
13916         if ((_res & 1) != 0) return;
13917         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13918         CHECK_ACCESS(_res_ptr);
13919         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
13920         FREE((void*)_res);
13921         COption_CVec_NetAddressZZ_free(_res_conv);
13922 }
13923
13924 static inline uint64_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
13925         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
13926         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
13927 uint64_t ret_ref = (uint64_t)ret_copy;
13928         return ret_ref;
13929 }
13930 int64_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
13931         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
13932         int64_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
13933         return ret_val;
13934 }
13935
13936 uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
13937         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
13938         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
13939         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
13940         uint64_t ret_ref = (uint64_t)ret_copy;
13941         return ret_ref;
13942 }
13943
13944 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
13945         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13946         CHECK_ACCESS(o_ptr);
13947         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
13948         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
13949         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13950         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
13951         return (uint64_t)ret_conv;
13952 }
13953
13954 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
13955         LDKDecodeError e_conv;
13956         e_conv.inner = (void*)(e & (~1));
13957         e_conv.is_owned = (e & 1) || (e == 0);
13958         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13959         e_conv = DecodeError_clone(&e_conv);
13960         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13961         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
13962         return (uint64_t)ret_conv;
13963 }
13964
13965 jboolean  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
13966         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
13967         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
13968         return ret_val;
13969 }
13970
13971 void  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
13972         if ((_res & 1) != 0) return;
13973         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13974         CHECK_ACCESS(_res_ptr);
13975         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
13976         FREE((void*)_res);
13977         CResult_NetAddressDecodeErrorZ_free(_res_conv);
13978 }
13979
13980 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
13981         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13982         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
13983         return (uint64_t)ret_conv;
13984 }
13985 int64_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
13986         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
13987         int64_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
13988         return ret_val;
13989 }
13990
13991 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
13992         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
13993         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13994         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
13995         return (uint64_t)ret_conv;
13996 }
13997
13998 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
13999         LDKCVec_UpdateAddHTLCZ _res_constr;
14000         _res_constr.datalen = *((uint32_t*)_res);
14001         if (_res_constr.datalen > 0)
14002                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
14003         else
14004                 _res_constr.data = NULL;
14005         uint32_t* _res_vals = (uint32_t*)(_res + 4);
14006         for (size_t p = 0; p < _res_constr.datalen; p++) {
14007                 uint32_t _res_conv_15 = _res_vals[p];
14008                 LDKUpdateAddHTLC _res_conv_15_conv;
14009                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
14010                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
14011                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
14012                 _res_constr.data[p] = _res_conv_15_conv;
14013         }
14014         CVec_UpdateAddHTLCZ_free(_res_constr);
14015 }
14016
14017 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
14018         LDKCVec_UpdateFulfillHTLCZ _res_constr;
14019         _res_constr.datalen = *((uint32_t*)_res);
14020         if (_res_constr.datalen > 0)
14021                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
14022         else
14023                 _res_constr.data = NULL;
14024         uint32_t* _res_vals = (uint32_t*)(_res + 4);
14025         for (size_t t = 0; t < _res_constr.datalen; t++) {
14026                 uint32_t _res_conv_19 = _res_vals[t];
14027                 LDKUpdateFulfillHTLC _res_conv_19_conv;
14028                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
14029                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
14030                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
14031                 _res_constr.data[t] = _res_conv_19_conv;
14032         }
14033         CVec_UpdateFulfillHTLCZ_free(_res_constr);
14034 }
14035
14036 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
14037         LDKCVec_UpdateFailHTLCZ _res_constr;
14038         _res_constr.datalen = *((uint32_t*)_res);
14039         if (_res_constr.datalen > 0)
14040                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
14041         else
14042                 _res_constr.data = NULL;
14043         uint32_t* _res_vals = (uint32_t*)(_res + 4);
14044         for (size_t q = 0; q < _res_constr.datalen; q++) {
14045                 uint32_t _res_conv_16 = _res_vals[q];
14046                 LDKUpdateFailHTLC _res_conv_16_conv;
14047                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
14048                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
14049                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
14050                 _res_constr.data[q] = _res_conv_16_conv;
14051         }
14052         CVec_UpdateFailHTLCZ_free(_res_constr);
14053 }
14054
14055 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
14056         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
14057         _res_constr.datalen = *((uint32_t*)_res);
14058         if (_res_constr.datalen > 0)
14059                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
14060         else
14061                 _res_constr.data = NULL;
14062         uint32_t* _res_vals = (uint32_t*)(_res + 4);
14063         for (size_t z = 0; z < _res_constr.datalen; z++) {
14064                 uint32_t _res_conv_25 = _res_vals[z];
14065                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
14066                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
14067                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
14068                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
14069                 _res_constr.data[z] = _res_conv_25_conv;
14070         }
14071         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
14072 }
14073
14074 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
14075         LDKAcceptChannel o_conv;
14076         o_conv.inner = (void*)(o & (~1));
14077         o_conv.is_owned = (o & 1) || (o == 0);
14078         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14079         o_conv = AcceptChannel_clone(&o_conv);
14080         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
14081         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
14082         return (uint64_t)ret_conv;
14083 }
14084
14085 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
14086         LDKDecodeError e_conv;
14087         e_conv.inner = (void*)(e & (~1));
14088         e_conv.is_owned = (e & 1) || (e == 0);
14089         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14090         e_conv = DecodeError_clone(&e_conv);
14091         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
14092         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
14093         return (uint64_t)ret_conv;
14094 }
14095
14096 jboolean  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
14097         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
14098         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
14099         return ret_val;
14100 }
14101
14102 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
14103         if ((_res & 1) != 0) return;
14104         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14105         CHECK_ACCESS(_res_ptr);
14106         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
14107         FREE((void*)_res);
14108         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
14109 }
14110
14111 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
14112         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
14113         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
14114         return (uint64_t)ret_conv;
14115 }
14116 int64_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
14117         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
14118         int64_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
14119         return ret_val;
14120 }
14121
14122 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
14123         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
14124         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
14125         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
14126         return (uint64_t)ret_conv;
14127 }
14128
14129 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
14130         LDKAnnouncementSignatures o_conv;
14131         o_conv.inner = (void*)(o & (~1));
14132         o_conv.is_owned = (o & 1) || (o == 0);
14133         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14134         o_conv = AnnouncementSignatures_clone(&o_conv);
14135         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
14136         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
14137         return (uint64_t)ret_conv;
14138 }
14139
14140 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
14141         LDKDecodeError e_conv;
14142         e_conv.inner = (void*)(e & (~1));
14143         e_conv.is_owned = (e & 1) || (e == 0);
14144         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14145         e_conv = DecodeError_clone(&e_conv);
14146         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
14147         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
14148         return (uint64_t)ret_conv;
14149 }
14150
14151 jboolean  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
14152         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
14153         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
14154         return ret_val;
14155 }
14156
14157 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
14158         if ((_res & 1) != 0) return;
14159         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14160         CHECK_ACCESS(_res_ptr);
14161         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
14162         FREE((void*)_res);
14163         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
14164 }
14165
14166 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
14167         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
14168         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
14169         return (uint64_t)ret_conv;
14170 }
14171 int64_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
14172         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
14173         int64_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
14174         return ret_val;
14175 }
14176
14177 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
14178         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
14179         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
14180         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
14181         return (uint64_t)ret_conv;
14182 }
14183
14184 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
14185         LDKChannelReestablish o_conv;
14186         o_conv.inner = (void*)(o & (~1));
14187         o_conv.is_owned = (o & 1) || (o == 0);
14188         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14189         o_conv = ChannelReestablish_clone(&o_conv);
14190         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
14191         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
14192         return (uint64_t)ret_conv;
14193 }
14194
14195 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
14196         LDKDecodeError e_conv;
14197         e_conv.inner = (void*)(e & (~1));
14198         e_conv.is_owned = (e & 1) || (e == 0);
14199         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14200         e_conv = DecodeError_clone(&e_conv);
14201         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
14202         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
14203         return (uint64_t)ret_conv;
14204 }
14205
14206 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
14207         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
14208         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
14209         return ret_val;
14210 }
14211
14212 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
14213         if ((_res & 1) != 0) return;
14214         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14215         CHECK_ACCESS(_res_ptr);
14216         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
14217         FREE((void*)_res);
14218         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
14219 }
14220
14221 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
14222         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
14223         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
14224         return (uint64_t)ret_conv;
14225 }
14226 int64_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
14227         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
14228         int64_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
14229         return ret_val;
14230 }
14231
14232 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
14233         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
14234         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
14235         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
14236         return (uint64_t)ret_conv;
14237 }
14238
14239 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
14240         LDKClosingSigned o_conv;
14241         o_conv.inner = (void*)(o & (~1));
14242         o_conv.is_owned = (o & 1) || (o == 0);
14243         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14244         o_conv = ClosingSigned_clone(&o_conv);
14245         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
14246         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
14247         return (uint64_t)ret_conv;
14248 }
14249
14250 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
14251         LDKDecodeError e_conv;
14252         e_conv.inner = (void*)(e & (~1));
14253         e_conv.is_owned = (e & 1) || (e == 0);
14254         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14255         e_conv = DecodeError_clone(&e_conv);
14256         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
14257         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
14258         return (uint64_t)ret_conv;
14259 }
14260
14261 jboolean  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
14262         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
14263         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
14264         return ret_val;
14265 }
14266
14267 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
14268         if ((_res & 1) != 0) return;
14269         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14270         CHECK_ACCESS(_res_ptr);
14271         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
14272         FREE((void*)_res);
14273         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
14274 }
14275
14276 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
14277         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
14278         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
14279         return (uint64_t)ret_conv;
14280 }
14281 int64_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
14282         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
14283         int64_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
14284         return ret_val;
14285 }
14286
14287 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
14288         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
14289         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
14290         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
14291         return (uint64_t)ret_conv;
14292 }
14293
14294 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
14295         LDKClosingSignedFeeRange o_conv;
14296         o_conv.inner = (void*)(o & (~1));
14297         o_conv.is_owned = (o & 1) || (o == 0);
14298         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14299         o_conv = ClosingSignedFeeRange_clone(&o_conv);
14300         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
14301         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
14302         return (uint64_t)ret_conv;
14303 }
14304
14305 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
14306         LDKDecodeError e_conv;
14307         e_conv.inner = (void*)(e & (~1));
14308         e_conv.is_owned = (e & 1) || (e == 0);
14309         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14310         e_conv = DecodeError_clone(&e_conv);
14311         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
14312         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
14313         return (uint64_t)ret_conv;
14314 }
14315
14316 jboolean  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
14317         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
14318         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
14319         return ret_val;
14320 }
14321
14322 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
14323         if ((_res & 1) != 0) return;
14324         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14325         CHECK_ACCESS(_res_ptr);
14326         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
14327         FREE((void*)_res);
14328         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
14329 }
14330
14331 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
14332         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
14333         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
14334         return (uint64_t)ret_conv;
14335 }
14336 int64_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
14337         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
14338         int64_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
14339         return ret_val;
14340 }
14341
14342 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
14343         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
14344         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
14345         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
14346         return (uint64_t)ret_conv;
14347 }
14348
14349 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
14350         LDKCommitmentSigned o_conv;
14351         o_conv.inner = (void*)(o & (~1));
14352         o_conv.is_owned = (o & 1) || (o == 0);
14353         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14354         o_conv = CommitmentSigned_clone(&o_conv);
14355         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
14356         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
14357         return (uint64_t)ret_conv;
14358 }
14359
14360 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
14361         LDKDecodeError e_conv;
14362         e_conv.inner = (void*)(e & (~1));
14363         e_conv.is_owned = (e & 1) || (e == 0);
14364         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14365         e_conv = DecodeError_clone(&e_conv);
14366         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
14367         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
14368         return (uint64_t)ret_conv;
14369 }
14370
14371 jboolean  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
14372         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
14373         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
14374         return ret_val;
14375 }
14376
14377 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
14378         if ((_res & 1) != 0) return;
14379         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14380         CHECK_ACCESS(_res_ptr);
14381         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
14382         FREE((void*)_res);
14383         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
14384 }
14385
14386 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
14387         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
14388         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
14389         return (uint64_t)ret_conv;
14390 }
14391 int64_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
14392         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
14393         int64_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
14394         return ret_val;
14395 }
14396
14397 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
14398         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
14399         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
14400         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
14401         return (uint64_t)ret_conv;
14402 }
14403
14404 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
14405         LDKFundingCreated o_conv;
14406         o_conv.inner = (void*)(o & (~1));
14407         o_conv.is_owned = (o & 1) || (o == 0);
14408         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14409         o_conv = FundingCreated_clone(&o_conv);
14410         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
14411         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
14412         return (uint64_t)ret_conv;
14413 }
14414
14415 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
14416         LDKDecodeError e_conv;
14417         e_conv.inner = (void*)(e & (~1));
14418         e_conv.is_owned = (e & 1) || (e == 0);
14419         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14420         e_conv = DecodeError_clone(&e_conv);
14421         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
14422         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
14423         return (uint64_t)ret_conv;
14424 }
14425
14426 jboolean  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
14427         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
14428         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
14429         return ret_val;
14430 }
14431
14432 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
14433         if ((_res & 1) != 0) return;
14434         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14435         CHECK_ACCESS(_res_ptr);
14436         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
14437         FREE((void*)_res);
14438         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
14439 }
14440
14441 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
14442         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
14443         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
14444         return (uint64_t)ret_conv;
14445 }
14446 int64_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
14447         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
14448         int64_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
14449         return ret_val;
14450 }
14451
14452 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
14453         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
14454         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
14455         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
14456         return (uint64_t)ret_conv;
14457 }
14458
14459 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
14460         LDKFundingSigned o_conv;
14461         o_conv.inner = (void*)(o & (~1));
14462         o_conv.is_owned = (o & 1) || (o == 0);
14463         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14464         o_conv = FundingSigned_clone(&o_conv);
14465         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
14466         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
14467         return (uint64_t)ret_conv;
14468 }
14469
14470 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
14471         LDKDecodeError e_conv;
14472         e_conv.inner = (void*)(e & (~1));
14473         e_conv.is_owned = (e & 1) || (e == 0);
14474         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14475         e_conv = DecodeError_clone(&e_conv);
14476         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
14477         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
14478         return (uint64_t)ret_conv;
14479 }
14480
14481 jboolean  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
14482         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
14483         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
14484         return ret_val;
14485 }
14486
14487 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
14488         if ((_res & 1) != 0) return;
14489         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14490         CHECK_ACCESS(_res_ptr);
14491         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
14492         FREE((void*)_res);
14493         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
14494 }
14495
14496 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
14497         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
14498         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
14499         return (uint64_t)ret_conv;
14500 }
14501 int64_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
14502         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
14503         int64_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
14504         return ret_val;
14505 }
14506
14507 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
14508         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
14509         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
14510         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
14511         return (uint64_t)ret_conv;
14512 }
14513
14514 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
14515         LDKFundingLocked o_conv;
14516         o_conv.inner = (void*)(o & (~1));
14517         o_conv.is_owned = (o & 1) || (o == 0);
14518         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14519         o_conv = FundingLocked_clone(&o_conv);
14520         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
14521         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
14522         return (uint64_t)ret_conv;
14523 }
14524
14525 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
14526         LDKDecodeError e_conv;
14527         e_conv.inner = (void*)(e & (~1));
14528         e_conv.is_owned = (e & 1) || (e == 0);
14529         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14530         e_conv = DecodeError_clone(&e_conv);
14531         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
14532         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
14533         return (uint64_t)ret_conv;
14534 }
14535
14536 jboolean  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_is_ok(uint32_t o) {
14537         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
14538         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
14539         return ret_val;
14540 }
14541
14542 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
14543         if ((_res & 1) != 0) return;
14544         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14545         CHECK_ACCESS(_res_ptr);
14546         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
14547         FREE((void*)_res);
14548         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
14549 }
14550
14551 static inline uint64_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
14552         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
14553         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
14554         return (uint64_t)ret_conv;
14555 }
14556 int64_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone_ptr(uint32_t arg) {
14557         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
14558         int64_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
14559         return ret_val;
14560 }
14561
14562 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
14563         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
14564         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
14565         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
14566         return (uint64_t)ret_conv;
14567 }
14568
14569 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
14570         LDKInit o_conv;
14571         o_conv.inner = (void*)(o & (~1));
14572         o_conv.is_owned = (o & 1) || (o == 0);
14573         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14574         o_conv = Init_clone(&o_conv);
14575         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
14576         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
14577         return (uint64_t)ret_conv;
14578 }
14579
14580 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
14581         LDKDecodeError e_conv;
14582         e_conv.inner = (void*)(e & (~1));
14583         e_conv.is_owned = (e & 1) || (e == 0);
14584         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14585         e_conv = DecodeError_clone(&e_conv);
14586         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
14587         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
14588         return (uint64_t)ret_conv;
14589 }
14590
14591 jboolean  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
14592         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
14593         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
14594         return ret_val;
14595 }
14596
14597 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
14598         if ((_res & 1) != 0) return;
14599         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14600         CHECK_ACCESS(_res_ptr);
14601         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
14602         FREE((void*)_res);
14603         CResult_InitDecodeErrorZ_free(_res_conv);
14604 }
14605
14606 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
14607         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
14608         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
14609         return (uint64_t)ret_conv;
14610 }
14611 int64_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
14612         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
14613         int64_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
14614         return ret_val;
14615 }
14616
14617 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
14618         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
14619         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
14620         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
14621         return (uint64_t)ret_conv;
14622 }
14623
14624 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
14625         LDKOpenChannel o_conv;
14626         o_conv.inner = (void*)(o & (~1));
14627         o_conv.is_owned = (o & 1) || (o == 0);
14628         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14629         o_conv = OpenChannel_clone(&o_conv);
14630         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
14631         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
14632         return (uint64_t)ret_conv;
14633 }
14634
14635 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
14636         LDKDecodeError e_conv;
14637         e_conv.inner = (void*)(e & (~1));
14638         e_conv.is_owned = (e & 1) || (e == 0);
14639         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14640         e_conv = DecodeError_clone(&e_conv);
14641         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
14642         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
14643         return (uint64_t)ret_conv;
14644 }
14645
14646 jboolean  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
14647         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
14648         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
14649         return ret_val;
14650 }
14651
14652 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
14653         if ((_res & 1) != 0) return;
14654         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14655         CHECK_ACCESS(_res_ptr);
14656         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
14657         FREE((void*)_res);
14658         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
14659 }
14660
14661 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
14662         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
14663         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
14664         return (uint64_t)ret_conv;
14665 }
14666 int64_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
14667         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
14668         int64_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
14669         return ret_val;
14670 }
14671
14672 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
14673         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
14674         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
14675         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
14676         return (uint64_t)ret_conv;
14677 }
14678
14679 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
14680         LDKRevokeAndACK o_conv;
14681         o_conv.inner = (void*)(o & (~1));
14682         o_conv.is_owned = (o & 1) || (o == 0);
14683         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14684         o_conv = RevokeAndACK_clone(&o_conv);
14685         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
14686         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
14687         return (uint64_t)ret_conv;
14688 }
14689
14690 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
14691         LDKDecodeError e_conv;
14692         e_conv.inner = (void*)(e & (~1));
14693         e_conv.is_owned = (e & 1) || (e == 0);
14694         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14695         e_conv = DecodeError_clone(&e_conv);
14696         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
14697         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
14698         return (uint64_t)ret_conv;
14699 }
14700
14701 jboolean  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
14702         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
14703         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
14704         return ret_val;
14705 }
14706
14707 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
14708         if ((_res & 1) != 0) return;
14709         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14710         CHECK_ACCESS(_res_ptr);
14711         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
14712         FREE((void*)_res);
14713         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
14714 }
14715
14716 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
14717         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
14718         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
14719         return (uint64_t)ret_conv;
14720 }
14721 int64_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
14722         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
14723         int64_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
14724         return ret_val;
14725 }
14726
14727 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
14728         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
14729         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
14730         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
14731         return (uint64_t)ret_conv;
14732 }
14733
14734 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
14735         LDKShutdown o_conv;
14736         o_conv.inner = (void*)(o & (~1));
14737         o_conv.is_owned = (o & 1) || (o == 0);
14738         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14739         o_conv = Shutdown_clone(&o_conv);
14740         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
14741         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
14742         return (uint64_t)ret_conv;
14743 }
14744
14745 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
14746         LDKDecodeError e_conv;
14747         e_conv.inner = (void*)(e & (~1));
14748         e_conv.is_owned = (e & 1) || (e == 0);
14749         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14750         e_conv = DecodeError_clone(&e_conv);
14751         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
14752         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
14753         return (uint64_t)ret_conv;
14754 }
14755
14756 jboolean  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
14757         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
14758         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
14759         return ret_val;
14760 }
14761
14762 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
14763         if ((_res & 1) != 0) return;
14764         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14765         CHECK_ACCESS(_res_ptr);
14766         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
14767         FREE((void*)_res);
14768         CResult_ShutdownDecodeErrorZ_free(_res_conv);
14769 }
14770
14771 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
14772         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
14773         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
14774         return (uint64_t)ret_conv;
14775 }
14776 int64_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
14777         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
14778         int64_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
14779         return ret_val;
14780 }
14781
14782 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
14783         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
14784         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
14785         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
14786         return (uint64_t)ret_conv;
14787 }
14788
14789 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
14790         LDKUpdateFailHTLC o_conv;
14791         o_conv.inner = (void*)(o & (~1));
14792         o_conv.is_owned = (o & 1) || (o == 0);
14793         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14794         o_conv = UpdateFailHTLC_clone(&o_conv);
14795         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
14796         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
14797         return (uint64_t)ret_conv;
14798 }
14799
14800 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
14801         LDKDecodeError e_conv;
14802         e_conv.inner = (void*)(e & (~1));
14803         e_conv.is_owned = (e & 1) || (e == 0);
14804         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14805         e_conv = DecodeError_clone(&e_conv);
14806         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
14807         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
14808         return (uint64_t)ret_conv;
14809 }
14810
14811 jboolean  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
14812         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
14813         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
14814         return ret_val;
14815 }
14816
14817 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
14818         if ((_res & 1) != 0) return;
14819         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14820         CHECK_ACCESS(_res_ptr);
14821         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
14822         FREE((void*)_res);
14823         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
14824 }
14825
14826 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
14827         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
14828         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
14829         return (uint64_t)ret_conv;
14830 }
14831 int64_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
14832         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
14833         int64_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
14834         return ret_val;
14835 }
14836
14837 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
14838         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
14839         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
14840         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
14841         return (uint64_t)ret_conv;
14842 }
14843
14844 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
14845         LDKUpdateFailMalformedHTLC o_conv;
14846         o_conv.inner = (void*)(o & (~1));
14847         o_conv.is_owned = (o & 1) || (o == 0);
14848         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14849         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
14850         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
14851         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
14852         return (uint64_t)ret_conv;
14853 }
14854
14855 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
14856         LDKDecodeError e_conv;
14857         e_conv.inner = (void*)(e & (~1));
14858         e_conv.is_owned = (e & 1) || (e == 0);
14859         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14860         e_conv = DecodeError_clone(&e_conv);
14861         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
14862         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
14863         return (uint64_t)ret_conv;
14864 }
14865
14866 jboolean  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
14867         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
14868         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
14869         return ret_val;
14870 }
14871
14872 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
14873         if ((_res & 1) != 0) return;
14874         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14875         CHECK_ACCESS(_res_ptr);
14876         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
14877         FREE((void*)_res);
14878         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
14879 }
14880
14881 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
14882         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
14883         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
14884         return (uint64_t)ret_conv;
14885 }
14886 int64_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
14887         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
14888         int64_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
14889         return ret_val;
14890 }
14891
14892 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
14893         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
14894         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
14895         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
14896         return (uint64_t)ret_conv;
14897 }
14898
14899 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
14900         LDKUpdateFee o_conv;
14901         o_conv.inner = (void*)(o & (~1));
14902         o_conv.is_owned = (o & 1) || (o == 0);
14903         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14904         o_conv = UpdateFee_clone(&o_conv);
14905         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
14906         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
14907         return (uint64_t)ret_conv;
14908 }
14909
14910 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
14911         LDKDecodeError e_conv;
14912         e_conv.inner = (void*)(e & (~1));
14913         e_conv.is_owned = (e & 1) || (e == 0);
14914         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14915         e_conv = DecodeError_clone(&e_conv);
14916         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
14917         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
14918         return (uint64_t)ret_conv;
14919 }
14920
14921 jboolean  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
14922         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
14923         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
14924         return ret_val;
14925 }
14926
14927 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
14928         if ((_res & 1) != 0) return;
14929         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14930         CHECK_ACCESS(_res_ptr);
14931         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
14932         FREE((void*)_res);
14933         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
14934 }
14935
14936 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
14937         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
14938         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
14939         return (uint64_t)ret_conv;
14940 }
14941 int64_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
14942         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
14943         int64_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
14944         return ret_val;
14945 }
14946
14947 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
14948         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
14949         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
14950         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
14951         return (uint64_t)ret_conv;
14952 }
14953
14954 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
14955         LDKUpdateFulfillHTLC o_conv;
14956         o_conv.inner = (void*)(o & (~1));
14957         o_conv.is_owned = (o & 1) || (o == 0);
14958         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14959         o_conv = UpdateFulfillHTLC_clone(&o_conv);
14960         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14961         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
14962         return (uint64_t)ret_conv;
14963 }
14964
14965 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
14966         LDKDecodeError e_conv;
14967         e_conv.inner = (void*)(e & (~1));
14968         e_conv.is_owned = (e & 1) || (e == 0);
14969         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14970         e_conv = DecodeError_clone(&e_conv);
14971         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14972         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
14973         return (uint64_t)ret_conv;
14974 }
14975
14976 jboolean  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
14977         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
14978         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
14979         return ret_val;
14980 }
14981
14982 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
14983         if ((_res & 1) != 0) return;
14984         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14985         CHECK_ACCESS(_res_ptr);
14986         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
14987         FREE((void*)_res);
14988         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
14989 }
14990
14991 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
14992         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14993         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
14994         return (uint64_t)ret_conv;
14995 }
14996 int64_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
14997         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
14998         int64_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
14999         return ret_val;
15000 }
15001
15002 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
15003         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
15004         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
15005         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
15006         return (uint64_t)ret_conv;
15007 }
15008
15009 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
15010         LDKUpdateAddHTLC o_conv;
15011         o_conv.inner = (void*)(o & (~1));
15012         o_conv.is_owned = (o & 1) || (o == 0);
15013         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15014         o_conv = UpdateAddHTLC_clone(&o_conv);
15015         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
15016         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
15017         return (uint64_t)ret_conv;
15018 }
15019
15020 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
15021         LDKDecodeError e_conv;
15022         e_conv.inner = (void*)(e & (~1));
15023         e_conv.is_owned = (e & 1) || (e == 0);
15024         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15025         e_conv = DecodeError_clone(&e_conv);
15026         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
15027         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
15028         return (uint64_t)ret_conv;
15029 }
15030
15031 jboolean  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
15032         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
15033         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
15034         return ret_val;
15035 }
15036
15037 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
15038         if ((_res & 1) != 0) return;
15039         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15040         CHECK_ACCESS(_res_ptr);
15041         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
15042         FREE((void*)_res);
15043         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
15044 }
15045
15046 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
15047         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
15048         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
15049         return (uint64_t)ret_conv;
15050 }
15051 int64_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
15052         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
15053         int64_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
15054         return ret_val;
15055 }
15056
15057 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
15058         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
15059         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
15060         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
15061         return (uint64_t)ret_conv;
15062 }
15063
15064 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
15065         LDKPing o_conv;
15066         o_conv.inner = (void*)(o & (~1));
15067         o_conv.is_owned = (o & 1) || (o == 0);
15068         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15069         o_conv = Ping_clone(&o_conv);
15070         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
15071         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
15072         return (uint64_t)ret_conv;
15073 }
15074
15075 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
15076         LDKDecodeError e_conv;
15077         e_conv.inner = (void*)(e & (~1));
15078         e_conv.is_owned = (e & 1) || (e == 0);
15079         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15080         e_conv = DecodeError_clone(&e_conv);
15081         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
15082         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
15083         return (uint64_t)ret_conv;
15084 }
15085
15086 jboolean  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
15087         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
15088         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
15089         return ret_val;
15090 }
15091
15092 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
15093         if ((_res & 1) != 0) return;
15094         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15095         CHECK_ACCESS(_res_ptr);
15096         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
15097         FREE((void*)_res);
15098         CResult_PingDecodeErrorZ_free(_res_conv);
15099 }
15100
15101 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
15102         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
15103         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
15104         return (uint64_t)ret_conv;
15105 }
15106 int64_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
15107         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
15108         int64_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
15109         return ret_val;
15110 }
15111
15112 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
15113         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
15114         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
15115         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
15116         return (uint64_t)ret_conv;
15117 }
15118
15119 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
15120         LDKPong o_conv;
15121         o_conv.inner = (void*)(o & (~1));
15122         o_conv.is_owned = (o & 1) || (o == 0);
15123         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15124         o_conv = Pong_clone(&o_conv);
15125         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
15126         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
15127         return (uint64_t)ret_conv;
15128 }
15129
15130 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
15131         LDKDecodeError e_conv;
15132         e_conv.inner = (void*)(e & (~1));
15133         e_conv.is_owned = (e & 1) || (e == 0);
15134         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15135         e_conv = DecodeError_clone(&e_conv);
15136         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
15137         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
15138         return (uint64_t)ret_conv;
15139 }
15140
15141 jboolean  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
15142         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
15143         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
15144         return ret_val;
15145 }
15146
15147 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
15148         if ((_res & 1) != 0) return;
15149         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15150         CHECK_ACCESS(_res_ptr);
15151         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
15152         FREE((void*)_res);
15153         CResult_PongDecodeErrorZ_free(_res_conv);
15154 }
15155
15156 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
15157         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
15158         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
15159         return (uint64_t)ret_conv;
15160 }
15161 int64_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
15162         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
15163         int64_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
15164         return ret_val;
15165 }
15166
15167 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
15168         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
15169         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
15170         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
15171         return (uint64_t)ret_conv;
15172 }
15173
15174 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
15175         LDKUnsignedChannelAnnouncement o_conv;
15176         o_conv.inner = (void*)(o & (~1));
15177         o_conv.is_owned = (o & 1) || (o == 0);
15178         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15179         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
15180         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
15181         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
15182         return (uint64_t)ret_conv;
15183 }
15184
15185 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
15186         LDKDecodeError e_conv;
15187         e_conv.inner = (void*)(e & (~1));
15188         e_conv.is_owned = (e & 1) || (e == 0);
15189         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15190         e_conv = DecodeError_clone(&e_conv);
15191         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
15192         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
15193         return (uint64_t)ret_conv;
15194 }
15195
15196 jboolean  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
15197         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
15198         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
15199         return ret_val;
15200 }
15201
15202 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
15203         if ((_res & 1) != 0) return;
15204         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15205         CHECK_ACCESS(_res_ptr);
15206         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
15207         FREE((void*)_res);
15208         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
15209 }
15210
15211 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
15212         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
15213         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
15214         return (uint64_t)ret_conv;
15215 }
15216 int64_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
15217         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
15218         int64_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
15219         return ret_val;
15220 }
15221
15222 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
15223         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
15224         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
15225         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
15226         return (uint64_t)ret_conv;
15227 }
15228
15229 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
15230         LDKChannelAnnouncement o_conv;
15231         o_conv.inner = (void*)(o & (~1));
15232         o_conv.is_owned = (o & 1) || (o == 0);
15233         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15234         o_conv = ChannelAnnouncement_clone(&o_conv);
15235         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
15236         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
15237         return (uint64_t)ret_conv;
15238 }
15239
15240 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
15241         LDKDecodeError e_conv;
15242         e_conv.inner = (void*)(e & (~1));
15243         e_conv.is_owned = (e & 1) || (e == 0);
15244         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15245         e_conv = DecodeError_clone(&e_conv);
15246         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
15247         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
15248         return (uint64_t)ret_conv;
15249 }
15250
15251 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
15252         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
15253         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
15254         return ret_val;
15255 }
15256
15257 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
15258         if ((_res & 1) != 0) return;
15259         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15260         CHECK_ACCESS(_res_ptr);
15261         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
15262         FREE((void*)_res);
15263         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
15264 }
15265
15266 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
15267         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
15268         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
15269         return (uint64_t)ret_conv;
15270 }
15271 int64_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
15272         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
15273         int64_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
15274         return ret_val;
15275 }
15276
15277 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
15278         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
15279         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
15280         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
15281         return (uint64_t)ret_conv;
15282 }
15283
15284 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
15285         LDKUnsignedChannelUpdate o_conv;
15286         o_conv.inner = (void*)(o & (~1));
15287         o_conv.is_owned = (o & 1) || (o == 0);
15288         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15289         o_conv = UnsignedChannelUpdate_clone(&o_conv);
15290         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
15291         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
15292         return (uint64_t)ret_conv;
15293 }
15294
15295 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
15296         LDKDecodeError e_conv;
15297         e_conv.inner = (void*)(e & (~1));
15298         e_conv.is_owned = (e & 1) || (e == 0);
15299         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15300         e_conv = DecodeError_clone(&e_conv);
15301         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
15302         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
15303         return (uint64_t)ret_conv;
15304 }
15305
15306 jboolean  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
15307         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
15308         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
15309         return ret_val;
15310 }
15311
15312 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
15313         if ((_res & 1) != 0) return;
15314         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15315         CHECK_ACCESS(_res_ptr);
15316         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
15317         FREE((void*)_res);
15318         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
15319 }
15320
15321 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
15322         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
15323         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
15324         return (uint64_t)ret_conv;
15325 }
15326 int64_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15327         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
15328         int64_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
15329         return ret_val;
15330 }
15331
15332 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
15333         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
15334         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
15335         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
15336         return (uint64_t)ret_conv;
15337 }
15338
15339 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
15340         LDKChannelUpdate o_conv;
15341         o_conv.inner = (void*)(o & (~1));
15342         o_conv.is_owned = (o & 1) || (o == 0);
15343         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15344         o_conv = ChannelUpdate_clone(&o_conv);
15345         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
15346         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
15347         return (uint64_t)ret_conv;
15348 }
15349
15350 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
15351         LDKDecodeError e_conv;
15352         e_conv.inner = (void*)(e & (~1));
15353         e_conv.is_owned = (e & 1) || (e == 0);
15354         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15355         e_conv = DecodeError_clone(&e_conv);
15356         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
15357         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
15358         return (uint64_t)ret_conv;
15359 }
15360
15361 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
15362         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
15363         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
15364         return ret_val;
15365 }
15366
15367 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
15368         if ((_res & 1) != 0) return;
15369         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15370         CHECK_ACCESS(_res_ptr);
15371         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
15372         FREE((void*)_res);
15373         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
15374 }
15375
15376 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
15377         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
15378         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
15379         return (uint64_t)ret_conv;
15380 }
15381 int64_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15382         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
15383         int64_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
15384         return ret_val;
15385 }
15386
15387 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
15388         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
15389         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
15390         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
15391         return (uint64_t)ret_conv;
15392 }
15393
15394 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
15395         LDKErrorMessage o_conv;
15396         o_conv.inner = (void*)(o & (~1));
15397         o_conv.is_owned = (o & 1) || (o == 0);
15398         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15399         o_conv = ErrorMessage_clone(&o_conv);
15400         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15401         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
15402         return (uint64_t)ret_conv;
15403 }
15404
15405 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
15406         LDKDecodeError e_conv;
15407         e_conv.inner = (void*)(e & (~1));
15408         e_conv.is_owned = (e & 1) || (e == 0);
15409         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15410         e_conv = DecodeError_clone(&e_conv);
15411         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15412         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
15413         return (uint64_t)ret_conv;
15414 }
15415
15416 jboolean  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
15417         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
15418         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
15419         return ret_val;
15420 }
15421
15422 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
15423         if ((_res & 1) != 0) return;
15424         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15425         CHECK_ACCESS(_res_ptr);
15426         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
15427         FREE((void*)_res);
15428         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
15429 }
15430
15431 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
15432         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15433         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
15434         return (uint64_t)ret_conv;
15435 }
15436 int64_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
15437         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
15438         int64_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
15439         return ret_val;
15440 }
15441
15442 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
15443         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
15444         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15445         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
15446         return (uint64_t)ret_conv;
15447 }
15448
15449 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
15450         LDKUnsignedNodeAnnouncement o_conv;
15451         o_conv.inner = (void*)(o & (~1));
15452         o_conv.is_owned = (o & 1) || (o == 0);
15453         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15454         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
15455         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15456         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
15457         return (uint64_t)ret_conv;
15458 }
15459
15460 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
15461         LDKDecodeError e_conv;
15462         e_conv.inner = (void*)(e & (~1));
15463         e_conv.is_owned = (e & 1) || (e == 0);
15464         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15465         e_conv = DecodeError_clone(&e_conv);
15466         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15467         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
15468         return (uint64_t)ret_conv;
15469 }
15470
15471 jboolean  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
15472         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
15473         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
15474         return ret_val;
15475 }
15476
15477 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
15478         if ((_res & 1) != 0) return;
15479         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15480         CHECK_ACCESS(_res_ptr);
15481         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
15482         FREE((void*)_res);
15483         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
15484 }
15485
15486 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
15487         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15488         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
15489         return (uint64_t)ret_conv;
15490 }
15491 int64_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
15492         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
15493         int64_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
15494         return ret_val;
15495 }
15496
15497 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
15498         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
15499         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15500         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
15501         return (uint64_t)ret_conv;
15502 }
15503
15504 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
15505         LDKNodeAnnouncement o_conv;
15506         o_conv.inner = (void*)(o & (~1));
15507         o_conv.is_owned = (o & 1) || (o == 0);
15508         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15509         o_conv = NodeAnnouncement_clone(&o_conv);
15510         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
15511         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
15512         return (uint64_t)ret_conv;
15513 }
15514
15515 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
15516         LDKDecodeError e_conv;
15517         e_conv.inner = (void*)(e & (~1));
15518         e_conv.is_owned = (e & 1) || (e == 0);
15519         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15520         e_conv = DecodeError_clone(&e_conv);
15521         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
15522         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
15523         return (uint64_t)ret_conv;
15524 }
15525
15526 jboolean  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
15527         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
15528         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
15529         return ret_val;
15530 }
15531
15532 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
15533         if ((_res & 1) != 0) return;
15534         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15535         CHECK_ACCESS(_res_ptr);
15536         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
15537         FREE((void*)_res);
15538         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
15539 }
15540
15541 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
15542         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
15543         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
15544         return (uint64_t)ret_conv;
15545 }
15546 int64_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
15547         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
15548         int64_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
15549         return ret_val;
15550 }
15551
15552 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
15553         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
15554         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
15555         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
15556         return (uint64_t)ret_conv;
15557 }
15558
15559 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
15560         LDKQueryShortChannelIds o_conv;
15561         o_conv.inner = (void*)(o & (~1));
15562         o_conv.is_owned = (o & 1) || (o == 0);
15563         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15564         o_conv = QueryShortChannelIds_clone(&o_conv);
15565         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
15566         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
15567         return (uint64_t)ret_conv;
15568 }
15569
15570 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
15571         LDKDecodeError e_conv;
15572         e_conv.inner = (void*)(e & (~1));
15573         e_conv.is_owned = (e & 1) || (e == 0);
15574         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15575         e_conv = DecodeError_clone(&e_conv);
15576         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
15577         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
15578         return (uint64_t)ret_conv;
15579 }
15580
15581 jboolean  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
15582         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
15583         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
15584         return ret_val;
15585 }
15586
15587 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
15588         if ((_res & 1) != 0) return;
15589         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15590         CHECK_ACCESS(_res_ptr);
15591         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
15592         FREE((void*)_res);
15593         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
15594 }
15595
15596 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
15597         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
15598         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
15599         return (uint64_t)ret_conv;
15600 }
15601 int64_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
15602         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
15603         int64_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
15604         return ret_val;
15605 }
15606
15607 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
15608         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
15609         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
15610         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
15611         return (uint64_t)ret_conv;
15612 }
15613
15614 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
15615         LDKReplyShortChannelIdsEnd o_conv;
15616         o_conv.inner = (void*)(o & (~1));
15617         o_conv.is_owned = (o & 1) || (o == 0);
15618         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15619         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
15620         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
15621         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
15622         return (uint64_t)ret_conv;
15623 }
15624
15625 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
15626         LDKDecodeError e_conv;
15627         e_conv.inner = (void*)(e & (~1));
15628         e_conv.is_owned = (e & 1) || (e == 0);
15629         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15630         e_conv = DecodeError_clone(&e_conv);
15631         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
15632         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
15633         return (uint64_t)ret_conv;
15634 }
15635
15636 jboolean  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
15637         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
15638         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
15639         return ret_val;
15640 }
15641
15642 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
15643         if ((_res & 1) != 0) return;
15644         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15645         CHECK_ACCESS(_res_ptr);
15646         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
15647         FREE((void*)_res);
15648         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
15649 }
15650
15651 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
15652         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
15653         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
15654         return (uint64_t)ret_conv;
15655 }
15656 int64_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
15657         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
15658         int64_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
15659         return ret_val;
15660 }
15661
15662 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
15663         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
15664         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
15665         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
15666         return (uint64_t)ret_conv;
15667 }
15668
15669 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
15670         LDKQueryChannelRange o_conv;
15671         o_conv.inner = (void*)(o & (~1));
15672         o_conv.is_owned = (o & 1) || (o == 0);
15673         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15674         o_conv = QueryChannelRange_clone(&o_conv);
15675         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
15676         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
15677         return (uint64_t)ret_conv;
15678 }
15679
15680 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
15681         LDKDecodeError e_conv;
15682         e_conv.inner = (void*)(e & (~1));
15683         e_conv.is_owned = (e & 1) || (e == 0);
15684         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15685         e_conv = DecodeError_clone(&e_conv);
15686         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
15687         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
15688         return (uint64_t)ret_conv;
15689 }
15690
15691 jboolean  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
15692         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
15693         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
15694         return ret_val;
15695 }
15696
15697 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
15698         if ((_res & 1) != 0) return;
15699         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15700         CHECK_ACCESS(_res_ptr);
15701         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
15702         FREE((void*)_res);
15703         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
15704 }
15705
15706 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
15707         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
15708         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
15709         return (uint64_t)ret_conv;
15710 }
15711 int64_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
15712         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
15713         int64_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
15714         return ret_val;
15715 }
15716
15717 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
15718         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
15719         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
15720         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
15721         return (uint64_t)ret_conv;
15722 }
15723
15724 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
15725         LDKReplyChannelRange o_conv;
15726         o_conv.inner = (void*)(o & (~1));
15727         o_conv.is_owned = (o & 1) || (o == 0);
15728         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15729         o_conv = ReplyChannelRange_clone(&o_conv);
15730         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
15731         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
15732         return (uint64_t)ret_conv;
15733 }
15734
15735 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
15736         LDKDecodeError e_conv;
15737         e_conv.inner = (void*)(e & (~1));
15738         e_conv.is_owned = (e & 1) || (e == 0);
15739         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15740         e_conv = DecodeError_clone(&e_conv);
15741         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
15742         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
15743         return (uint64_t)ret_conv;
15744 }
15745
15746 jboolean  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
15747         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
15748         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
15749         return ret_val;
15750 }
15751
15752 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
15753         if ((_res & 1) != 0) return;
15754         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15755         CHECK_ACCESS(_res_ptr);
15756         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
15757         FREE((void*)_res);
15758         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
15759 }
15760
15761 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
15762         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
15763         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
15764         return (uint64_t)ret_conv;
15765 }
15766 int64_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
15767         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
15768         int64_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
15769         return ret_val;
15770 }
15771
15772 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
15773         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
15774         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
15775         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
15776         return (uint64_t)ret_conv;
15777 }
15778
15779 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
15780         LDKGossipTimestampFilter o_conv;
15781         o_conv.inner = (void*)(o & (~1));
15782         o_conv.is_owned = (o & 1) || (o == 0);
15783         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15784         o_conv = GossipTimestampFilter_clone(&o_conv);
15785         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
15786         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
15787         return (uint64_t)ret_conv;
15788 }
15789
15790 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
15791         LDKDecodeError e_conv;
15792         e_conv.inner = (void*)(e & (~1));
15793         e_conv.is_owned = (e & 1) || (e == 0);
15794         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15795         e_conv = DecodeError_clone(&e_conv);
15796         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
15797         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
15798         return (uint64_t)ret_conv;
15799 }
15800
15801 jboolean  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
15802         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
15803         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
15804         return ret_val;
15805 }
15806
15807 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
15808         if ((_res & 1) != 0) return;
15809         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15810         CHECK_ACCESS(_res_ptr);
15811         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
15812         FREE((void*)_res);
15813         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
15814 }
15815
15816 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
15817         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
15818         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
15819         return (uint64_t)ret_conv;
15820 }
15821 int64_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
15822         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
15823         int64_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
15824         return ret_val;
15825 }
15826
15827 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
15828         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
15829         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
15830         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
15831         return (uint64_t)ret_conv;
15832 }
15833
15834 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
15835         LDKInvoice o_conv;
15836         o_conv.inner = (void*)(o & (~1));
15837         o_conv.is_owned = (o & 1) || (o == 0);
15838         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15839         o_conv = Invoice_clone(&o_conv);
15840         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
15841         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
15842         return (uint64_t)ret_conv;
15843 }
15844
15845 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
15846         void* e_ptr = (void*)(((uint64_t)e) & ~1);
15847         CHECK_ACCESS(e_ptr);
15848         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
15849         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1));
15850         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
15851         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
15852         return (uint64_t)ret_conv;
15853 }
15854
15855 jboolean  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_is_ok(uint32_t o) {
15856         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
15857         jboolean ret_val = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
15858         return ret_val;
15859 }
15860
15861 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
15862         if ((_res & 1) != 0) return;
15863         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15864         CHECK_ACCESS(_res_ptr);
15865         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
15866         FREE((void*)_res);
15867         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
15868 }
15869
15870 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
15871         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
15872         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
15873         return (uint64_t)ret_conv;
15874 }
15875 int64_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr(uint32_t arg) {
15876         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
15877         int64_t ret_val = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
15878         return ret_val;
15879 }
15880
15881 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
15882         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
15883         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
15884         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
15885         return (uint64_t)ret_conv;
15886 }
15887
15888 uint32_t  __attribute__((visibility("default"))) TS_COption_FilterZ_some(uint32_t o) {
15889         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15890         CHECK_ACCESS(o_ptr);
15891         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
15892         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
15893         *ret_copy = COption_FilterZ_some(o_conv);
15894         uint64_t ret_ref = (uint64_t)ret_copy;
15895         return ret_ref;
15896 }
15897
15898 uint32_t  __attribute__((visibility("default"))) TS_COption_FilterZ_none() {
15899         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
15900         *ret_copy = COption_FilterZ_none();
15901         uint64_t ret_ref = (uint64_t)ret_copy;
15902         return ret_ref;
15903 }
15904
15905 void  __attribute__((visibility("default"))) TS_COption_FilterZ_free(uint32_t _res) {
15906         if ((_res & 1) != 0) return;
15907         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15908         CHECK_ACCESS(_res_ptr);
15909         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
15910         FREE((void*)_res);
15911         COption_FilterZ_free(_res_conv);
15912 }
15913
15914 uint32_t  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
15915         LDKLockedChannelMonitor o_conv;
15916         o_conv.inner = (void*)(o & (~1));
15917         o_conv.is_owned = (o & 1) || (o == 0);
15918         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15919         // Warning: we need a move here but no clone is available for LDKLockedChannelMonitor
15920         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
15921         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
15922         return (uint64_t)ret_conv;
15923 }
15924
15925 uint32_t  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
15926         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
15927         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
15928         return (uint64_t)ret_conv;
15929 }
15930
15931 jboolean  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
15932         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
15933         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
15934         return ret_val;
15935 }
15936
15937 void  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
15938         if ((_res & 1) != 0) return;
15939         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15940         CHECK_ACCESS(_res_ptr);
15941         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
15942         FREE((void*)_res);
15943         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
15944 }
15945
15946 void  __attribute__((visibility("default"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
15947         LDKCVec_OutPointZ _res_constr;
15948         _res_constr.datalen = *((uint32_t*)_res);
15949         if (_res_constr.datalen > 0)
15950                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
15951         else
15952                 _res_constr.data = NULL;
15953         uint32_t* _res_vals = (uint32_t*)(_res + 4);
15954         for (size_t k = 0; k < _res_constr.datalen; k++) {
15955                 uint32_t _res_conv_10 = _res_vals[k];
15956                 LDKOutPoint _res_conv_10_conv;
15957                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
15958                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
15959                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
15960                 _res_constr.data[k] = _res_conv_10_conv;
15961         }
15962         CVec_OutPointZ_free(_res_constr);
15963 }
15964
15965 void  __attribute__((visibility("default"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
15966         if ((this_ptr & 1) != 0) return;
15967         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
15968         CHECK_ACCESS(this_ptr_ptr);
15969         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
15970         FREE((void*)this_ptr);
15971         PaymentPurpose_free(this_ptr_conv);
15972 }
15973
15974 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
15975         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
15976         *ret_copy = PaymentPurpose_clone(arg);
15977 uint64_t ret_ref = (uint64_t)ret_copy;
15978         return ret_ref;
15979 }
15980 int64_t  __attribute__((visibility("default"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
15981         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
15982         int64_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
15983         return ret_val;
15984 }
15985
15986 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_clone(uint32_t orig) {
15987         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
15988         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
15989         *ret_copy = PaymentPurpose_clone(orig_conv);
15990         uint64_t ret_ref = (uint64_t)ret_copy;
15991         return ret_ref;
15992 }
15993
15994 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret, int64_t user_payment_id) {
15995         LDKThirtyTwoBytes payment_preimage_ref;
15996         CHECK(*((uint32_t*)payment_preimage) == 32);
15997         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
15998         LDKThirtyTwoBytes payment_secret_ref;
15999         CHECK(*((uint32_t*)payment_secret) == 32);
16000         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
16001         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16002         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref, user_payment_id);
16003         uint64_t ret_ref = (uint64_t)ret_copy;
16004         return ret_ref;
16005 }
16006
16007 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
16008         LDKThirtyTwoBytes a_ref;
16009         CHECK(*((uint32_t*)a) == 32);
16010         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
16011         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16012         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
16013         uint64_t ret_ref = (uint64_t)ret_copy;
16014         return ret_ref;
16015 }
16016
16017 void  __attribute__((visibility("default"))) TS_ClosureReason_free(uint32_t this_ptr) {
16018         if ((this_ptr & 1) != 0) return;
16019         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16020         CHECK_ACCESS(this_ptr_ptr);
16021         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
16022         FREE((void*)this_ptr);
16023         ClosureReason_free(this_ptr_conv);
16024 }
16025
16026 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
16027         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16028         *ret_copy = ClosureReason_clone(arg);
16029 uint64_t ret_ref = (uint64_t)ret_copy;
16030         return ret_ref;
16031 }
16032 int64_t  __attribute__((visibility("default"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
16033         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
16034         int64_t ret_val = ClosureReason_clone_ptr(arg_conv);
16035         return ret_val;
16036 }
16037
16038 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_clone(uint32_t orig) {
16039         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
16040         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16041         *ret_copy = ClosureReason_clone(orig_conv);
16042         uint64_t ret_ref = (uint64_t)ret_copy;
16043         return ret_ref;
16044 }
16045
16046 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
16047         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
16048         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16049         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
16050         uint64_t ret_ref = (uint64_t)ret_copy;
16051         return ret_ref;
16052 }
16053
16054 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_holder_force_closed() {
16055         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16056         *ret_copy = ClosureReason_holder_force_closed();
16057         uint64_t ret_ref = (uint64_t)ret_copy;
16058         return ret_ref;
16059 }
16060
16061 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_cooperative_closure() {
16062         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16063         *ret_copy = ClosureReason_cooperative_closure();
16064         uint64_t ret_ref = (uint64_t)ret_copy;
16065         return ret_ref;
16066 }
16067
16068 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_commitment_tx_confirmed() {
16069         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16070         *ret_copy = ClosureReason_commitment_tx_confirmed();
16071         uint64_t ret_ref = (uint64_t)ret_copy;
16072         return ret_ref;
16073 }
16074
16075 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_processing_error(jstring err) {
16076         LDKStr err_conv = str_ref_to_owned_c(err);
16077         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16078         *ret_copy = ClosureReason_processing_error(err_conv);
16079         uint64_t ret_ref = (uint64_t)ret_copy;
16080         return ret_ref;
16081 }
16082
16083 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_disconnected_peer() {
16084         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16085         *ret_copy = ClosureReason_disconnected_peer();
16086         uint64_t ret_ref = (uint64_t)ret_copy;
16087         return ret_ref;
16088 }
16089
16090 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_outdated_channel_manager() {
16091         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16092         *ret_copy = ClosureReason_outdated_channel_manager();
16093         uint64_t ret_ref = (uint64_t)ret_copy;
16094         return ret_ref;
16095 }
16096
16097 int8_tArray  __attribute__((visibility("default"))) TS_ClosureReason_write(uint32_t obj) {
16098         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
16099         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
16100         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16101         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16102         CVec_u8Z_free(ret_var);
16103         return ret_arr;
16104 }
16105
16106 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_read(int8_tArray ser) {
16107         LDKu8slice ser_ref;
16108         ser_ref.datalen = *((uint32_t*)ser);
16109         ser_ref.data = (int8_t*)(ser + 4);
16110         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16111         *ret_conv = ClosureReason_read(ser_ref);
16112         return (uint64_t)ret_conv;
16113 }
16114
16115 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
16116         if ((this_ptr & 1) != 0) return;
16117         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16118         CHECK_ACCESS(this_ptr_ptr);
16119         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
16120         FREE((void*)this_ptr);
16121         Event_free(this_ptr_conv);
16122 }
16123
16124 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
16125         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16126         *ret_copy = Event_clone(arg);
16127 uint64_t ret_ref = (uint64_t)ret_copy;
16128         return ret_ref;
16129 }
16130 int64_t  __attribute__((visibility("default"))) TS_Event_clone_ptr(uint32_t arg) {
16131         LDKEvent* arg_conv = (LDKEvent*)arg;
16132         int64_t ret_val = Event_clone_ptr(arg_conv);
16133         return ret_val;
16134 }
16135
16136 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
16137         LDKEvent* orig_conv = (LDKEvent*)orig;
16138         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16139         *ret_copy = Event_clone(orig_conv);
16140         uint64_t ret_ref = (uint64_t)ret_copy;
16141         return ret_ref;
16142 }
16143
16144 uint32_t  __attribute__((visibility("default"))) TS_Event_funding_generation_ready(int8_tArray temporary_channel_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
16145         LDKThirtyTwoBytes temporary_channel_id_ref;
16146         CHECK(*((uint32_t*)temporary_channel_id) == 32);
16147         memcpy(temporary_channel_id_ref.data, (uint8_t*)(temporary_channel_id + 4), 32);
16148         LDKCVec_u8Z output_script_ref;
16149         output_script_ref.datalen = *((uint32_t*)output_script);
16150         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
16151         memcpy(output_script_ref.data, (uint8_t*)(output_script + 4), output_script_ref.datalen);
16152         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16153         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
16154         uint64_t ret_ref = (uint64_t)ret_copy;
16155         return ret_ref;
16156 }
16157
16158 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
16159         LDKThirtyTwoBytes payment_hash_ref;
16160         CHECK(*((uint32_t*)payment_hash) == 32);
16161         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
16162         void* purpose_ptr = (void*)(((uint64_t)purpose) & ~1);
16163         CHECK_ACCESS(purpose_ptr);
16164         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
16165         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1));
16166         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16167         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
16168         uint64_t ret_ref = (uint64_t)ret_copy;
16169         return ret_ref;
16170 }
16171
16172 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_sent(int8_tArray payment_id, int8_tArray payment_preimage, int8_tArray payment_hash, uint32_t fee_paid_msat) {
16173         LDKThirtyTwoBytes payment_id_ref;
16174         CHECK(*((uint32_t*)payment_id) == 32);
16175         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
16176         LDKThirtyTwoBytes payment_preimage_ref;
16177         CHECK(*((uint32_t*)payment_preimage) == 32);
16178         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
16179         LDKThirtyTwoBytes payment_hash_ref;
16180         CHECK(*((uint32_t*)payment_hash) == 32);
16181         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
16182         void* fee_paid_msat_ptr = (void*)(((uint64_t)fee_paid_msat) & ~1);
16183         CHECK_ACCESS(fee_paid_msat_ptr);
16184         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
16185         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_paid_msat) & ~1));
16186         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16187         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
16188         uint64_t ret_ref = (uint64_t)ret_copy;
16189         return ret_ref;
16190 }
16191
16192 uint32_t  __attribute__((visibility("default"))) 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) {
16193         LDKThirtyTwoBytes payment_id_ref;
16194         CHECK(*((uint32_t*)payment_id) == 32);
16195         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
16196         LDKThirtyTwoBytes payment_hash_ref;
16197         CHECK(*((uint32_t*)payment_hash) == 32);
16198         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
16199         void* network_update_ptr = (void*)(((uint64_t)network_update) & ~1);
16200         CHECK_ACCESS(network_update_ptr);
16201         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
16202         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
16203         LDKCVec_RouteHopZ path_constr;
16204         path_constr.datalen = *((uint32_t*)path);
16205         if (path_constr.datalen > 0)
16206                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16207         else
16208                 path_constr.data = NULL;
16209         uint32_t* path_vals = (uint32_t*)(path + 4);
16210         for (size_t k = 0; k < path_constr.datalen; k++) {
16211                 uint32_t path_conv_10 = path_vals[k];
16212                 LDKRouteHop path_conv_10_conv;
16213                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
16214                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
16215                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
16216                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
16217                 path_constr.data[k] = path_conv_10_conv;
16218         }
16219         void* short_channel_id_ptr = (void*)(((uint64_t)short_channel_id) & ~1);
16220         CHECK_ACCESS(short_channel_id_ptr);
16221         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
16222         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1));
16223         LDKRouteParameters retry_conv;
16224         retry_conv.inner = (void*)(retry & (~1));
16225         retry_conv.is_owned = (retry & 1) || (retry == 0);
16226         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
16227         retry_conv = RouteParameters_clone(&retry_conv);
16228         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16229         *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);
16230         uint64_t ret_ref = (uint64_t)ret_copy;
16231         return ret_ref;
16232 }
16233
16234 uint32_t  __attribute__((visibility("default"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
16235         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16236         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
16237         uint64_t ret_ref = (uint64_t)ret_copy;
16238         return ret_ref;
16239 }
16240
16241 uint32_t  __attribute__((visibility("default"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
16242         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
16243         outputs_constr.datalen = *((uint32_t*)outputs);
16244         if (outputs_constr.datalen > 0)
16245                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16246         else
16247                 outputs_constr.data = NULL;
16248         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
16249         for (size_t b = 0; b < outputs_constr.datalen; b++) {
16250                 uint32_t outputs_conv_27 = outputs_vals[b];
16251                 void* outputs_conv_27_ptr = (void*)(((uint64_t)outputs_conv_27) & ~1);
16252                 CHECK_ACCESS(outputs_conv_27_ptr);
16253                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
16254                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
16255                 outputs_constr.data[b] = outputs_conv_27_conv;
16256         }
16257         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16258         *ret_copy = Event_spendable_outputs(outputs_constr);
16259         uint64_t ret_ref = (uint64_t)ret_copy;
16260         return ret_ref;
16261 }
16262
16263 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
16264         void* fee_earned_msat_ptr = (void*)(((uint64_t)fee_earned_msat) & ~1);
16265         CHECK_ACCESS(fee_earned_msat_ptr);
16266         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
16267         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1));
16268         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16269         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
16270         uint64_t ret_ref = (uint64_t)ret_copy;
16271         return ret_ref;
16272 }
16273
16274 uint32_t  __attribute__((visibility("default"))) TS_Event_channel_closed(int8_tArray channel_id, int64_t user_channel_id, uint32_t reason) {
16275         LDKThirtyTwoBytes channel_id_ref;
16276         CHECK(*((uint32_t*)channel_id) == 32);
16277         memcpy(channel_id_ref.data, (uint8_t*)(channel_id + 4), 32);
16278         void* reason_ptr = (void*)(((uint64_t)reason) & ~1);
16279         CHECK_ACCESS(reason_ptr);
16280         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
16281         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
16282         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16283         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
16284         uint64_t ret_ref = (uint64_t)ret_copy;
16285         return ret_ref;
16286 }
16287
16288 uint32_t  __attribute__((visibility("default"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
16289         LDKThirtyTwoBytes channel_id_ref;
16290         CHECK(*((uint32_t*)channel_id) == 32);
16291         memcpy(channel_id_ref.data, (uint8_t*)(channel_id + 4), 32);
16292         LDKTransaction transaction_ref;
16293         transaction_ref.datalen = *((uint32_t*)transaction);
16294         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
16295         memcpy(transaction_ref.data, (uint8_t*)(transaction + 4), transaction_ref.datalen);
16296         transaction_ref.data_is_owned = true;
16297         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16298         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
16299         uint64_t ret_ref = (uint64_t)ret_copy;
16300         return ret_ref;
16301 }
16302
16303 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
16304         LDKEvent* obj_conv = (LDKEvent*)obj;
16305         LDKCVec_u8Z ret_var = Event_write(obj_conv);
16306         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16307         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16308         CVec_u8Z_free(ret_var);
16309         return ret_arr;
16310 }
16311
16312 uint32_t  __attribute__((visibility("default"))) TS_Event_read(int8_tArray ser) {
16313         LDKu8slice ser_ref;
16314         ser_ref.datalen = *((uint32_t*)ser);
16315         ser_ref.data = (int8_t*)(ser + 4);
16316         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16317         *ret_conv = Event_read(ser_ref);
16318         return (uint64_t)ret_conv;
16319 }
16320
16321 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
16322         if ((this_ptr & 1) != 0) return;
16323         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16324         CHECK_ACCESS(this_ptr_ptr);
16325         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
16326         FREE((void*)this_ptr);
16327         MessageSendEvent_free(this_ptr_conv);
16328 }
16329
16330 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
16331         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16332         *ret_copy = MessageSendEvent_clone(arg);
16333 uint64_t ret_ref = (uint64_t)ret_copy;
16334         return ret_ref;
16335 }
16336 int64_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
16337         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
16338         int64_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
16339         return ret_val;
16340 }
16341
16342 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
16343         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
16344         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16345         *ret_copy = MessageSendEvent_clone(orig_conv);
16346         uint64_t ret_ref = (uint64_t)ret_copy;
16347         return ret_ref;
16348 }
16349
16350 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
16351         LDKPublicKey node_id_ref;
16352         CHECK(*((uint32_t*)node_id) == 33);
16353         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16354         LDKAcceptChannel msg_conv;
16355         msg_conv.inner = (void*)(msg & (~1));
16356         msg_conv.is_owned = (msg & 1) || (msg == 0);
16357         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16358         msg_conv = AcceptChannel_clone(&msg_conv);
16359         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16360         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
16361         uint64_t ret_ref = (uint64_t)ret_copy;
16362         return ret_ref;
16363 }
16364
16365 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
16366         LDKPublicKey node_id_ref;
16367         CHECK(*((uint32_t*)node_id) == 33);
16368         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16369         LDKOpenChannel msg_conv;
16370         msg_conv.inner = (void*)(msg & (~1));
16371         msg_conv.is_owned = (msg & 1) || (msg == 0);
16372         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16373         msg_conv = OpenChannel_clone(&msg_conv);
16374         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16375         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
16376         uint64_t ret_ref = (uint64_t)ret_copy;
16377         return ret_ref;
16378 }
16379
16380 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
16381         LDKPublicKey node_id_ref;
16382         CHECK(*((uint32_t*)node_id) == 33);
16383         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16384         LDKFundingCreated msg_conv;
16385         msg_conv.inner = (void*)(msg & (~1));
16386         msg_conv.is_owned = (msg & 1) || (msg == 0);
16387         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16388         msg_conv = FundingCreated_clone(&msg_conv);
16389         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16390         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
16391         uint64_t ret_ref = (uint64_t)ret_copy;
16392         return ret_ref;
16393 }
16394
16395 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
16396         LDKPublicKey node_id_ref;
16397         CHECK(*((uint32_t*)node_id) == 33);
16398         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16399         LDKFundingSigned msg_conv;
16400         msg_conv.inner = (void*)(msg & (~1));
16401         msg_conv.is_owned = (msg & 1) || (msg == 0);
16402         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16403         msg_conv = FundingSigned_clone(&msg_conv);
16404         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16405         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
16406         uint64_t ret_ref = (uint64_t)ret_copy;
16407         return ret_ref;
16408 }
16409
16410 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
16411         LDKPublicKey node_id_ref;
16412         CHECK(*((uint32_t*)node_id) == 33);
16413         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16414         LDKFundingLocked msg_conv;
16415         msg_conv.inner = (void*)(msg & (~1));
16416         msg_conv.is_owned = (msg & 1) || (msg == 0);
16417         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16418         msg_conv = FundingLocked_clone(&msg_conv);
16419         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16420         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
16421         uint64_t ret_ref = (uint64_t)ret_copy;
16422         return ret_ref;
16423 }
16424
16425 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
16426         LDKPublicKey node_id_ref;
16427         CHECK(*((uint32_t*)node_id) == 33);
16428         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16429         LDKAnnouncementSignatures msg_conv;
16430         msg_conv.inner = (void*)(msg & (~1));
16431         msg_conv.is_owned = (msg & 1) || (msg == 0);
16432         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16433         msg_conv = AnnouncementSignatures_clone(&msg_conv);
16434         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16435         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
16436         uint64_t ret_ref = (uint64_t)ret_copy;
16437         return ret_ref;
16438 }
16439
16440 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
16441         LDKPublicKey node_id_ref;
16442         CHECK(*((uint32_t*)node_id) == 33);
16443         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16444         LDKCommitmentUpdate updates_conv;
16445         updates_conv.inner = (void*)(updates & (~1));
16446         updates_conv.is_owned = (updates & 1) || (updates == 0);
16447         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
16448         updates_conv = CommitmentUpdate_clone(&updates_conv);
16449         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16450         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
16451         uint64_t ret_ref = (uint64_t)ret_copy;
16452         return ret_ref;
16453 }
16454
16455 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
16456         LDKPublicKey node_id_ref;
16457         CHECK(*((uint32_t*)node_id) == 33);
16458         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16459         LDKRevokeAndACK msg_conv;
16460         msg_conv.inner = (void*)(msg & (~1));
16461         msg_conv.is_owned = (msg & 1) || (msg == 0);
16462         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16463         msg_conv = RevokeAndACK_clone(&msg_conv);
16464         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16465         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
16466         uint64_t ret_ref = (uint64_t)ret_copy;
16467         return ret_ref;
16468 }
16469
16470 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
16471         LDKPublicKey node_id_ref;
16472         CHECK(*((uint32_t*)node_id) == 33);
16473         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16474         LDKClosingSigned msg_conv;
16475         msg_conv.inner = (void*)(msg & (~1));
16476         msg_conv.is_owned = (msg & 1) || (msg == 0);
16477         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16478         msg_conv = ClosingSigned_clone(&msg_conv);
16479         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16480         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
16481         uint64_t ret_ref = (uint64_t)ret_copy;
16482         return ret_ref;
16483 }
16484
16485 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
16486         LDKPublicKey node_id_ref;
16487         CHECK(*((uint32_t*)node_id) == 33);
16488         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16489         LDKShutdown msg_conv;
16490         msg_conv.inner = (void*)(msg & (~1));
16491         msg_conv.is_owned = (msg & 1) || (msg == 0);
16492         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16493         msg_conv = Shutdown_clone(&msg_conv);
16494         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16495         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
16496         uint64_t ret_ref = (uint64_t)ret_copy;
16497         return ret_ref;
16498 }
16499
16500 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
16501         LDKPublicKey node_id_ref;
16502         CHECK(*((uint32_t*)node_id) == 33);
16503         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16504         LDKChannelReestablish msg_conv;
16505         msg_conv.inner = (void*)(msg & (~1));
16506         msg_conv.is_owned = (msg & 1) || (msg == 0);
16507         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16508         msg_conv = ChannelReestablish_clone(&msg_conv);
16509         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16510         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
16511         uint64_t ret_ref = (uint64_t)ret_copy;
16512         return ret_ref;
16513 }
16514
16515 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
16516         LDKChannelAnnouncement msg_conv;
16517         msg_conv.inner = (void*)(msg & (~1));
16518         msg_conv.is_owned = (msg & 1) || (msg == 0);
16519         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16520         msg_conv = ChannelAnnouncement_clone(&msg_conv);
16521         LDKChannelUpdate update_msg_conv;
16522         update_msg_conv.inner = (void*)(update_msg & (~1));
16523         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
16524         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
16525         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
16526         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16527         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
16528         uint64_t ret_ref = (uint64_t)ret_copy;
16529         return ret_ref;
16530 }
16531
16532 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
16533         LDKNodeAnnouncement msg_conv;
16534         msg_conv.inner = (void*)(msg & (~1));
16535         msg_conv.is_owned = (msg & 1) || (msg == 0);
16536         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16537         msg_conv = NodeAnnouncement_clone(&msg_conv);
16538         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16539         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
16540         uint64_t ret_ref = (uint64_t)ret_copy;
16541         return ret_ref;
16542 }
16543
16544 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
16545         LDKChannelUpdate msg_conv;
16546         msg_conv.inner = (void*)(msg & (~1));
16547         msg_conv.is_owned = (msg & 1) || (msg == 0);
16548         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16549         msg_conv = ChannelUpdate_clone(&msg_conv);
16550         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16551         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
16552         uint64_t ret_ref = (uint64_t)ret_copy;
16553         return ret_ref;
16554 }
16555
16556 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
16557         LDKPublicKey node_id_ref;
16558         CHECK(*((uint32_t*)node_id) == 33);
16559         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16560         LDKChannelUpdate msg_conv;
16561         msg_conv.inner = (void*)(msg & (~1));
16562         msg_conv.is_owned = (msg & 1) || (msg == 0);
16563         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16564         msg_conv = ChannelUpdate_clone(&msg_conv);
16565         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16566         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
16567         uint64_t ret_ref = (uint64_t)ret_copy;
16568         return ret_ref;
16569 }
16570
16571 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
16572         LDKPublicKey node_id_ref;
16573         CHECK(*((uint32_t*)node_id) == 33);
16574         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16575         void* action_ptr = (void*)(((uint64_t)action) & ~1);
16576         CHECK_ACCESS(action_ptr);
16577         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
16578         action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1));
16579         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16580         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
16581         uint64_t ret_ref = (uint64_t)ret_copy;
16582         return ret_ref;
16583 }
16584
16585 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
16586         LDKPublicKey node_id_ref;
16587         CHECK(*((uint32_t*)node_id) == 33);
16588         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16589         LDKQueryChannelRange msg_conv;
16590         msg_conv.inner = (void*)(msg & (~1));
16591         msg_conv.is_owned = (msg & 1) || (msg == 0);
16592         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16593         msg_conv = QueryChannelRange_clone(&msg_conv);
16594         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16595         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
16596         uint64_t ret_ref = (uint64_t)ret_copy;
16597         return ret_ref;
16598 }
16599
16600 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
16601         LDKPublicKey node_id_ref;
16602         CHECK(*((uint32_t*)node_id) == 33);
16603         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16604         LDKQueryShortChannelIds msg_conv;
16605         msg_conv.inner = (void*)(msg & (~1));
16606         msg_conv.is_owned = (msg & 1) || (msg == 0);
16607         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16608         msg_conv = QueryShortChannelIds_clone(&msg_conv);
16609         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16610         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
16611         uint64_t ret_ref = (uint64_t)ret_copy;
16612         return ret_ref;
16613 }
16614
16615 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
16616         LDKPublicKey node_id_ref;
16617         CHECK(*((uint32_t*)node_id) == 33);
16618         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16619         LDKReplyChannelRange msg_conv;
16620         msg_conv.inner = (void*)(msg & (~1));
16621         msg_conv.is_owned = (msg & 1) || (msg == 0);
16622         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16623         msg_conv = ReplyChannelRange_clone(&msg_conv);
16624         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16625         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
16626         uint64_t ret_ref = (uint64_t)ret_copy;
16627         return ret_ref;
16628 }
16629
16630 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
16631         if ((this_ptr & 1) != 0) return;
16632         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16633         CHECK_ACCESS(this_ptr_ptr);
16634         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
16635         FREE((void*)this_ptr);
16636         MessageSendEventsProvider_free(this_ptr_conv);
16637 }
16638
16639 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
16640         if ((this_ptr & 1) != 0) return;
16641         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16642         CHECK_ACCESS(this_ptr_ptr);
16643         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
16644         FREE((void*)this_ptr);
16645         EventsProvider_free(this_ptr_conv);
16646 }
16647
16648 void  __attribute__((visibility("default"))) TS_EventHandler_free(uint32_t this_ptr) {
16649         if ((this_ptr & 1) != 0) return;
16650         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16651         CHECK_ACCESS(this_ptr_ptr);
16652         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
16653         FREE((void*)this_ptr);
16654         EventHandler_free(this_ptr_conv);
16655 }
16656
16657 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
16658         if ((this_ptr & 1) != 0) return;
16659         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16660         CHECK_ACCESS(this_ptr_ptr);
16661         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
16662         FREE((void*)this_ptr);
16663         APIError_free(this_ptr_conv);
16664 }
16665
16666 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
16667         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
16668         *ret_copy = APIError_clone(arg);
16669 uint64_t ret_ref = (uint64_t)ret_copy;
16670         return ret_ref;
16671 }
16672 int64_t  __attribute__((visibility("default"))) TS_APIError_clone_ptr(uint32_t arg) {
16673         LDKAPIError* arg_conv = (LDKAPIError*)arg;
16674         int64_t ret_val = APIError_clone_ptr(arg_conv);
16675         return ret_val;
16676 }
16677
16678 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
16679         LDKAPIError* orig_conv = (LDKAPIError*)orig;
16680         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
16681         *ret_copy = APIError_clone(orig_conv);
16682         uint64_t ret_ref = (uint64_t)ret_copy;
16683         return ret_ref;
16684 }
16685
16686 uint32_t  __attribute__((visibility("default"))) TS_APIError_apimisuse_error(jstring err) {
16687         LDKStr err_conv = str_ref_to_owned_c(err);
16688         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
16689         *ret_copy = APIError_apimisuse_error(err_conv);
16690         uint64_t ret_ref = (uint64_t)ret_copy;
16691         return ret_ref;
16692 }
16693
16694 uint32_t  __attribute__((visibility("default"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
16695         LDKStr err_conv = str_ref_to_owned_c(err);
16696         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
16697         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
16698         uint64_t ret_ref = (uint64_t)ret_copy;
16699         return ret_ref;
16700 }
16701
16702 uint32_t  __attribute__((visibility("default"))) TS_APIError_route_error(jstring err) {
16703         LDKStr err_conv = str_ref_to_owned_c(err);
16704         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
16705         *ret_copy = APIError_route_error(err_conv);
16706         uint64_t ret_ref = (uint64_t)ret_copy;
16707         return ret_ref;
16708 }
16709
16710 uint32_t  __attribute__((visibility("default"))) TS_APIError_channel_unavailable(jstring err) {
16711         LDKStr err_conv = str_ref_to_owned_c(err);
16712         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
16713         *ret_copy = APIError_channel_unavailable(err_conv);
16714         uint64_t ret_ref = (uint64_t)ret_copy;
16715         return ret_ref;
16716 }
16717
16718 uint32_t  __attribute__((visibility("default"))) TS_APIError_monitor_update_failed() {
16719         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
16720         *ret_copy = APIError_monitor_update_failed();
16721         uint64_t ret_ref = (uint64_t)ret_copy;
16722         return ret_ref;
16723 }
16724
16725 uint32_t  __attribute__((visibility("default"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
16726         LDKShutdownScript script_conv;
16727         script_conv.inner = (void*)(script & (~1));
16728         script_conv.is_owned = (script & 1) || (script == 0);
16729         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
16730         script_conv = ShutdownScript_clone(&script_conv);
16731         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
16732         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
16733         uint64_t ret_ref = (uint64_t)ret_copy;
16734         return ret_ref;
16735 }
16736
16737 uint32_t  __attribute__((visibility("default"))) TS_sign(int8_tArray msg, int8_tArray sk) {
16738         LDKu8slice msg_ref;
16739         msg_ref.datalen = *((uint32_t*)msg);
16740         msg_ref.data = (int8_t*)(msg + 4);
16741         unsigned char sk_arr[32];
16742         CHECK(*((uint32_t*)sk) == 32);
16743         memcpy(sk_arr, (uint8_t*)(sk + 4), 32);
16744         unsigned char (*sk_ref)[32] = &sk_arr;
16745         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
16746         *ret_conv = sign(msg_ref, sk_ref);
16747         return (uint64_t)ret_conv;
16748 }
16749
16750 uint32_t  __attribute__((visibility("default"))) TS_recover_pk(int8_tArray msg, jstring sig) {
16751         LDKu8slice msg_ref;
16752         msg_ref.datalen = *((uint32_t*)msg);
16753         msg_ref.data = (int8_t*)(msg + 4);
16754         LDKStr sig_conv = str_ref_to_owned_c(sig);
16755         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
16756         *ret_conv = recover_pk(msg_ref, sig_conv);
16757         return (uint64_t)ret_conv;
16758 }
16759
16760 jboolean  __attribute__((visibility("default"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
16761         LDKu8slice msg_ref;
16762         msg_ref.datalen = *((uint32_t*)msg);
16763         msg_ref.data = (int8_t*)(msg + 4);
16764         LDKStr sig_conv = str_ref_to_owned_c(sig);
16765         LDKPublicKey pk_ref;
16766         CHECK(*((uint32_t*)pk) == 33);
16767         memcpy(pk_ref.compressed_form, (uint8_t*)(pk + 4), 33);
16768         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
16769         return ret_val;
16770 }
16771
16772 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
16773         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
16774         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
16775         return ret_conv;
16776 }
16777
16778 uint32_t  __attribute__((visibility("default"))) TS_Level_trace() {
16779         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
16780         return ret_conv;
16781 }
16782
16783 uint32_t  __attribute__((visibility("default"))) TS_Level_debug() {
16784         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
16785         return ret_conv;
16786 }
16787
16788 uint32_t  __attribute__((visibility("default"))) TS_Level_info() {
16789         uint32_t ret_conv = LDKLevel_to_js(Level_info());
16790         return ret_conv;
16791 }
16792
16793 uint32_t  __attribute__((visibility("default"))) TS_Level_warn() {
16794         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
16795         return ret_conv;
16796 }
16797
16798 uint32_t  __attribute__((visibility("default"))) TS_Level_error() {
16799         uint32_t ret_conv = LDKLevel_to_js(Level_error());
16800         return ret_conv;
16801 }
16802
16803 jboolean  __attribute__((visibility("default"))) TS_Level_eq(uint32_t a, uint32_t b) {
16804         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
16805         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
16806         jboolean ret_val = Level_eq(a_conv, b_conv);
16807         return ret_val;
16808 }
16809
16810 int64_t  __attribute__((visibility("default"))) TS_Level_hash(uint32_t o) {
16811         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
16812         int64_t ret_val = Level_hash(o_conv);
16813         return ret_val;
16814 }
16815
16816 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
16817         uint32_t ret_conv = LDKLevel_to_js(Level_max());
16818         return ret_conv;
16819 }
16820
16821 void  __attribute__((visibility("default"))) TS_Record_free(uint32_t this_obj) {
16822         LDKRecord this_obj_conv;
16823         this_obj_conv.inner = (void*)(this_obj & (~1));
16824         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
16826         Record_free(this_obj_conv);
16827 }
16828
16829 uint32_t  __attribute__((visibility("default"))) TS_Record_get_level(uint32_t this_ptr) {
16830         LDKRecord this_ptr_conv;
16831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16832         this_ptr_conv.is_owned = false;
16833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
16834         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
16835         return ret_conv;
16836 }
16837
16838 void  __attribute__((visibility("default"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
16839         LDKRecord this_ptr_conv;
16840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16841         this_ptr_conv.is_owned = false;
16842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
16843         LDKLevel val_conv = LDKLevel_from_js(val);
16844         Record_set_level(&this_ptr_conv, val_conv);
16845 }
16846
16847 jstring  __attribute__((visibility("default"))) TS_Record_get_args(uint32_t this_ptr) {
16848         LDKRecord this_ptr_conv;
16849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16850         this_ptr_conv.is_owned = false;
16851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
16852         LDKStr ret_str = Record_get_args(&this_ptr_conv);
16853         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
16854         Str_free(ret_str);
16855         return ret_conv;
16856 }
16857
16858 void  __attribute__((visibility("default"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
16859         LDKRecord this_ptr_conv;
16860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16861         this_ptr_conv.is_owned = false;
16862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
16863         LDKStr val_conv = str_ref_to_owned_c(val);
16864         Record_set_args(&this_ptr_conv, val_conv);
16865 }
16866
16867 jstring  __attribute__((visibility("default"))) TS_Record_get_module_path(uint32_t this_ptr) {
16868         LDKRecord this_ptr_conv;
16869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16870         this_ptr_conv.is_owned = false;
16871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
16872         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
16873         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
16874         Str_free(ret_str);
16875         return ret_conv;
16876 }
16877
16878 void  __attribute__((visibility("default"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
16879         LDKRecord this_ptr_conv;
16880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16881         this_ptr_conv.is_owned = false;
16882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
16883         LDKStr val_conv = str_ref_to_owned_c(val);
16884         Record_set_module_path(&this_ptr_conv, val_conv);
16885 }
16886
16887 jstring  __attribute__((visibility("default"))) TS_Record_get_file(uint32_t this_ptr) {
16888         LDKRecord this_ptr_conv;
16889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16890         this_ptr_conv.is_owned = false;
16891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
16892         LDKStr ret_str = Record_get_file(&this_ptr_conv);
16893         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
16894         Str_free(ret_str);
16895         return ret_conv;
16896 }
16897
16898 void  __attribute__((visibility("default"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
16899         LDKRecord this_ptr_conv;
16900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16901         this_ptr_conv.is_owned = false;
16902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
16903         LDKStr val_conv = str_ref_to_owned_c(val);
16904         Record_set_file(&this_ptr_conv, val_conv);
16905 }
16906
16907 int32_t  __attribute__((visibility("default"))) TS_Record_get_line(uint32_t this_ptr) {
16908         LDKRecord this_ptr_conv;
16909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16910         this_ptr_conv.is_owned = false;
16911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
16912         int32_t ret_val = Record_get_line(&this_ptr_conv);
16913         return ret_val;
16914 }
16915
16916 void  __attribute__((visibility("default"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
16917         LDKRecord this_ptr_conv;
16918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16919         this_ptr_conv.is_owned = false;
16920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
16921         Record_set_line(&this_ptr_conv, val);
16922 }
16923
16924 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
16925         LDKRecord ret_var = Record_clone(arg);
16926 uint64_t ret_ref = 0;
16927 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16928 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16929 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
16930 ret_ref = (uint64_t)ret_var.inner;
16931 if (ret_var.is_owned) {
16932         ret_ref |= 1;
16933 }
16934         return ret_ref;
16935 }
16936 int64_t  __attribute__((visibility("default"))) TS_Record_clone_ptr(uint32_t arg) {
16937         LDKRecord arg_conv;
16938         arg_conv.inner = (void*)(arg & (~1));
16939         arg_conv.is_owned = false;
16940         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
16941         int64_t ret_val = Record_clone_ptr(&arg_conv);
16942         return ret_val;
16943 }
16944
16945 uint32_t  __attribute__((visibility("default"))) TS_Record_clone(uint32_t orig) {
16946         LDKRecord orig_conv;
16947         orig_conv.inner = (void*)(orig & (~1));
16948         orig_conv.is_owned = false;
16949         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
16950         LDKRecord ret_var = Record_clone(&orig_conv);
16951         uint64_t ret_ref = 0;
16952         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16953         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16954         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
16955         ret_ref = (uint64_t)ret_var.inner;
16956         if (ret_var.is_owned) {
16957                 ret_ref |= 1;
16958         }
16959         return ret_ref;
16960 }
16961
16962 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
16963         if ((this_ptr & 1) != 0) return;
16964         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16965         CHECK_ACCESS(this_ptr_ptr);
16966         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
16967         FREE((void*)this_ptr);
16968         Logger_free(this_ptr_conv);
16969 }
16970
16971 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
16972         LDKChannelHandshakeConfig this_obj_conv;
16973         this_obj_conv.inner = (void*)(this_obj & (~1));
16974         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
16976         ChannelHandshakeConfig_free(this_obj_conv);
16977 }
16978
16979 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
16980         LDKChannelHandshakeConfig this_ptr_conv;
16981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16982         this_ptr_conv.is_owned = false;
16983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
16984         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
16985         return ret_val;
16986 }
16987
16988 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
16989         LDKChannelHandshakeConfig this_ptr_conv;
16990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16991         this_ptr_conv.is_owned = false;
16992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
16993         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
16994 }
16995
16996 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
16997         LDKChannelHandshakeConfig this_ptr_conv;
16998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16999         this_ptr_conv.is_owned = false;
17000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17001         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
17002         return ret_val;
17003 }
17004
17005 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
17006         LDKChannelHandshakeConfig this_ptr_conv;
17007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17008         this_ptr_conv.is_owned = false;
17009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17010         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
17011 }
17012
17013 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
17014         LDKChannelHandshakeConfig this_ptr_conv;
17015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17016         this_ptr_conv.is_owned = false;
17017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17018         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
17019         return ret_val;
17020 }
17021
17022 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
17023         LDKChannelHandshakeConfig this_ptr_conv;
17024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17025         this_ptr_conv.is_owned = false;
17026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17027         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
17028 }
17029
17030 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_new(int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg) {
17031         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
17032         uint64_t ret_ref = 0;
17033         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17034         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17036         ret_ref = (uint64_t)ret_var.inner;
17037         if (ret_var.is_owned) {
17038                 ret_ref |= 1;
17039         }
17040         return ret_ref;
17041 }
17042
17043 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
17044         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
17045 uint64_t ret_ref = 0;
17046 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17047 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17048 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17049 ret_ref = (uint64_t)ret_var.inner;
17050 if (ret_var.is_owned) {
17051         ret_ref |= 1;
17052 }
17053         return ret_ref;
17054 }
17055 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
17056         LDKChannelHandshakeConfig arg_conv;
17057         arg_conv.inner = (void*)(arg & (~1));
17058         arg_conv.is_owned = false;
17059         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17060         int64_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
17061         return ret_val;
17062 }
17063
17064 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
17065         LDKChannelHandshakeConfig orig_conv;
17066         orig_conv.inner = (void*)(orig & (~1));
17067         orig_conv.is_owned = false;
17068         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17069         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
17070         uint64_t ret_ref = 0;
17071         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17072         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17074         ret_ref = (uint64_t)ret_var.inner;
17075         if (ret_var.is_owned) {
17076                 ret_ref |= 1;
17077         }
17078         return ret_ref;
17079 }
17080
17081 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
17082         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
17083         uint64_t ret_ref = 0;
17084         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17085         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17087         ret_ref = (uint64_t)ret_var.inner;
17088         if (ret_var.is_owned) {
17089                 ret_ref |= 1;
17090         }
17091         return ret_ref;
17092 }
17093
17094 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
17095         LDKChannelHandshakeLimits this_obj_conv;
17096         this_obj_conv.inner = (void*)(this_obj & (~1));
17097         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17099         ChannelHandshakeLimits_free(this_obj_conv);
17100 }
17101
17102 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
17103         LDKChannelHandshakeLimits this_ptr_conv;
17104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17105         this_ptr_conv.is_owned = false;
17106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17107         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
17108         return ret_val;
17109 }
17110
17111 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
17112         LDKChannelHandshakeLimits this_ptr_conv;
17113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17114         this_ptr_conv.is_owned = false;
17115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17116         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
17117 }
17118
17119 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
17120         LDKChannelHandshakeLimits this_ptr_conv;
17121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17122         this_ptr_conv.is_owned = false;
17123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17124         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
17125         return ret_val;
17126 }
17127
17128 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
17129         LDKChannelHandshakeLimits this_ptr_conv;
17130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17131         this_ptr_conv.is_owned = false;
17132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17133         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
17134 }
17135
17136 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
17137         LDKChannelHandshakeLimits this_ptr_conv;
17138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17139         this_ptr_conv.is_owned = false;
17140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17141         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
17142         return ret_val;
17143 }
17144
17145 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
17146         LDKChannelHandshakeLimits this_ptr_conv;
17147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17148         this_ptr_conv.is_owned = false;
17149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17150         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17151 }
17152
17153 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
17154         LDKChannelHandshakeLimits this_ptr_conv;
17155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17156         this_ptr_conv.is_owned = false;
17157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17158         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
17159         return ret_val;
17160 }
17161
17162 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
17163         LDKChannelHandshakeLimits this_ptr_conv;
17164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17165         this_ptr_conv.is_owned = false;
17166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17167         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
17168 }
17169
17170 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
17171         LDKChannelHandshakeLimits this_ptr_conv;
17172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17173         this_ptr_conv.is_owned = false;
17174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17175         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
17176         return ret_val;
17177 }
17178
17179 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
17180         LDKChannelHandshakeLimits this_ptr_conv;
17181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17182         this_ptr_conv.is_owned = false;
17183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17184         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
17185 }
17186
17187 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
17188         LDKChannelHandshakeLimits this_ptr_conv;
17189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17190         this_ptr_conv.is_owned = false;
17191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17192         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
17193         return ret_val;
17194 }
17195
17196 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
17197         LDKChannelHandshakeLimits this_ptr_conv;
17198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17199         this_ptr_conv.is_owned = false;
17200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17201         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
17202 }
17203
17204 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
17205         LDKChannelHandshakeLimits this_ptr_conv;
17206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17207         this_ptr_conv.is_owned = false;
17208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17209         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
17210         return ret_val;
17211 }
17212
17213 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
17214         LDKChannelHandshakeLimits this_ptr_conv;
17215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17216         this_ptr_conv.is_owned = false;
17217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17218         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
17219 }
17220
17221 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
17222         LDKChannelHandshakeLimits this_ptr_conv;
17223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17224         this_ptr_conv.is_owned = false;
17225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17226         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
17227         return ret_val;
17228 }
17229
17230 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
17231         LDKChannelHandshakeLimits this_ptr_conv;
17232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17233         this_ptr_conv.is_owned = false;
17234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17235         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
17236 }
17237
17238 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_new(int64_t min_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
17239         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
17240         uint64_t ret_ref = 0;
17241         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17242         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17244         ret_ref = (uint64_t)ret_var.inner;
17245         if (ret_var.is_owned) {
17246                 ret_ref |= 1;
17247         }
17248         return ret_ref;
17249 }
17250
17251 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
17252         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
17253 uint64_t ret_ref = 0;
17254 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17255 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17256 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17257 ret_ref = (uint64_t)ret_var.inner;
17258 if (ret_var.is_owned) {
17259         ret_ref |= 1;
17260 }
17261         return ret_ref;
17262 }
17263 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
17264         LDKChannelHandshakeLimits arg_conv;
17265         arg_conv.inner = (void*)(arg & (~1));
17266         arg_conv.is_owned = false;
17267         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17268         int64_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
17269         return ret_val;
17270 }
17271
17272 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
17273         LDKChannelHandshakeLimits orig_conv;
17274         orig_conv.inner = (void*)(orig & (~1));
17275         orig_conv.is_owned = false;
17276         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17277         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
17278         uint64_t ret_ref = 0;
17279         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17280         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17282         ret_ref = (uint64_t)ret_var.inner;
17283         if (ret_var.is_owned) {
17284                 ret_ref |= 1;
17285         }
17286         return ret_ref;
17287 }
17288
17289 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
17290         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
17291         uint64_t ret_ref = 0;
17292         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17293         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17295         ret_ref = (uint64_t)ret_var.inner;
17296         if (ret_var.is_owned) {
17297                 ret_ref |= 1;
17298         }
17299         return ret_ref;
17300 }
17301
17302 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_obj) {
17303         LDKChannelConfig this_obj_conv;
17304         this_obj_conv.inner = (void*)(this_obj & (~1));
17305         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17307         ChannelConfig_free(this_obj_conv);
17308 }
17309
17310 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
17311         LDKChannelConfig this_ptr_conv;
17312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17313         this_ptr_conv.is_owned = false;
17314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17315         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
17316         return ret_val;
17317 }
17318
17319 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
17320         LDKChannelConfig this_ptr_conv;
17321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17322         this_ptr_conv.is_owned = false;
17323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17324         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
17325 }
17326
17327 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
17328         LDKChannelConfig this_ptr_conv;
17329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17330         this_ptr_conv.is_owned = false;
17331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17332         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
17333         return ret_val;
17334 }
17335
17336 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_base_msat(uint32_t this_ptr, int32_t val) {
17337         LDKChannelConfig this_ptr_conv;
17338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17339         this_ptr_conv.is_owned = false;
17340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17341         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
17342 }
17343
17344 int16_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
17345         LDKChannelConfig this_ptr_conv;
17346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17347         this_ptr_conv.is_owned = false;
17348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17349         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
17350         return ret_val;
17351 }
17352
17353 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
17354         LDKChannelConfig this_ptr_conv;
17355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17356         this_ptr_conv.is_owned = false;
17357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17358         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
17359 }
17360
17361 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
17362         LDKChannelConfig this_ptr_conv;
17363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17364         this_ptr_conv.is_owned = false;
17365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17366         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
17367         return ret_val;
17368 }
17369
17370 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
17371         LDKChannelConfig this_ptr_conv;
17372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17373         this_ptr_conv.is_owned = false;
17374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17375         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
17376 }
17377
17378 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
17379         LDKChannelConfig this_ptr_conv;
17380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17381         this_ptr_conv.is_owned = false;
17382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17383         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
17384         return ret_val;
17385 }
17386
17387 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
17388         LDKChannelConfig this_ptr_conv;
17389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17390         this_ptr_conv.is_owned = false;
17391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17392         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
17393 }
17394
17395 int64_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_max_dust_htlc_exposure_msat(uint32_t this_ptr) {
17396         LDKChannelConfig this_ptr_conv;
17397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17398         this_ptr_conv.is_owned = false;
17399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17400         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
17401         return ret_val;
17402 }
17403
17404 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_max_dust_htlc_exposure_msat(uint32_t this_ptr, int64_t val) {
17405         LDKChannelConfig this_ptr_conv;
17406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17407         this_ptr_conv.is_owned = false;
17408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17409         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
17410 }
17411
17412 int64_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr) {
17413         LDKChannelConfig this_ptr_conv;
17414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17415         this_ptr_conv.is_owned = false;
17416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17417         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
17418         return ret_val;
17419 }
17420
17421 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
17422         LDKChannelConfig this_ptr_conv;
17423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17424         this_ptr_conv.is_owned = false;
17425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17426         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
17427 }
17428
17429 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
17430         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
17431         uint64_t ret_ref = 0;
17432         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17433         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17435         ret_ref = (uint64_t)ret_var.inner;
17436         if (ret_var.is_owned) {
17437                 ret_ref |= 1;
17438         }
17439         return ret_ref;
17440 }
17441
17442 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
17443         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
17444 uint64_t ret_ref = 0;
17445 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17446 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17447 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17448 ret_ref = (uint64_t)ret_var.inner;
17449 if (ret_var.is_owned) {
17450         ret_ref |= 1;
17451 }
17452         return ret_ref;
17453 }
17454 int64_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
17455         LDKChannelConfig arg_conv;
17456         arg_conv.inner = (void*)(arg & (~1));
17457         arg_conv.is_owned = false;
17458         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17459         int64_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
17460         return ret_val;
17461 }
17462
17463 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
17464         LDKChannelConfig orig_conv;
17465         orig_conv.inner = (void*)(orig & (~1));
17466         orig_conv.is_owned = false;
17467         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17468         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
17469         uint64_t ret_ref = 0;
17470         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17471         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17473         ret_ref = (uint64_t)ret_var.inner;
17474         if (ret_var.is_owned) {
17475                 ret_ref |= 1;
17476         }
17477         return ret_ref;
17478 }
17479
17480 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
17481         LDKChannelConfig ret_var = ChannelConfig_default();
17482         uint64_t ret_ref = 0;
17483         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17484         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17486         ret_ref = (uint64_t)ret_var.inner;
17487         if (ret_var.is_owned) {
17488                 ret_ref |= 1;
17489         }
17490         return ret_ref;
17491 }
17492
17493 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
17494         LDKChannelConfig obj_conv;
17495         obj_conv.inner = (void*)(obj & (~1));
17496         obj_conv.is_owned = false;
17497         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
17498         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
17499         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17500         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17501         CVec_u8Z_free(ret_var);
17502         return ret_arr;
17503 }
17504
17505 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
17506         LDKu8slice ser_ref;
17507         ser_ref.datalen = *((uint32_t*)ser);
17508         ser_ref.data = (int8_t*)(ser + 4);
17509         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
17510         *ret_conv = ChannelConfig_read(ser_ref);
17511         return (uint64_t)ret_conv;
17512 }
17513
17514 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_obj) {
17515         LDKUserConfig this_obj_conv;
17516         this_obj_conv.inner = (void*)(this_obj & (~1));
17517         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17519         UserConfig_free(this_obj_conv);
17520 }
17521
17522 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
17523         LDKUserConfig this_ptr_conv;
17524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17525         this_ptr_conv.is_owned = false;
17526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17527         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
17528         uint64_t ret_ref = 0;
17529         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17530         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17532         ret_ref = (uint64_t)ret_var.inner;
17533         if (ret_var.is_owned) {
17534                 ret_ref |= 1;
17535         }
17536         return ret_ref;
17537 }
17538
17539 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
17540         LDKUserConfig this_ptr_conv;
17541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17542         this_ptr_conv.is_owned = false;
17543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17544         LDKChannelHandshakeConfig val_conv;
17545         val_conv.inner = (void*)(val & (~1));
17546         val_conv.is_owned = (val & 1) || (val == 0);
17547         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
17548         val_conv = ChannelHandshakeConfig_clone(&val_conv);
17549         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
17550 }
17551
17552 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
17553         LDKUserConfig this_ptr_conv;
17554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17555         this_ptr_conv.is_owned = false;
17556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17557         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
17558         uint64_t ret_ref = 0;
17559         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17560         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17562         ret_ref = (uint64_t)ret_var.inner;
17563         if (ret_var.is_owned) {
17564                 ret_ref |= 1;
17565         }
17566         return ret_ref;
17567 }
17568
17569 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
17570         LDKUserConfig this_ptr_conv;
17571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17572         this_ptr_conv.is_owned = false;
17573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17574         LDKChannelHandshakeLimits val_conv;
17575         val_conv.inner = (void*)(val & (~1));
17576         val_conv.is_owned = (val & 1) || (val == 0);
17577         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
17578         val_conv = ChannelHandshakeLimits_clone(&val_conv);
17579         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
17580 }
17581
17582 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
17583         LDKUserConfig this_ptr_conv;
17584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17585         this_ptr_conv.is_owned = false;
17586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17587         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
17588         uint64_t ret_ref = 0;
17589         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17590         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17592         ret_ref = (uint64_t)ret_var.inner;
17593         if (ret_var.is_owned) {
17594                 ret_ref |= 1;
17595         }
17596         return ret_ref;
17597 }
17598
17599 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
17600         LDKUserConfig this_ptr_conv;
17601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17602         this_ptr_conv.is_owned = false;
17603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17604         LDKChannelConfig val_conv;
17605         val_conv.inner = (void*)(val & (~1));
17606         val_conv.is_owned = (val & 1) || (val == 0);
17607         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
17608         val_conv = ChannelConfig_clone(&val_conv);
17609         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
17610 }
17611
17612 jboolean  __attribute__((visibility("default"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
17613         LDKUserConfig this_ptr_conv;
17614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17615         this_ptr_conv.is_owned = false;
17616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17617         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
17618         return ret_val;
17619 }
17620
17621 void  __attribute__((visibility("default"))) TS_UserConfig_set_accept_forwards_to_priv_channels(uint32_t this_ptr, jboolean val) {
17622         LDKUserConfig this_ptr_conv;
17623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17624         this_ptr_conv.is_owned = false;
17625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17626         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
17627 }
17628
17629 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_new(uint32_t own_channel_config_arg, uint32_t peer_channel_config_limits_arg, uint32_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg) {
17630         LDKChannelHandshakeConfig own_channel_config_arg_conv;
17631         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
17632         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
17633         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
17634         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
17635         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
17636         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
17637         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
17638         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
17639         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
17640         LDKChannelConfig channel_options_arg_conv;
17641         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
17642         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
17643         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
17644         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
17645         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg);
17646         uint64_t ret_ref = 0;
17647         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17648         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17650         ret_ref = (uint64_t)ret_var.inner;
17651         if (ret_var.is_owned) {
17652                 ret_ref |= 1;
17653         }
17654         return ret_ref;
17655 }
17656
17657 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
17658         LDKUserConfig ret_var = UserConfig_clone(arg);
17659 uint64_t ret_ref = 0;
17660 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17661 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17662 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17663 ret_ref = (uint64_t)ret_var.inner;
17664 if (ret_var.is_owned) {
17665         ret_ref |= 1;
17666 }
17667         return ret_ref;
17668 }
17669 int64_t  __attribute__((visibility("default"))) TS_UserConfig_clone_ptr(uint32_t arg) {
17670         LDKUserConfig arg_conv;
17671         arg_conv.inner = (void*)(arg & (~1));
17672         arg_conv.is_owned = false;
17673         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17674         int64_t ret_val = UserConfig_clone_ptr(&arg_conv);
17675         return ret_val;
17676 }
17677
17678 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
17679         LDKUserConfig orig_conv;
17680         orig_conv.inner = (void*)(orig & (~1));
17681         orig_conv.is_owned = false;
17682         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17683         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
17684         uint64_t ret_ref = 0;
17685         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17686         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17688         ret_ref = (uint64_t)ret_var.inner;
17689         if (ret_var.is_owned) {
17690                 ret_ref |= 1;
17691         }
17692         return ret_ref;
17693 }
17694
17695 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
17696         LDKUserConfig ret_var = UserConfig_default();
17697         uint64_t ret_ref = 0;
17698         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17699         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17700         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17701         ret_ref = (uint64_t)ret_var.inner;
17702         if (ret_var.is_owned) {
17703                 ret_ref |= 1;
17704         }
17705         return ret_ref;
17706 }
17707
17708 void  __attribute__((visibility("default"))) TS_BestBlock_free(uint32_t this_obj) {
17709         LDKBestBlock this_obj_conv;
17710         this_obj_conv.inner = (void*)(this_obj & (~1));
17711         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17713         BestBlock_free(this_obj_conv);
17714 }
17715
17716 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
17717         LDKBestBlock ret_var = BestBlock_clone(arg);
17718 uint64_t ret_ref = 0;
17719 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17720 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17721 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17722 ret_ref = (uint64_t)ret_var.inner;
17723 if (ret_var.is_owned) {
17724         ret_ref |= 1;
17725 }
17726         return ret_ref;
17727 }
17728 int64_t  __attribute__((visibility("default"))) TS_BestBlock_clone_ptr(uint32_t arg) {
17729         LDKBestBlock arg_conv;
17730         arg_conv.inner = (void*)(arg & (~1));
17731         arg_conv.is_owned = false;
17732         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17733         int64_t ret_val = BestBlock_clone_ptr(&arg_conv);
17734         return ret_val;
17735 }
17736
17737 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t orig) {
17738         LDKBestBlock orig_conv;
17739         orig_conv.inner = (void*)(orig & (~1));
17740         orig_conv.is_owned = false;
17741         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17742         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
17743         uint64_t ret_ref = 0;
17744         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17745         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17747         ret_ref = (uint64_t)ret_var.inner;
17748         if (ret_var.is_owned) {
17749                 ret_ref |= 1;
17750         }
17751         return ret_ref;
17752 }
17753
17754 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) {
17755         LDKNetwork network_conv = LDKNetwork_from_js(network);
17756         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
17757         uint64_t ret_ref = 0;
17758         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17759         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17761         ret_ref = (uint64_t)ret_var.inner;
17762         if (ret_var.is_owned) {
17763                 ret_ref |= 1;
17764         }
17765         return ret_ref;
17766 }
17767
17768 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
17769         LDKThirtyTwoBytes block_hash_ref;
17770         CHECK(*((uint32_t*)block_hash) == 32);
17771         memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32);
17772         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
17773         uint64_t ret_ref = 0;
17774         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17775         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17777         ret_ref = (uint64_t)ret_var.inner;
17778         if (ret_var.is_owned) {
17779                 ret_ref |= 1;
17780         }
17781         return ret_ref;
17782 }
17783
17784 int8_tArray  __attribute__((visibility("default"))) TS_BestBlock_block_hash(uint32_t this_arg) {
17785         LDKBestBlock this_arg_conv;
17786         this_arg_conv.inner = (void*)(this_arg & (~1));
17787         this_arg_conv.is_owned = false;
17788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
17789         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17790         memcpy((uint8_t*)(ret_arr + 4), BestBlock_block_hash(&this_arg_conv).data, 32);
17791         return ret_arr;
17792 }
17793
17794 int32_t  __attribute__((visibility("default"))) TS_BestBlock_height(uint32_t this_arg) {
17795         LDKBestBlock this_arg_conv;
17796         this_arg_conv.inner = (void*)(this_arg & (~1));
17797         this_arg_conv.is_owned = false;
17798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
17799         int32_t ret_val = BestBlock_height(&this_arg_conv);
17800         return ret_val;
17801 }
17802
17803 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
17804         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
17805         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
17806         return ret_conv;
17807 }
17808
17809 uint32_t  __attribute__((visibility("default"))) TS_AccessError_unknown_chain() {
17810         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
17811         return ret_conv;
17812 }
17813
17814 uint32_t  __attribute__((visibility("default"))) TS_AccessError_unknown_tx() {
17815         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
17816         return ret_conv;
17817 }
17818
17819 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
17820         if ((this_ptr & 1) != 0) return;
17821         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17822         CHECK_ACCESS(this_ptr_ptr);
17823         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
17824         FREE((void*)this_ptr);
17825         Access_free(this_ptr_conv);
17826 }
17827
17828 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
17829         if ((this_ptr & 1) != 0) return;
17830         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17831         CHECK_ACCESS(this_ptr_ptr);
17832         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
17833         FREE((void*)this_ptr);
17834         Listen_free(this_ptr_conv);
17835 }
17836
17837 void  __attribute__((visibility("default"))) TS_Confirm_free(uint32_t this_ptr) {
17838         if ((this_ptr & 1) != 0) return;
17839         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17840         CHECK_ACCESS(this_ptr_ptr);
17841         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
17842         FREE((void*)this_ptr);
17843         Confirm_free(this_ptr_conv);
17844 }
17845
17846 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
17847         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
17848         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
17849         return ret_conv;
17850 }
17851
17852 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
17853         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
17854         return ret_conv;
17855 }
17856
17857 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
17858         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
17859         return ret_conv;
17860 }
17861
17862 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
17863         if ((this_ptr & 1) != 0) return;
17864         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17865         CHECK_ACCESS(this_ptr_ptr);
17866         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
17867         FREE((void*)this_ptr);
17868         Watch_free(this_ptr_conv);
17869 }
17870
17871 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
17872         if ((this_ptr & 1) != 0) return;
17873         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17874         CHECK_ACCESS(this_ptr_ptr);
17875         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
17876         FREE((void*)this_ptr);
17877         Filter_free(this_ptr_conv);
17878 }
17879
17880 void  __attribute__((visibility("default"))) TS_WatchedOutput_free(uint32_t this_obj) {
17881         LDKWatchedOutput this_obj_conv;
17882         this_obj_conv.inner = (void*)(this_obj & (~1));
17883         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17885         WatchedOutput_free(this_obj_conv);
17886 }
17887
17888 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
17889         LDKWatchedOutput this_ptr_conv;
17890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17891         this_ptr_conv.is_owned = false;
17892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17893         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17894         memcpy((uint8_t*)(ret_arr + 4), WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
17895         return ret_arr;
17896 }
17897
17898 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
17899         LDKWatchedOutput this_ptr_conv;
17900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17901         this_ptr_conv.is_owned = false;
17902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17903         LDKThirtyTwoBytes val_ref;
17904         CHECK(*((uint32_t*)val) == 32);
17905         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17906         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
17907 }
17908
17909 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
17910         LDKWatchedOutput this_ptr_conv;
17911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17912         this_ptr_conv.is_owned = false;
17913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17914         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
17915         uint64_t ret_ref = 0;
17916         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17917         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17919         ret_ref = (uint64_t)ret_var.inner;
17920         if (ret_var.is_owned) {
17921                 ret_ref |= 1;
17922         }
17923         return ret_ref;
17924 }
17925
17926 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
17927         LDKWatchedOutput this_ptr_conv;
17928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17929         this_ptr_conv.is_owned = false;
17930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17931         LDKOutPoint val_conv;
17932         val_conv.inner = (void*)(val & (~1));
17933         val_conv.is_owned = (val & 1) || (val == 0);
17934         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
17935         val_conv = OutPoint_clone(&val_conv);
17936         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
17937 }
17938
17939 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
17940         LDKWatchedOutput this_ptr_conv;
17941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17942         this_ptr_conv.is_owned = false;
17943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17944         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
17945         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17946         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17947         return ret_arr;
17948 }
17949
17950 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
17951         LDKWatchedOutput this_ptr_conv;
17952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17953         this_ptr_conv.is_owned = false;
17954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17955         LDKCVec_u8Z val_ref;
17956         val_ref.datalen = *((uint32_t*)val);
17957         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
17958         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
17959         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
17960 }
17961
17962 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_new(int8_tArray block_hash_arg, uint32_t outpoint_arg, int8_tArray script_pubkey_arg) {
17963         LDKThirtyTwoBytes block_hash_arg_ref;
17964         CHECK(*((uint32_t*)block_hash_arg) == 32);
17965         memcpy(block_hash_arg_ref.data, (uint8_t*)(block_hash_arg + 4), 32);
17966         LDKOutPoint outpoint_arg_conv;
17967         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
17968         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
17969         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
17970         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
17971         LDKCVec_u8Z script_pubkey_arg_ref;
17972         script_pubkey_arg_ref.datalen = *((uint32_t*)script_pubkey_arg);
17973         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
17974         memcpy(script_pubkey_arg_ref.data, (uint8_t*)(script_pubkey_arg + 4), script_pubkey_arg_ref.datalen);
17975         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
17976         uint64_t ret_ref = 0;
17977         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17978         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17980         ret_ref = (uint64_t)ret_var.inner;
17981         if (ret_var.is_owned) {
17982                 ret_ref |= 1;
17983         }
17984         return ret_ref;
17985 }
17986
17987 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
17988         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
17989 uint64_t ret_ref = 0;
17990 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17991 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17992 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17993 ret_ref = (uint64_t)ret_var.inner;
17994 if (ret_var.is_owned) {
17995         ret_ref |= 1;
17996 }
17997         return ret_ref;
17998 }
17999 int64_t  __attribute__((visibility("default"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
18000         LDKWatchedOutput arg_conv;
18001         arg_conv.inner = (void*)(arg & (~1));
18002         arg_conv.is_owned = false;
18003         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18004         int64_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
18005         return ret_val;
18006 }
18007
18008 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_clone(uint32_t orig) {
18009         LDKWatchedOutput orig_conv;
18010         orig_conv.inner = (void*)(orig & (~1));
18011         orig_conv.is_owned = false;
18012         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18013         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
18014         uint64_t ret_ref = 0;
18015         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18016         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18018         ret_ref = (uint64_t)ret_var.inner;
18019         if (ret_var.is_owned) {
18020                 ret_ref |= 1;
18021         }
18022         return ret_ref;
18023 }
18024
18025 int64_t  __attribute__((visibility("default"))) TS_WatchedOutput_hash(uint32_t o) {
18026         LDKWatchedOutput o_conv;
18027         o_conv.inner = (void*)(o & (~1));
18028         o_conv.is_owned = false;
18029         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18030         int64_t ret_val = WatchedOutput_hash(&o_conv);
18031         return ret_val;
18032 }
18033
18034 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
18035         if ((this_ptr & 1) != 0) return;
18036         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18037         CHECK_ACCESS(this_ptr_ptr);
18038         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
18039         FREE((void*)this_ptr);
18040         BroadcasterInterface_free(this_ptr_conv);
18041 }
18042
18043 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
18044         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
18045         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
18046         return ret_conv;
18047 }
18048
18049 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_background() {
18050         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
18051         return ret_conv;
18052 }
18053
18054 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_normal() {
18055         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
18056         return ret_conv;
18057 }
18058
18059 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_high_priority() {
18060         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
18061         return ret_conv;
18062 }
18063
18064 jboolean  __attribute__((visibility("default"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
18065         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
18066         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
18067         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
18068         return ret_val;
18069 }
18070
18071 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
18072         if ((this_ptr & 1) != 0) return;
18073         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18074         CHECK_ACCESS(this_ptr_ptr);
18075         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
18076         FREE((void*)this_ptr);
18077         FeeEstimator_free(this_ptr_conv);
18078 }
18079
18080 void  __attribute__((visibility("default"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
18081         LDKMonitorUpdateId this_obj_conv;
18082         this_obj_conv.inner = (void*)(this_obj & (~1));
18083         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18085         MonitorUpdateId_free(this_obj_conv);
18086 }
18087
18088 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
18089         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
18090 uint64_t ret_ref = 0;
18091 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18092 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18093 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18094 ret_ref = (uint64_t)ret_var.inner;
18095 if (ret_var.is_owned) {
18096         ret_ref |= 1;
18097 }
18098         return ret_ref;
18099 }
18100 int64_t  __attribute__((visibility("default"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
18101         LDKMonitorUpdateId arg_conv;
18102         arg_conv.inner = (void*)(arg & (~1));
18103         arg_conv.is_owned = false;
18104         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18105         int64_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
18106         return ret_val;
18107 }
18108
18109 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateId_clone(uint32_t orig) {
18110         LDKMonitorUpdateId orig_conv;
18111         orig_conv.inner = (void*)(orig & (~1));
18112         orig_conv.is_owned = false;
18113         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18114         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
18115         uint64_t ret_ref = 0;
18116         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18117         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18119         ret_ref = (uint64_t)ret_var.inner;
18120         if (ret_var.is_owned) {
18121                 ret_ref |= 1;
18122         }
18123         return ret_ref;
18124 }
18125
18126 int64_t  __attribute__((visibility("default"))) TS_MonitorUpdateId_hash(uint32_t o) {
18127         LDKMonitorUpdateId o_conv;
18128         o_conv.inner = (void*)(o & (~1));
18129         o_conv.is_owned = false;
18130         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18131         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
18132         return ret_val;
18133 }
18134
18135 jboolean  __attribute__((visibility("default"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
18136         LDKMonitorUpdateId a_conv;
18137         a_conv.inner = (void*)(a & (~1));
18138         a_conv.is_owned = false;
18139         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18140         LDKMonitorUpdateId b_conv;
18141         b_conv.inner = (void*)(b & (~1));
18142         b_conv.is_owned = false;
18143         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18144         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
18145         return ret_val;
18146 }
18147
18148 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
18149         if ((this_ptr & 1) != 0) return;
18150         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18151         CHECK_ACCESS(this_ptr_ptr);
18152         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
18153         FREE((void*)this_ptr);
18154         Persist_free(this_ptr_conv);
18155 }
18156
18157 void  __attribute__((visibility("default"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
18158         LDKLockedChannelMonitor this_obj_conv;
18159         this_obj_conv.inner = (void*)(this_obj & (~1));
18160         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18162         LockedChannelMonitor_free(this_obj_conv);
18163 }
18164
18165 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
18166         LDKChainMonitor this_obj_conv;
18167         this_obj_conv.inner = (void*)(this_obj & (~1));
18168         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18170         ChainMonitor_free(this_obj_conv);
18171 }
18172
18173 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
18174         void* chain_source_ptr = (void*)(((uint64_t)chain_source) & ~1);
18175         CHECK_ACCESS(chain_source_ptr);
18176         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
18177         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
18178         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
18179                 // Manually implement clone for Java trait instances
18180         }
18181         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
18182         CHECK_ACCESS(broadcaster_ptr);
18183         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
18184         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
18185         CHECK_ACCESS(logger_ptr);
18186         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
18187         void* feeest_ptr = (void*)(((uint64_t)feeest) & ~1);
18188         CHECK_ACCESS(feeest_ptr);
18189         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
18190         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
18191         CHECK_ACCESS(persister_ptr);
18192         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
18193         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
18194         uint64_t ret_ref = 0;
18195         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18196         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18198         ret_ref = (uint64_t)ret_var.inner;
18199         if (ret_var.is_owned) {
18200                 ret_ref |= 1;
18201         }
18202         return ret_ref;
18203 }
18204
18205 uint32_tArray  __attribute__((visibility("default"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
18206         LDKChainMonitor this_arg_conv;
18207         this_arg_conv.inner = (void*)(this_arg & (~1));
18208         this_arg_conv.is_owned = false;
18209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18210         LDKCVec_ChannelDetailsZ ignored_channels_constr;
18211         ignored_channels_constr.datalen = *((uint32_t*)ignored_channels);
18212         if (ignored_channels_constr.datalen > 0)
18213                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
18214         else
18215                 ignored_channels_constr.data = NULL;
18216         uint32_t* ignored_channels_vals = (uint32_t*)(ignored_channels + 4);
18217         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
18218                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
18219                 LDKChannelDetails ignored_channels_conv_16_conv;
18220                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
18221                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
18222                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
18223                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
18224                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
18225         }
18226         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
18227         uint32_tArray ret_arr = NULL;
18228         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
18229         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
18230         for (size_t j = 0; j < ret_var.datalen; j++) {
18231                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
18232                 *ret_conv_9_copy = ret_var.data[j];
18233                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
18234                 ret_arr_ptr[j] = ret_conv_9_ref;
18235         }
18236         
18237         FREE(ret_var.data);
18238         return ret_arr;
18239 }
18240
18241 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
18242         LDKChainMonitor this_arg_conv;
18243         this_arg_conv.inner = (void*)(this_arg & (~1));
18244         this_arg_conv.is_owned = false;
18245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18246         LDKOutPoint funding_txo_conv;
18247         funding_txo_conv.inner = (void*)(funding_txo & (~1));
18248         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
18249         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
18250         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
18251         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
18252         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
18253         return (uint64_t)ret_conv;
18254 }
18255
18256 uint32_tArray  __attribute__((visibility("default"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
18257         LDKChainMonitor this_arg_conv;
18258         this_arg_conv.inner = (void*)(this_arg & (~1));
18259         this_arg_conv.is_owned = false;
18260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18261         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
18262         uint32_tArray ret_arr = NULL;
18263         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
18264         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
18265         for (size_t k = 0; k < ret_var.datalen; k++) {
18266                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
18267                 uint64_t ret_conv_10_ref = 0;
18268                 CHECK((((uint64_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18269                 CHECK((((uint64_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18270                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
18271                 ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
18272                 if (ret_conv_10_var.is_owned) {
18273                         ret_conv_10_ref |= 1;
18274                 }
18275                 ret_arr_ptr[k] = ret_conv_10_ref;
18276         }
18277         
18278         FREE(ret_var.data);
18279         return ret_arr;
18280 }
18281
18282 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, uint32_t completed_update_id) {
18283         LDKChainMonitor this_arg_conv;
18284         this_arg_conv.inner = (void*)(this_arg & (~1));
18285         this_arg_conv.is_owned = false;
18286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18287         LDKOutPoint funding_txo_conv;
18288         funding_txo_conv.inner = (void*)(funding_txo & (~1));
18289         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
18290         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
18291         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
18292         LDKMonitorUpdateId completed_update_id_conv;
18293         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
18294         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
18295         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
18296         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
18297         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18298         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
18299         return (uint64_t)ret_conv;
18300 }
18301
18302 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
18303         LDKChainMonitor this_arg_conv;
18304         this_arg_conv.inner = (void*)(this_arg & (~1));
18305         this_arg_conv.is_owned = false;
18306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18307         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
18308         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
18309         return (uint64_t)ret_ret;
18310 }
18311
18312 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
18313         LDKChainMonitor this_arg_conv;
18314         this_arg_conv.inner = (void*)(this_arg & (~1));
18315         this_arg_conv.is_owned = false;
18316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18317         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
18318         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
18319         return (uint64_t)ret_ret;
18320 }
18321
18322 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
18323         LDKChainMonitor this_arg_conv;
18324         this_arg_conv.inner = (void*)(this_arg & (~1));
18325         this_arg_conv.is_owned = false;
18326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18327         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
18328         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
18329         return (uint64_t)ret_ret;
18330 }
18331
18332 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
18333         LDKChainMonitor this_arg_conv;
18334         this_arg_conv.inner = (void*)(this_arg & (~1));
18335         this_arg_conv.is_owned = false;
18336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18337         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
18338         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
18339         return (uint64_t)ret_ret;
18340 }
18341
18342 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
18343         LDKChannelMonitorUpdate this_obj_conv;
18344         this_obj_conv.inner = (void*)(this_obj & (~1));
18345         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18347         ChannelMonitorUpdate_free(this_obj_conv);
18348 }
18349
18350 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
18351         LDKChannelMonitorUpdate this_ptr_conv;
18352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18353         this_ptr_conv.is_owned = false;
18354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18355         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
18356         return ret_val;
18357 }
18358
18359 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
18360         LDKChannelMonitorUpdate this_ptr_conv;
18361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18362         this_ptr_conv.is_owned = false;
18363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18364         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
18365 }
18366
18367 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
18368         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
18369 uint64_t ret_ref = 0;
18370 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18371 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18372 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18373 ret_ref = (uint64_t)ret_var.inner;
18374 if (ret_var.is_owned) {
18375         ret_ref |= 1;
18376 }
18377         return ret_ref;
18378 }
18379 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
18380         LDKChannelMonitorUpdate arg_conv;
18381         arg_conv.inner = (void*)(arg & (~1));
18382         arg_conv.is_owned = false;
18383         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18384         int64_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
18385         return ret_val;
18386 }
18387
18388 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
18389         LDKChannelMonitorUpdate orig_conv;
18390         orig_conv.inner = (void*)(orig & (~1));
18391         orig_conv.is_owned = false;
18392         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18393         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
18394         uint64_t ret_ref = 0;
18395         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18396         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18398         ret_ref = (uint64_t)ret_var.inner;
18399         if (ret_var.is_owned) {
18400                 ret_ref |= 1;
18401         }
18402         return ret_ref;
18403 }
18404
18405 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
18406         LDKChannelMonitorUpdate obj_conv;
18407         obj_conv.inner = (void*)(obj & (~1));
18408         obj_conv.is_owned = false;
18409         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
18410         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
18411         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18412         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18413         CVec_u8Z_free(ret_var);
18414         return ret_arr;
18415 }
18416
18417 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
18418         LDKu8slice ser_ref;
18419         ser_ref.datalen = *((uint32_t*)ser);
18420         ser_ref.data = (int8_t*)(ser + 4);
18421         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
18422         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
18423         return (uint64_t)ret_conv;
18424 }
18425
18426 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_obj) {
18427         LDKMonitorUpdateError this_obj_conv;
18428         this_obj_conv.inner = (void*)(this_obj & (~1));
18429         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18431         MonitorUpdateError_free(this_obj_conv);
18432 }
18433
18434 jstring  __attribute__((visibility("default"))) TS_MonitorUpdateError_get_a(uint32_t this_ptr) {
18435         LDKMonitorUpdateError this_ptr_conv;
18436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18437         this_ptr_conv.is_owned = false;
18438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18439         LDKStr ret_str = MonitorUpdateError_get_a(&this_ptr_conv);
18440         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
18441         Str_free(ret_str);
18442         return ret_conv;
18443 }
18444
18445 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_set_a(uint32_t this_ptr, jstring val) {
18446         LDKMonitorUpdateError this_ptr_conv;
18447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18448         this_ptr_conv.is_owned = false;
18449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18450         LDKStr val_conv = str_ref_to_owned_c(val);
18451         MonitorUpdateError_set_a(&this_ptr_conv, val_conv);
18452 }
18453
18454 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_new(jstring a_arg) {
18455         LDKStr a_arg_conv = str_ref_to_owned_c(a_arg);
18456         LDKMonitorUpdateError ret_var = MonitorUpdateError_new(a_arg_conv);
18457         uint64_t ret_ref = 0;
18458         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18459         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18461         ret_ref = (uint64_t)ret_var.inner;
18462         if (ret_var.is_owned) {
18463                 ret_ref |= 1;
18464         }
18465         return ret_ref;
18466 }
18467
18468 static inline uint64_t MonitorUpdateError_clone_ptr(LDKMonitorUpdateError *NONNULL_PTR arg) {
18469         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(arg);
18470 uint64_t ret_ref = 0;
18471 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18472 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18473 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18474 ret_ref = (uint64_t)ret_var.inner;
18475 if (ret_var.is_owned) {
18476         ret_ref |= 1;
18477 }
18478         return ret_ref;
18479 }
18480 int64_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone_ptr(uint32_t arg) {
18481         LDKMonitorUpdateError arg_conv;
18482         arg_conv.inner = (void*)(arg & (~1));
18483         arg_conv.is_owned = false;
18484         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18485         int64_t ret_val = MonitorUpdateError_clone_ptr(&arg_conv);
18486         return ret_val;
18487 }
18488
18489 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
18490         LDKMonitorUpdateError orig_conv;
18491         orig_conv.inner = (void*)(orig & (~1));
18492         orig_conv.is_owned = false;
18493         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18494         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
18495         uint64_t ret_ref = 0;
18496         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18497         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18499         ret_ref = (uint64_t)ret_var.inner;
18500         if (ret_var.is_owned) {
18501                 ret_ref |= 1;
18502         }
18503         return ret_ref;
18504 }
18505
18506 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
18507         if ((this_ptr & 1) != 0) return;
18508         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18509         CHECK_ACCESS(this_ptr_ptr);
18510         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
18511         FREE((void*)this_ptr);
18512         MonitorEvent_free(this_ptr_conv);
18513 }
18514
18515 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
18516         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18517         *ret_copy = MonitorEvent_clone(arg);
18518 uint64_t ret_ref = (uint64_t)ret_copy;
18519         return ret_ref;
18520 }
18521 int64_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
18522         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
18523         int64_t ret_val = MonitorEvent_clone_ptr(arg_conv);
18524         return ret_val;
18525 }
18526
18527 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
18528         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
18529         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18530         *ret_copy = MonitorEvent_clone(orig_conv);
18531         uint64_t ret_ref = (uint64_t)ret_copy;
18532         return ret_ref;
18533 }
18534
18535 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_htlcevent(uint32_t a) {
18536         LDKHTLCUpdate a_conv;
18537         a_conv.inner = (void*)(a & (~1));
18538         a_conv.is_owned = (a & 1) || (a == 0);
18539         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18540         a_conv = HTLCUpdate_clone(&a_conv);
18541         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18542         *ret_copy = MonitorEvent_htlcevent(a_conv);
18543         uint64_t ret_ref = (uint64_t)ret_copy;
18544         return ret_ref;
18545 }
18546
18547 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
18548         LDKOutPoint a_conv;
18549         a_conv.inner = (void*)(a & (~1));
18550         a_conv.is_owned = (a & 1) || (a == 0);
18551         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18552         a_conv = OutPoint_clone(&a_conv);
18553         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18554         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
18555         uint64_t ret_ref = (uint64_t)ret_copy;
18556         return ret_ref;
18557 }
18558
18559 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
18560         LDKOutPoint funding_txo_conv;
18561         funding_txo_conv.inner = (void*)(funding_txo & (~1));
18562         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
18563         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
18564         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
18565         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18566         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
18567         uint64_t ret_ref = (uint64_t)ret_copy;
18568         return ret_ref;
18569 }
18570
18571 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_update_failed(uint32_t a) {
18572         LDKOutPoint a_conv;
18573         a_conv.inner = (void*)(a & (~1));
18574         a_conv.is_owned = (a & 1) || (a == 0);
18575         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18576         a_conv = OutPoint_clone(&a_conv);
18577         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18578         *ret_copy = MonitorEvent_update_failed(a_conv);
18579         uint64_t ret_ref = (uint64_t)ret_copy;
18580         return ret_ref;
18581 }
18582
18583 int8_tArray  __attribute__((visibility("default"))) TS_MonitorEvent_write(uint32_t obj) {
18584         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
18585         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
18586         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18587         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18588         CVec_u8Z_free(ret_var);
18589         return ret_arr;
18590 }
18591
18592 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_read(int8_tArray ser) {
18593         LDKu8slice ser_ref;
18594         ser_ref.datalen = *((uint32_t*)ser);
18595         ser_ref.data = (int8_t*)(ser + 4);
18596         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
18597         *ret_conv = MonitorEvent_read(ser_ref);
18598         return (uint64_t)ret_conv;
18599 }
18600
18601 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_obj) {
18602         LDKHTLCUpdate this_obj_conv;
18603         this_obj_conv.inner = (void*)(this_obj & (~1));
18604         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18606         HTLCUpdate_free(this_obj_conv);
18607 }
18608
18609 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
18610         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
18611 uint64_t ret_ref = 0;
18612 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18613 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18614 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18615 ret_ref = (uint64_t)ret_var.inner;
18616 if (ret_var.is_owned) {
18617         ret_ref |= 1;
18618 }
18619         return ret_ref;
18620 }
18621 int64_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
18622         LDKHTLCUpdate arg_conv;
18623         arg_conv.inner = (void*)(arg & (~1));
18624         arg_conv.is_owned = false;
18625         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18626         int64_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
18627         return ret_val;
18628 }
18629
18630 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
18631         LDKHTLCUpdate orig_conv;
18632         orig_conv.inner = (void*)(orig & (~1));
18633         orig_conv.is_owned = false;
18634         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18635         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
18636         uint64_t ret_ref = 0;
18637         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18638         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18640         ret_ref = (uint64_t)ret_var.inner;
18641         if (ret_var.is_owned) {
18642                 ret_ref |= 1;
18643         }
18644         return ret_ref;
18645 }
18646
18647 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
18648         LDKHTLCUpdate obj_conv;
18649         obj_conv.inner = (void*)(obj & (~1));
18650         obj_conv.is_owned = false;
18651         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
18652         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
18653         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18654         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18655         CVec_u8Z_free(ret_var);
18656         return ret_arr;
18657 }
18658
18659 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
18660         LDKu8slice ser_ref;
18661         ser_ref.datalen = *((uint32_t*)ser);
18662         ser_ref.data = (int8_t*)(ser + 4);
18663         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
18664         *ret_conv = HTLCUpdate_read(ser_ref);
18665         return (uint64_t)ret_conv;
18666 }
18667
18668 void  __attribute__((visibility("default"))) TS_Balance_free(uint32_t this_ptr) {
18669         if ((this_ptr & 1) != 0) return;
18670         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18671         CHECK_ACCESS(this_ptr_ptr);
18672         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
18673         FREE((void*)this_ptr);
18674         Balance_free(this_ptr_conv);
18675 }
18676
18677 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
18678         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
18679         *ret_copy = Balance_clone(arg);
18680 uint64_t ret_ref = (uint64_t)ret_copy;
18681         return ret_ref;
18682 }
18683 int64_t  __attribute__((visibility("default"))) TS_Balance_clone_ptr(uint32_t arg) {
18684         LDKBalance* arg_conv = (LDKBalance*)arg;
18685         int64_t ret_val = Balance_clone_ptr(arg_conv);
18686         return ret_val;
18687 }
18688
18689 uint32_t  __attribute__((visibility("default"))) TS_Balance_clone(uint32_t orig) {
18690         LDKBalance* orig_conv = (LDKBalance*)orig;
18691         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
18692         *ret_copy = Balance_clone(orig_conv);
18693         uint64_t ret_ref = (uint64_t)ret_copy;
18694         return ret_ref;
18695 }
18696
18697 uint32_t  __attribute__((visibility("default"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
18698         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
18699         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
18700         uint64_t ret_ref = (uint64_t)ret_copy;
18701         return ret_ref;
18702 }
18703
18704 uint32_t  __attribute__((visibility("default"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
18705         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
18706         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
18707         uint64_t ret_ref = (uint64_t)ret_copy;
18708         return ret_ref;
18709 }
18710
18711 uint32_t  __attribute__((visibility("default"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
18712         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
18713         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
18714         uint64_t ret_ref = (uint64_t)ret_copy;
18715         return ret_ref;
18716 }
18717
18718 uint32_t  __attribute__((visibility("default"))) TS_Balance_maybe_claimable_htlcawaiting_timeout(int64_t claimable_amount_satoshis, int32_t claimable_height) {
18719         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
18720         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
18721         uint64_t ret_ref = (uint64_t)ret_copy;
18722         return ret_ref;
18723 }
18724
18725 jboolean  __attribute__((visibility("default"))) TS_Balance_eq(uint32_t a, uint32_t b) {
18726         LDKBalance* a_conv = (LDKBalance*)a;
18727         LDKBalance* b_conv = (LDKBalance*)b;
18728         jboolean ret_val = Balance_eq(a_conv, b_conv);
18729         return ret_val;
18730 }
18731
18732 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) {
18733         LDKChannelMonitor this_obj_conv;
18734         this_obj_conv.inner = (void*)(this_obj & (~1));
18735         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18737         ChannelMonitor_free(this_obj_conv);
18738 }
18739
18740 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
18741         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
18742 uint64_t ret_ref = 0;
18743 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18744 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18745 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18746 ret_ref = (uint64_t)ret_var.inner;
18747 if (ret_var.is_owned) {
18748         ret_ref |= 1;
18749 }
18750         return ret_ref;
18751 }
18752 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
18753         LDKChannelMonitor arg_conv;
18754         arg_conv.inner = (void*)(arg & (~1));
18755         arg_conv.is_owned = false;
18756         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18757         int64_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
18758         return ret_val;
18759 }
18760
18761 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_t orig) {
18762         LDKChannelMonitor orig_conv;
18763         orig_conv.inner = (void*)(orig & (~1));
18764         orig_conv.is_owned = false;
18765         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18766         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
18767         uint64_t ret_ref = 0;
18768         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18769         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18771         ret_ref = (uint64_t)ret_var.inner;
18772         if (ret_var.is_owned) {
18773                 ret_ref |= 1;
18774         }
18775         return ret_ref;
18776 }
18777
18778 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
18779         LDKChannelMonitor obj_conv;
18780         obj_conv.inner = (void*)(obj & (~1));
18781         obj_conv.is_owned = false;
18782         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
18783         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
18784         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18785         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18786         CVec_u8Z_free(ret_var);
18787         return ret_arr;
18788 }
18789
18790 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_update_monitor(uint32_t this_arg, uint32_t updates, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
18791         LDKChannelMonitor this_arg_conv;
18792         this_arg_conv.inner = (void*)(this_arg & (~1));
18793         this_arg_conv.is_owned = false;
18794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18795         LDKChannelMonitorUpdate updates_conv;
18796         updates_conv.inner = (void*)(updates & (~1));
18797         updates_conv.is_owned = false;
18798         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
18799         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
18800         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
18801         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
18802         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
18803         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
18804         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
18805         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
18806         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
18807         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
18808         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
18809         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
18810         return (uint64_t)ret_conv;
18811 }
18812
18813 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
18814         LDKChannelMonitor this_arg_conv;
18815         this_arg_conv.inner = (void*)(this_arg & (~1));
18816         this_arg_conv.is_owned = false;
18817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18818         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
18819         return ret_val;
18820 }
18821
18822 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
18823         LDKChannelMonitor this_arg_conv;
18824         this_arg_conv.inner = (void*)(this_arg & (~1));
18825         this_arg_conv.is_owned = false;
18826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18827         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
18828         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
18829         return ((uint64_t)ret_conv);
18830 }
18831
18832 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
18833         LDKChannelMonitor this_arg_conv;
18834         this_arg_conv.inner = (void*)(this_arg & (~1));
18835         this_arg_conv.is_owned = false;
18836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18837         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
18838         uint32_tArray ret_arr = NULL;
18839         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
18840         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
18841         for (size_t o = 0; o < ret_var.datalen; o++) {
18842                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
18843                 *ret_conv_40_conv = ret_var.data[o];
18844                 ret_arr_ptr[o] = ((uint64_t)ret_conv_40_conv);
18845         }
18846         
18847         FREE(ret_var.data);
18848         return ret_arr;
18849 }
18850
18851 void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
18852         LDKChannelMonitor this_arg_conv;
18853         this_arg_conv.inner = (void*)(this_arg & (~1));
18854         this_arg_conv.is_owned = false;
18855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18856         void* filter_ptr = (void*)(((uint64_t)filter) & ~1);
18857         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
18858         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
18859         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
18860 }
18861
18862 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
18863         LDKChannelMonitor this_arg_conv;
18864         this_arg_conv.inner = (void*)(this_arg & (~1));
18865         this_arg_conv.is_owned = false;
18866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18867         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
18868         uint32_tArray ret_arr = NULL;
18869         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
18870         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
18871         for (size_t o = 0; o < ret_var.datalen; o++) {
18872                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18873                 *ret_conv_14_copy = ret_var.data[o];
18874                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
18875                 ret_arr_ptr[o] = ret_conv_14_ref;
18876         }
18877         
18878         FREE(ret_var.data);
18879         return ret_arr;
18880 }
18881
18882 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
18883         LDKChannelMonitor this_arg_conv;
18884         this_arg_conv.inner = (void*)(this_arg & (~1));
18885         this_arg_conv.is_owned = false;
18886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18887         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
18888         uint32_tArray ret_arr = NULL;
18889         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
18890         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
18891         for (size_t h = 0; h < ret_var.datalen; h++) {
18892                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
18893                 *ret_conv_7_copy = ret_var.data[h];
18894                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
18895                 ret_arr_ptr[h] = ret_conv_7_ref;
18896         }
18897         
18898         FREE(ret_var.data);
18899         return ret_arr;
18900 }
18901
18902 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
18903         LDKChannelMonitor this_arg_conv;
18904         this_arg_conv.inner = (void*)(this_arg & (~1));
18905         this_arg_conv.is_owned = false;
18906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18907         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
18908         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
18909         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
18910         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
18911         ptrArray ret_arr = NULL;
18912         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
18913         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
18914         for (size_t m = 0; m < ret_var.datalen; m++) {
18915                 LDKTransaction ret_conv_12_var = ret_var.data[m];
18916                 int8_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18917                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_conv_12_var.data, ret_conv_12_var.datalen);
18918                 Transaction_free(ret_conv_12_var);
18919                 ret_arr_ptr[m] = ret_conv_12_arr;
18920         }
18921         
18922         FREE(ret_var.data);
18923         return ret_arr;
18924 }
18925
18926 uint32_tArray  __attribute__((visibility("default"))) 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) {
18927         LDKChannelMonitor this_arg_conv;
18928         this_arg_conv.inner = (void*)(this_arg & (~1));
18929         this_arg_conv.is_owned = false;
18930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18931         unsigned char header_arr[80];
18932         CHECK(*((uint32_t*)header) == 80);
18933         memcpy(header_arr, (uint8_t*)(header + 4), 80);
18934         unsigned char (*header_ref)[80] = &header_arr;
18935         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
18936         txdata_constr.datalen = *((uint32_t*)txdata);
18937         if (txdata_constr.datalen > 0)
18938                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
18939         else
18940                 txdata_constr.data = NULL;
18941         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
18942         for (size_t c = 0; c < txdata_constr.datalen; c++) {
18943                 uint32_t txdata_conv_28 = txdata_vals[c];
18944                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
18945                 CHECK_ACCESS(txdata_conv_28_ptr);
18946                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
18947                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
18948                 txdata_constr.data[c] = txdata_conv_28_conv;
18949         }
18950         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
18951         CHECK_ACCESS(broadcaster_ptr);
18952         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
18953         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
18954         CHECK_ACCESS(fee_estimator_ptr);
18955         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
18956         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
18957         CHECK_ACCESS(logger_ptr);
18958         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
18959         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);
18960         uint32_tArray ret_arr = NULL;
18961         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
18962         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
18963         for (size_t n = 0; n < ret_var.datalen; n++) {
18964                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18965                 *ret_conv_39_conv = ret_var.data[n];
18966                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
18967         }
18968         
18969         FREE(ret_var.data);
18970         return ret_arr;
18971 }
18972
18973 void  __attribute__((visibility("default"))) TS_ChannelMonitor_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
18974         LDKChannelMonitor this_arg_conv;
18975         this_arg_conv.inner = (void*)(this_arg & (~1));
18976         this_arg_conv.is_owned = false;
18977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18978         unsigned char header_arr[80];
18979         CHECK(*((uint32_t*)header) == 80);
18980         memcpy(header_arr, (uint8_t*)(header + 4), 80);
18981         unsigned char (*header_ref)[80] = &header_arr;
18982         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
18983         CHECK_ACCESS(broadcaster_ptr);
18984         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
18985         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
18986         CHECK_ACCESS(fee_estimator_ptr);
18987         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
18988         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
18989         CHECK_ACCESS(logger_ptr);
18990         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
18991         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
18992 }
18993
18994 uint32_tArray  __attribute__((visibility("default"))) 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) {
18995         LDKChannelMonitor this_arg_conv;
18996         this_arg_conv.inner = (void*)(this_arg & (~1));
18997         this_arg_conv.is_owned = false;
18998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18999         unsigned char header_arr[80];
19000         CHECK(*((uint32_t*)header) == 80);
19001         memcpy(header_arr, (uint8_t*)(header + 4), 80);
19002         unsigned char (*header_ref)[80] = &header_arr;
19003         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
19004         txdata_constr.datalen = *((uint32_t*)txdata);
19005         if (txdata_constr.datalen > 0)
19006                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
19007         else
19008                 txdata_constr.data = NULL;
19009         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
19010         for (size_t c = 0; c < txdata_constr.datalen; c++) {
19011                 uint32_t txdata_conv_28 = txdata_vals[c];
19012                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
19013                 CHECK_ACCESS(txdata_conv_28_ptr);
19014                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
19015                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
19016                 txdata_constr.data[c] = txdata_conv_28_conv;
19017         }
19018         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19019         CHECK_ACCESS(broadcaster_ptr);
19020         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19021         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19022         CHECK_ACCESS(fee_estimator_ptr);
19023         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19024         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19025         CHECK_ACCESS(logger_ptr);
19026         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19027         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);
19028         uint32_tArray ret_arr = NULL;
19029         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19030         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19031         for (size_t n = 0; n < ret_var.datalen; n++) {
19032                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19033                 *ret_conv_39_conv = ret_var.data[n];
19034                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
19035         }
19036         
19037         FREE(ret_var.data);
19038         return ret_arr;
19039 }
19040
19041 void  __attribute__((visibility("default"))) TS_ChannelMonitor_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
19042         LDKChannelMonitor this_arg_conv;
19043         this_arg_conv.inner = (void*)(this_arg & (~1));
19044         this_arg_conv.is_owned = false;
19045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19046         unsigned char txid_arr[32];
19047         CHECK(*((uint32_t*)txid) == 32);
19048         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
19049         unsigned char (*txid_ref)[32] = &txid_arr;
19050         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19051         CHECK_ACCESS(broadcaster_ptr);
19052         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19053         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19054         CHECK_ACCESS(fee_estimator_ptr);
19055         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19056         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19057         CHECK_ACCESS(logger_ptr);
19058         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19059         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
19060 }
19061
19062 uint32_tArray  __attribute__((visibility("default"))) 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) {
19063         LDKChannelMonitor this_arg_conv;
19064         this_arg_conv.inner = (void*)(this_arg & (~1));
19065         this_arg_conv.is_owned = false;
19066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19067         unsigned char header_arr[80];
19068         CHECK(*((uint32_t*)header) == 80);
19069         memcpy(header_arr, (uint8_t*)(header + 4), 80);
19070         unsigned char (*header_ref)[80] = &header_arr;
19071         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19072         CHECK_ACCESS(broadcaster_ptr);
19073         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19074         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19075         CHECK_ACCESS(fee_estimator_ptr);
19076         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19077         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19078         CHECK_ACCESS(logger_ptr);
19079         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19080         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
19081         uint32_tArray ret_arr = NULL;
19082         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19083         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19084         for (size_t n = 0; n < ret_var.datalen; n++) {
19085                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19086                 *ret_conv_39_conv = ret_var.data[n];
19087                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
19088         }
19089         
19090         FREE(ret_var.data);
19091         return ret_arr;
19092 }
19093
19094 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
19095         LDKChannelMonitor this_arg_conv;
19096         this_arg_conv.inner = (void*)(this_arg & (~1));
19097         this_arg_conv.is_owned = false;
19098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19099         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
19100         ptrArray ret_arr = NULL;
19101         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
19102         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
19103         for (size_t m = 0; m < ret_var.datalen; m++) {
19104                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19105                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
19106                 ret_arr_ptr[m] = ret_conv_12_arr;
19107         }
19108         
19109         FREE(ret_var.data);
19110         return ret_arr;
19111 }
19112
19113 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
19114         LDKChannelMonitor this_arg_conv;
19115         this_arg_conv.inner = (void*)(this_arg & (~1));
19116         this_arg_conv.is_owned = false;
19117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19118         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
19119         uint64_t ret_ref = 0;
19120         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19121         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19123         ret_ref = (uint64_t)ret_var.inner;
19124         if (ret_var.is_owned) {
19125                 ret_ref |= 1;
19126         }
19127         return ret_ref;
19128 }
19129
19130 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
19131         LDKChannelMonitor this_arg_conv;
19132         this_arg_conv.inner = (void*)(this_arg & (~1));
19133         this_arg_conv.is_owned = false;
19134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19135         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
19136         uint32_tArray ret_arr = NULL;
19137         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19138         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19139         for (size_t j = 0; j < ret_var.datalen; j++) {
19140                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19141                 *ret_conv_9_copy = ret_var.data[j];
19142                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
19143                 ret_arr_ptr[j] = ret_conv_9_ref;
19144         }
19145         
19146         FREE(ret_var.data);
19147         return ret_arr;
19148 }
19149
19150 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
19151         LDKu8slice ser_ref;
19152         ser_ref.datalen = *((uint32_t*)ser);
19153         ser_ref.data = (int8_t*)(ser + 4);
19154         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
19155         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
19156         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
19157         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19158         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
19159         return (uint64_t)ret_conv;
19160 }
19161
19162 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_obj) {
19163         LDKOutPoint this_obj_conv;
19164         this_obj_conv.inner = (void*)(this_obj & (~1));
19165         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19167         OutPoint_free(this_obj_conv);
19168 }
19169
19170 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
19171         LDKOutPoint this_ptr_conv;
19172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19173         this_ptr_conv.is_owned = false;
19174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19175         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19176         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
19177         return ret_arr;
19178 }
19179
19180 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
19181         LDKOutPoint this_ptr_conv;
19182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19183         this_ptr_conv.is_owned = false;
19184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19185         LDKThirtyTwoBytes val_ref;
19186         CHECK(*((uint32_t*)val) == 32);
19187         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19188         OutPoint_set_txid(&this_ptr_conv, val_ref);
19189 }
19190
19191 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
19192         LDKOutPoint this_ptr_conv;
19193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19194         this_ptr_conv.is_owned = false;
19195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19196         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
19197         return ret_val;
19198 }
19199
19200 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
19201         LDKOutPoint this_ptr_conv;
19202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19203         this_ptr_conv.is_owned = false;
19204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19205         OutPoint_set_index(&this_ptr_conv, val);
19206 }
19207
19208 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
19209         LDKThirtyTwoBytes txid_arg_ref;
19210         CHECK(*((uint32_t*)txid_arg) == 32);
19211         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
19212         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
19213         uint64_t ret_ref = 0;
19214         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19215         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19217         ret_ref = (uint64_t)ret_var.inner;
19218         if (ret_var.is_owned) {
19219                 ret_ref |= 1;
19220         }
19221         return ret_ref;
19222 }
19223
19224 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
19225         LDKOutPoint ret_var = OutPoint_clone(arg);
19226 uint64_t ret_ref = 0;
19227 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19228 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19229 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19230 ret_ref = (uint64_t)ret_var.inner;
19231 if (ret_var.is_owned) {
19232         ret_ref |= 1;
19233 }
19234         return ret_ref;
19235 }
19236 int64_t  __attribute__((visibility("default"))) TS_OutPoint_clone_ptr(uint32_t arg) {
19237         LDKOutPoint arg_conv;
19238         arg_conv.inner = (void*)(arg & (~1));
19239         arg_conv.is_owned = false;
19240         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19241         int64_t ret_val = OutPoint_clone_ptr(&arg_conv);
19242         return ret_val;
19243 }
19244
19245 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
19246         LDKOutPoint orig_conv;
19247         orig_conv.inner = (void*)(orig & (~1));
19248         orig_conv.is_owned = false;
19249         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19250         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
19251         uint64_t ret_ref = 0;
19252         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19253         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19255         ret_ref = (uint64_t)ret_var.inner;
19256         if (ret_var.is_owned) {
19257                 ret_ref |= 1;
19258         }
19259         return ret_ref;
19260 }
19261
19262 jboolean  __attribute__((visibility("default"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
19263         LDKOutPoint a_conv;
19264         a_conv.inner = (void*)(a & (~1));
19265         a_conv.is_owned = false;
19266         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19267         LDKOutPoint b_conv;
19268         b_conv.inner = (void*)(b & (~1));
19269         b_conv.is_owned = false;
19270         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19271         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
19272         return ret_val;
19273 }
19274
19275 int64_t  __attribute__((visibility("default"))) TS_OutPoint_hash(uint32_t o) {
19276         LDKOutPoint o_conv;
19277         o_conv.inner = (void*)(o & (~1));
19278         o_conv.is_owned = false;
19279         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19280         int64_t ret_val = OutPoint_hash(&o_conv);
19281         return ret_val;
19282 }
19283
19284 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
19285         LDKOutPoint this_arg_conv;
19286         this_arg_conv.inner = (void*)(this_arg & (~1));
19287         this_arg_conv.is_owned = false;
19288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19289         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19290         memcpy((uint8_t*)(ret_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
19291         return ret_arr;
19292 }
19293
19294 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
19295         LDKOutPoint obj_conv;
19296         obj_conv.inner = (void*)(obj & (~1));
19297         obj_conv.is_owned = false;
19298         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19299         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
19300         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19301         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19302         CVec_u8Z_free(ret_var);
19303         return ret_arr;
19304 }
19305
19306 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
19307         LDKu8slice ser_ref;
19308         ser_ref.datalen = *((uint32_t*)ser);
19309         ser_ref.data = (int8_t*)(ser + 4);
19310         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
19311         *ret_conv = OutPoint_read(ser_ref);
19312         return (uint64_t)ret_conv;
19313 }
19314
19315 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
19316         LDKDelayedPaymentOutputDescriptor this_obj_conv;
19317         this_obj_conv.inner = (void*)(this_obj & (~1));
19318         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19320         DelayedPaymentOutputDescriptor_free(this_obj_conv);
19321 }
19322
19323 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
19324         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19326         this_ptr_conv.is_owned = false;
19327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19328         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
19329         uint64_t ret_ref = 0;
19330         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19331         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19333         ret_ref = (uint64_t)ret_var.inner;
19334         if (ret_var.is_owned) {
19335                 ret_ref |= 1;
19336         }
19337         return ret_ref;
19338 }
19339
19340 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
19341         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19343         this_ptr_conv.is_owned = false;
19344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19345         LDKOutPoint val_conv;
19346         val_conv.inner = (void*)(val & (~1));
19347         val_conv.is_owned = (val & 1) || (val == 0);
19348         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
19349         val_conv = OutPoint_clone(&val_conv);
19350         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
19351 }
19352
19353 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
19354         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19356         this_ptr_conv.is_owned = false;
19357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19358         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19359         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
19360         return ret_arr;
19361 }
19362
19363 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
19364         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19366         this_ptr_conv.is_owned = false;
19367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19368         LDKPublicKey val_ref;
19369         CHECK(*((uint32_t*)val) == 33);
19370         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19371         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
19372 }
19373
19374 int16_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
19375         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19377         this_ptr_conv.is_owned = false;
19378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19379         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
19380         return ret_val;
19381 }
19382
19383 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
19384         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19386         this_ptr_conv.is_owned = false;
19387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19388         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
19389 }
19390
19391 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
19392         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19394         this_ptr_conv.is_owned = false;
19395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19396         void* val_ptr = (void*)(((uint64_t)val) & ~1);
19397         CHECK_ACCESS(val_ptr);
19398         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
19399         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
19400         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
19401 }
19402
19403 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
19404         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19406         this_ptr_conv.is_owned = false;
19407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19408         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19409         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
19410         return ret_arr;
19411 }
19412
19413 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
19414         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19416         this_ptr_conv.is_owned = false;
19417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19418         LDKPublicKey val_ref;
19419         CHECK(*((uint32_t*)val) == 33);
19420         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19421         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
19422 }
19423
19424 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
19425         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19427         this_ptr_conv.is_owned = false;
19428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19429         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19430         memcpy((uint8_t*)(ret_arr + 4), *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
19431         return ret_arr;
19432 }
19433
19434 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
19435         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19437         this_ptr_conv.is_owned = false;
19438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19439         LDKThirtyTwoBytes val_ref;
19440         CHECK(*((uint32_t*)val) == 32);
19441         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19442         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
19443 }
19444
19445 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
19446         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19448         this_ptr_conv.is_owned = false;
19449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19450         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
19451         return ret_val;
19452 }
19453
19454 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
19455         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19457         this_ptr_conv.is_owned = false;
19458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19459         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
19460 }
19461
19462 uint32_t  __attribute__((visibility("default"))) 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) {
19463         LDKOutPoint outpoint_arg_conv;
19464         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
19465         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
19466         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
19467         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
19468         LDKPublicKey per_commitment_point_arg_ref;
19469         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
19470         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
19471         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
19472         CHECK_ACCESS(output_arg_ptr);
19473         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
19474         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
19475         LDKPublicKey revocation_pubkey_arg_ref;
19476         CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
19477         memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33);
19478         LDKThirtyTwoBytes channel_keys_id_arg_ref;
19479         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
19480         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
19481         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);
19482         uint64_t ret_ref = 0;
19483         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19484         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19486         ret_ref = (uint64_t)ret_var.inner;
19487         if (ret_var.is_owned) {
19488                 ret_ref |= 1;
19489         }
19490         return ret_ref;
19491 }
19492
19493 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
19494         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
19495 uint64_t ret_ref = 0;
19496 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19497 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19498 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19499 ret_ref = (uint64_t)ret_var.inner;
19500 if (ret_var.is_owned) {
19501         ret_ref |= 1;
19502 }
19503         return ret_ref;
19504 }
19505 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
19506         LDKDelayedPaymentOutputDescriptor arg_conv;
19507         arg_conv.inner = (void*)(arg & (~1));
19508         arg_conv.is_owned = false;
19509         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19510         int64_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
19511         return ret_val;
19512 }
19513
19514 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
19515         LDKDelayedPaymentOutputDescriptor orig_conv;
19516         orig_conv.inner = (void*)(orig & (~1));
19517         orig_conv.is_owned = false;
19518         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19519         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
19520         uint64_t ret_ref = 0;
19521         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19522         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19524         ret_ref = (uint64_t)ret_var.inner;
19525         if (ret_var.is_owned) {
19526                 ret_ref |= 1;
19527         }
19528         return ret_ref;
19529 }
19530
19531 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
19532         LDKDelayedPaymentOutputDescriptor obj_conv;
19533         obj_conv.inner = (void*)(obj & (~1));
19534         obj_conv.is_owned = false;
19535         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19536         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
19537         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19538         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19539         CVec_u8Z_free(ret_var);
19540         return ret_arr;
19541 }
19542
19543 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
19544         LDKu8slice ser_ref;
19545         ser_ref.datalen = *((uint32_t*)ser);
19546         ser_ref.data = (int8_t*)(ser + 4);
19547         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19548         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
19549         return (uint64_t)ret_conv;
19550 }
19551
19552 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
19553         LDKStaticPaymentOutputDescriptor this_obj_conv;
19554         this_obj_conv.inner = (void*)(this_obj & (~1));
19555         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19557         StaticPaymentOutputDescriptor_free(this_obj_conv);
19558 }
19559
19560 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
19561         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19563         this_ptr_conv.is_owned = false;
19564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19565         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
19566         uint64_t ret_ref = 0;
19567         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19568         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19570         ret_ref = (uint64_t)ret_var.inner;
19571         if (ret_var.is_owned) {
19572                 ret_ref |= 1;
19573         }
19574         return ret_ref;
19575 }
19576
19577 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
19578         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19580         this_ptr_conv.is_owned = false;
19581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19582         LDKOutPoint val_conv;
19583         val_conv.inner = (void*)(val & (~1));
19584         val_conv.is_owned = (val & 1) || (val == 0);
19585         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
19586         val_conv = OutPoint_clone(&val_conv);
19587         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
19588 }
19589
19590 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
19591         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19593         this_ptr_conv.is_owned = false;
19594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19595         void* val_ptr = (void*)(((uint64_t)val) & ~1);
19596         CHECK_ACCESS(val_ptr);
19597         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
19598         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
19599         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
19600 }
19601
19602 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
19603         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19605         this_ptr_conv.is_owned = false;
19606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19607         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19608         memcpy((uint8_t*)(ret_arr + 4), *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
19609         return ret_arr;
19610 }
19611
19612 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
19613         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19615         this_ptr_conv.is_owned = false;
19616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19617         LDKThirtyTwoBytes val_ref;
19618         CHECK(*((uint32_t*)val) == 32);
19619         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19620         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
19621 }
19622
19623 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
19624         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19626         this_ptr_conv.is_owned = false;
19627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19628         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
19629         return ret_val;
19630 }
19631
19632 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
19633         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19635         this_ptr_conv.is_owned = false;
19636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19637         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
19638 }
19639
19640 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_new(uint32_t outpoint_arg, uint32_t output_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg) {
19641         LDKOutPoint outpoint_arg_conv;
19642         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
19643         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
19644         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
19645         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
19646         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
19647         CHECK_ACCESS(output_arg_ptr);
19648         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
19649         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
19650         LDKThirtyTwoBytes channel_keys_id_arg_ref;
19651         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
19652         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
19653         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
19654         uint64_t ret_ref = 0;
19655         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19656         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19658         ret_ref = (uint64_t)ret_var.inner;
19659         if (ret_var.is_owned) {
19660                 ret_ref |= 1;
19661         }
19662         return ret_ref;
19663 }
19664
19665 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
19666         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
19667 uint64_t ret_ref = 0;
19668 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19669 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19670 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19671 ret_ref = (uint64_t)ret_var.inner;
19672 if (ret_var.is_owned) {
19673         ret_ref |= 1;
19674 }
19675         return ret_ref;
19676 }
19677 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
19678         LDKStaticPaymentOutputDescriptor arg_conv;
19679         arg_conv.inner = (void*)(arg & (~1));
19680         arg_conv.is_owned = false;
19681         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19682         int64_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
19683         return ret_val;
19684 }
19685
19686 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
19687         LDKStaticPaymentOutputDescriptor orig_conv;
19688         orig_conv.inner = (void*)(orig & (~1));
19689         orig_conv.is_owned = false;
19690         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19691         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
19692         uint64_t ret_ref = 0;
19693         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19694         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19696         ret_ref = (uint64_t)ret_var.inner;
19697         if (ret_var.is_owned) {
19698                 ret_ref |= 1;
19699         }
19700         return ret_ref;
19701 }
19702
19703 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
19704         LDKStaticPaymentOutputDescriptor obj_conv;
19705         obj_conv.inner = (void*)(obj & (~1));
19706         obj_conv.is_owned = false;
19707         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19708         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
19709         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19710         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19711         CVec_u8Z_free(ret_var);
19712         return ret_arr;
19713 }
19714
19715 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
19716         LDKu8slice ser_ref;
19717         ser_ref.datalen = *((uint32_t*)ser);
19718         ser_ref.data = (int8_t*)(ser + 4);
19719         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19720         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
19721         return (uint64_t)ret_conv;
19722 }
19723
19724 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
19725         if ((this_ptr & 1) != 0) return;
19726         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19727         CHECK_ACCESS(this_ptr_ptr);
19728         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
19729         FREE((void*)this_ptr);
19730         SpendableOutputDescriptor_free(this_ptr_conv);
19731 }
19732
19733 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
19734         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
19735         *ret_copy = SpendableOutputDescriptor_clone(arg);
19736 uint64_t ret_ref = (uint64_t)ret_copy;
19737         return ret_ref;
19738 }
19739 int64_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
19740         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
19741         int64_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
19742         return ret_val;
19743 }
19744
19745 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
19746         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
19747         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
19748         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
19749         uint64_t ret_ref = (uint64_t)ret_copy;
19750         return ret_ref;
19751 }
19752
19753 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
19754         LDKOutPoint outpoint_conv;
19755         outpoint_conv.inner = (void*)(outpoint & (~1));
19756         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
19757         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
19758         outpoint_conv = OutPoint_clone(&outpoint_conv);
19759         void* output_ptr = (void*)(((uint64_t)output) & ~1);
19760         CHECK_ACCESS(output_ptr);
19761         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
19762         output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1));
19763         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
19764         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
19765         uint64_t ret_ref = (uint64_t)ret_copy;
19766         return ret_ref;
19767 }
19768
19769 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
19770         LDKDelayedPaymentOutputDescriptor a_conv;
19771         a_conv.inner = (void*)(a & (~1));
19772         a_conv.is_owned = (a & 1) || (a == 0);
19773         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19774         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
19775         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
19776         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
19777         uint64_t ret_ref = (uint64_t)ret_copy;
19778         return ret_ref;
19779 }
19780
19781 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
19782         LDKStaticPaymentOutputDescriptor a_conv;
19783         a_conv.inner = (void*)(a & (~1));
19784         a_conv.is_owned = (a & 1) || (a == 0);
19785         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19786         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
19787         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
19788         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
19789         uint64_t ret_ref = (uint64_t)ret_copy;
19790         return ret_ref;
19791 }
19792
19793 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
19794         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
19795         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
19796         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19797         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19798         CVec_u8Z_free(ret_var);
19799         return ret_arr;
19800 }
19801
19802 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
19803         LDKu8slice ser_ref;
19804         ser_ref.datalen = *((uint32_t*)ser);
19805         ser_ref.data = (int8_t*)(ser + 4);
19806         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19807         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
19808         return (uint64_t)ret_conv;
19809 }
19810
19811 void  __attribute__((visibility("default"))) TS_BaseSign_free(uint32_t this_ptr) {
19812         if ((this_ptr & 1) != 0) return;
19813         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19814         CHECK_ACCESS(this_ptr_ptr);
19815         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
19816         FREE((void*)this_ptr);
19817         BaseSign_free(this_ptr_conv);
19818 }
19819
19820 static inline uint64_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
19821         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
19822         *ret_ret = Sign_clone(arg);
19823         return (uint64_t)ret_ret;
19824 }
19825 int64_t  __attribute__((visibility("default"))) TS_Sign_clone_ptr(uint32_t arg) {
19826         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
19827         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
19828         LDKSign* arg_conv = (LDKSign*)arg_ptr;
19829         int64_t ret_val = Sign_clone_ptr(arg_conv);
19830         return ret_val;
19831 }
19832
19833 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
19834         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
19835         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
19836         LDKSign* orig_conv = (LDKSign*)orig_ptr;
19837         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
19838         *ret_ret = Sign_clone(orig_conv);
19839         return (uint64_t)ret_ret;
19840 }
19841
19842 void  __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) {
19843         if ((this_ptr & 1) != 0) return;
19844         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19845         CHECK_ACCESS(this_ptr_ptr);
19846         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
19847         FREE((void*)this_ptr);
19848         Sign_free(this_ptr_conv);
19849 }
19850
19851 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
19852         if ((this_ptr & 1) != 0) return;
19853         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19854         CHECK_ACCESS(this_ptr_ptr);
19855         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
19856         FREE((void*)this_ptr);
19857         KeysInterface_free(this_ptr_conv);
19858 }
19859
19860 void  __attribute__((visibility("default"))) TS_InMemorySigner_free(uint32_t this_obj) {
19861         LDKInMemorySigner this_obj_conv;
19862         this_obj_conv.inner = (void*)(this_obj & (~1));
19863         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19865         InMemorySigner_free(this_obj_conv);
19866 }
19867
19868 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
19869         LDKInMemorySigner this_ptr_conv;
19870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19871         this_ptr_conv.is_owned = false;
19872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19873         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19874         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
19875         return ret_arr;
19876 }
19877
19878 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
19879         LDKInMemorySigner this_ptr_conv;
19880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19881         this_ptr_conv.is_owned = false;
19882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19883         LDKSecretKey val_ref;
19884         CHECK(*((uint32_t*)val) == 32);
19885         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
19886         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
19887 }
19888
19889 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
19890         LDKInMemorySigner this_ptr_conv;
19891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19892         this_ptr_conv.is_owned = false;
19893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19894         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19895         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
19896         return ret_arr;
19897 }
19898
19899 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
19900         LDKInMemorySigner this_ptr_conv;
19901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19902         this_ptr_conv.is_owned = false;
19903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19904         LDKSecretKey val_ref;
19905         CHECK(*((uint32_t*)val) == 32);
19906         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
19907         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
19908 }
19909
19910 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
19911         LDKInMemorySigner this_ptr_conv;
19912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19913         this_ptr_conv.is_owned = false;
19914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19915         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19916         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
19917         return ret_arr;
19918 }
19919
19920 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
19921         LDKInMemorySigner this_ptr_conv;
19922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19923         this_ptr_conv.is_owned = false;
19924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19925         LDKSecretKey val_ref;
19926         CHECK(*((uint32_t*)val) == 32);
19927         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
19928         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
19929 }
19930
19931 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
19932         LDKInMemorySigner this_ptr_conv;
19933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19934         this_ptr_conv.is_owned = false;
19935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19936         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19937         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
19938         return ret_arr;
19939 }
19940
19941 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
19942         LDKInMemorySigner this_ptr_conv;
19943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19944         this_ptr_conv.is_owned = false;
19945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19946         LDKSecretKey val_ref;
19947         CHECK(*((uint32_t*)val) == 32);
19948         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
19949         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
19950 }
19951
19952 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
19953         LDKInMemorySigner this_ptr_conv;
19954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19955         this_ptr_conv.is_owned = false;
19956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19957         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19958         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
19959         return ret_arr;
19960 }
19961
19962 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
19963         LDKInMemorySigner this_ptr_conv;
19964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19965         this_ptr_conv.is_owned = false;
19966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19967         LDKSecretKey val_ref;
19968         CHECK(*((uint32_t*)val) == 32);
19969         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
19970         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
19971 }
19972
19973 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
19974         LDKInMemorySigner this_ptr_conv;
19975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19976         this_ptr_conv.is_owned = false;
19977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19978         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19979         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
19980         return ret_arr;
19981 }
19982
19983 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
19984         LDKInMemorySigner this_ptr_conv;
19985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19986         this_ptr_conv.is_owned = false;
19987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19988         LDKThirtyTwoBytes val_ref;
19989         CHECK(*((uint32_t*)val) == 32);
19990         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19991         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
19992 }
19993
19994 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
19995         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
19996 uint64_t ret_ref = 0;
19997 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19998 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19999 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20000 ret_ref = (uint64_t)ret_var.inner;
20001 if (ret_var.is_owned) {
20002         ret_ref |= 1;
20003 }
20004         return ret_ref;
20005 }
20006 int64_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
20007         LDKInMemorySigner arg_conv;
20008         arg_conv.inner = (void*)(arg & (~1));
20009         arg_conv.is_owned = false;
20010         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20011         int64_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
20012         return ret_val;
20013 }
20014
20015 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_t orig) {
20016         LDKInMemorySigner orig_conv;
20017         orig_conv.inner = (void*)(orig & (~1));
20018         orig_conv.is_owned = false;
20019         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20020         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
20021         uint64_t ret_ref = 0;
20022         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20023         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20024         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20025         ret_ref = (uint64_t)ret_var.inner;
20026         if (ret_var.is_owned) {
20027                 ret_ref |= 1;
20028         }
20029         return ret_ref;
20030 }
20031
20032 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_new(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) {
20033         LDKSecretKey funding_key_ref;
20034         CHECK(*((uint32_t*)funding_key) == 32);
20035         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
20036         LDKSecretKey revocation_base_key_ref;
20037         CHECK(*((uint32_t*)revocation_base_key) == 32);
20038         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
20039         LDKSecretKey payment_key_ref;
20040         CHECK(*((uint32_t*)payment_key) == 32);
20041         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
20042         LDKSecretKey delayed_payment_base_key_ref;
20043         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
20044         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
20045         LDKSecretKey htlc_base_key_ref;
20046         CHECK(*((uint32_t*)htlc_base_key) == 32);
20047         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
20048         LDKThirtyTwoBytes commitment_seed_ref;
20049         CHECK(*((uint32_t*)commitment_seed) == 32);
20050         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
20051         LDKThirtyTwoBytes channel_keys_id_ref;
20052         CHECK(*((uint32_t*)channel_keys_id) == 32);
20053         memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
20054         LDKInMemorySigner ret_var = InMemorySigner_new(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);
20055         uint64_t ret_ref = 0;
20056         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20057         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20059         ret_ref = (uint64_t)ret_var.inner;
20060         if (ret_var.is_owned) {
20061                 ret_ref |= 1;
20062         }
20063         return ret_ref;
20064 }
20065
20066 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
20067         LDKInMemorySigner this_arg_conv;
20068         this_arg_conv.inner = (void*)(this_arg & (~1));
20069         this_arg_conv.is_owned = false;
20070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20071         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
20072         uint64_t ret_ref = 0;
20073         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20074         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20076         ret_ref = (uint64_t)ret_var.inner;
20077         if (ret_var.is_owned) {
20078                 ret_ref |= 1;
20079         }
20080         return ret_ref;
20081 }
20082
20083 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
20084         LDKInMemorySigner this_arg_conv;
20085         this_arg_conv.inner = (void*)(this_arg & (~1));
20086         this_arg_conv.is_owned = false;
20087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20088         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
20089         return ret_val;
20090 }
20091
20092 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
20093         LDKInMemorySigner this_arg_conv;
20094         this_arg_conv.inner = (void*)(this_arg & (~1));
20095         this_arg_conv.is_owned = false;
20096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20097         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
20098         return ret_val;
20099 }
20100
20101 jboolean  __attribute__((visibility("default"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
20102         LDKInMemorySigner this_arg_conv;
20103         this_arg_conv.inner = (void*)(this_arg & (~1));
20104         this_arg_conv.is_owned = false;
20105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20106         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
20107         return ret_val;
20108 }
20109
20110 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
20111         LDKInMemorySigner this_arg_conv;
20112         this_arg_conv.inner = (void*)(this_arg & (~1));
20113         this_arg_conv.is_owned = false;
20114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20115         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
20116         uint64_t ret_ref = 0;
20117         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20118         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20120         ret_ref = (uint64_t)ret_var.inner;
20121         if (ret_var.is_owned) {
20122                 ret_ref |= 1;
20123         }
20124         return ret_ref;
20125 }
20126
20127 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
20128         LDKInMemorySigner this_arg_conv;
20129         this_arg_conv.inner = (void*)(this_arg & (~1));
20130         this_arg_conv.is_owned = false;
20131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20132         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
20133         uint64_t ret_ref = 0;
20134         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20135         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20137         ret_ref = (uint64_t)ret_var.inner;
20138         if (ret_var.is_owned) {
20139                 ret_ref |= 1;
20140         }
20141         return ret_ref;
20142 }
20143
20144 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_sign_counterparty_payment_input(uint32_t this_arg, int8_tArray spend_tx, int64_t input_idx, uint32_t descriptor) {
20145         LDKInMemorySigner this_arg_conv;
20146         this_arg_conv.inner = (void*)(this_arg & (~1));
20147         this_arg_conv.is_owned = false;
20148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20149         LDKTransaction spend_tx_ref;
20150         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
20151         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
20152         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
20153         spend_tx_ref.data_is_owned = true;
20154         LDKStaticPaymentOutputDescriptor descriptor_conv;
20155         descriptor_conv.inner = (void*)(descriptor & (~1));
20156         descriptor_conv.is_owned = false;
20157         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
20158         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20159         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
20160         return (uint64_t)ret_conv;
20161 }
20162
20163 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_sign_dynamic_p2wsh_input(uint32_t this_arg, int8_tArray spend_tx, int64_t input_idx, uint32_t descriptor) {
20164         LDKInMemorySigner this_arg_conv;
20165         this_arg_conv.inner = (void*)(this_arg & (~1));
20166         this_arg_conv.is_owned = false;
20167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20168         LDKTransaction spend_tx_ref;
20169         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
20170         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
20171         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
20172         spend_tx_ref.data_is_owned = true;
20173         LDKDelayedPaymentOutputDescriptor descriptor_conv;
20174         descriptor_conv.inner = (void*)(descriptor & (~1));
20175         descriptor_conv.is_owned = false;
20176         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
20177         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20178         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
20179         return (uint64_t)ret_conv;
20180 }
20181
20182 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
20183         LDKInMemorySigner this_arg_conv;
20184         this_arg_conv.inner = (void*)(this_arg & (~1));
20185         this_arg_conv.is_owned = false;
20186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20187         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
20188         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
20189         return (uint64_t)ret_ret;
20190 }
20191
20192 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
20193         LDKInMemorySigner this_arg_conv;
20194         this_arg_conv.inner = (void*)(this_arg & (~1));
20195         this_arg_conv.is_owned = false;
20196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20197         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
20198         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
20199         return (uint64_t)ret_ret;
20200 }
20201
20202 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) {
20203         LDKInMemorySigner obj_conv;
20204         obj_conv.inner = (void*)(obj & (~1));
20205         obj_conv.is_owned = false;
20206         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
20207         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
20208         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20209         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20210         CVec_u8Z_free(ret_var);
20211         return ret_arr;
20212 }
20213
20214 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_read(int8_tArray ser) {
20215         LDKu8slice ser_ref;
20216         ser_ref.datalen = *((uint32_t*)ser);
20217         ser_ref.data = (int8_t*)(ser + 4);
20218         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20219         *ret_conv = InMemorySigner_read(ser_ref);
20220         return (uint64_t)ret_conv;
20221 }
20222
20223 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_obj) {
20224         LDKKeysManager this_obj_conv;
20225         this_obj_conv.inner = (void*)(this_obj & (~1));
20226         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20228         KeysManager_free(this_obj_conv);
20229 }
20230
20231 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
20232         unsigned char seed_arr[32];
20233         CHECK(*((uint32_t*)seed) == 32);
20234         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
20235         unsigned char (*seed_ref)[32] = &seed_arr;
20236         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
20237         uint64_t ret_ref = 0;
20238         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20239         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20241         ret_ref = (uint64_t)ret_var.inner;
20242         if (ret_var.is_owned) {
20243                 ret_ref |= 1;
20244         }
20245         return ret_ref;
20246 }
20247
20248 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
20249         LDKKeysManager this_arg_conv;
20250         this_arg_conv.inner = (void*)(this_arg & (~1));
20251         this_arg_conv.is_owned = false;
20252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20253         unsigned char params_arr[32];
20254         CHECK(*((uint32_t*)params) == 32);
20255         memcpy(params_arr, (uint8_t*)(params + 4), 32);
20256         unsigned char (*params_ref)[32] = &params_arr;
20257         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
20258         uint64_t ret_ref = 0;
20259         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20260         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20262         ret_ref = (uint64_t)ret_var.inner;
20263         if (ret_var.is_owned) {
20264                 ret_ref |= 1;
20265         }
20266         return ret_ref;
20267 }
20268
20269 uint32_t  __attribute__((visibility("default"))) 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) {
20270         LDKKeysManager this_arg_conv;
20271         this_arg_conv.inner = (void*)(this_arg & (~1));
20272         this_arg_conv.is_owned = false;
20273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20274         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
20275         descriptors_constr.datalen = *((uint32_t*)descriptors);
20276         if (descriptors_constr.datalen > 0)
20277                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
20278         else
20279                 descriptors_constr.data = NULL;
20280         uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
20281         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
20282                 uint32_t descriptors_conv_27 = descriptors_vals[b];
20283                 void* descriptors_conv_27_ptr = (void*)(((uint64_t)descriptors_conv_27) & ~1);
20284                 CHECK_ACCESS(descriptors_conv_27_ptr);
20285                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
20286                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
20287                 descriptors_constr.data[b] = descriptors_conv_27_conv;
20288         }
20289         LDKCVec_TxOutZ outputs_constr;
20290         outputs_constr.datalen = *((uint32_t*)outputs);
20291         if (outputs_constr.datalen > 0)
20292                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
20293         else
20294                 outputs_constr.data = NULL;
20295         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
20296         for (size_t h = 0; h < outputs_constr.datalen; h++) {
20297                 uint32_t outputs_conv_7 = outputs_vals[h];
20298                 void* outputs_conv_7_ptr = (void*)(((uint64_t)outputs_conv_7) & ~1);
20299                 CHECK_ACCESS(outputs_conv_7_ptr);
20300                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
20301                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
20302                 outputs_constr.data[h] = outputs_conv_7_conv;
20303         }
20304         LDKCVec_u8Z change_destination_script_ref;
20305         change_destination_script_ref.datalen = *((uint32_t*)change_destination_script);
20306         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
20307         memcpy(change_destination_script_ref.data, (uint8_t*)(change_destination_script + 4), change_destination_script_ref.datalen);
20308         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20309         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
20310         return (uint64_t)ret_conv;
20311 }
20312
20313 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
20314         LDKKeysManager this_arg_conv;
20315         this_arg_conv.inner = (void*)(this_arg & (~1));
20316         this_arg_conv.is_owned = false;
20317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20318         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
20319         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
20320         return (uint64_t)ret_ret;
20321 }
20322
20323 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
20324         LDKChannelManager this_obj_conv;
20325         this_obj_conv.inner = (void*)(this_obj & (~1));
20326         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20328         ChannelManager_free(this_obj_conv);
20329 }
20330
20331 void  __attribute__((visibility("default"))) TS_ChainParameters_free(uint32_t this_obj) {
20332         LDKChainParameters this_obj_conv;
20333         this_obj_conv.inner = (void*)(this_obj & (~1));
20334         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20336         ChainParameters_free(this_obj_conv);
20337 }
20338
20339 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
20340         LDKChainParameters this_ptr_conv;
20341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20342         this_ptr_conv.is_owned = false;
20343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20344         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
20345         return ret_conv;
20346 }
20347
20348 void  __attribute__((visibility("default"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
20349         LDKChainParameters this_ptr_conv;
20350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20351         this_ptr_conv.is_owned = false;
20352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20353         LDKNetwork val_conv = LDKNetwork_from_js(val);
20354         ChainParameters_set_network(&this_ptr_conv, val_conv);
20355 }
20356
20357 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
20358         LDKChainParameters this_ptr_conv;
20359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20360         this_ptr_conv.is_owned = false;
20361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20362         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
20363         uint64_t ret_ref = 0;
20364         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20365         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20367         ret_ref = (uint64_t)ret_var.inner;
20368         if (ret_var.is_owned) {
20369                 ret_ref |= 1;
20370         }
20371         return ret_ref;
20372 }
20373
20374 void  __attribute__((visibility("default"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
20375         LDKChainParameters this_ptr_conv;
20376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20377         this_ptr_conv.is_owned = false;
20378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20379         LDKBestBlock val_conv;
20380         val_conv.inner = (void*)(val & (~1));
20381         val_conv.is_owned = (val & 1) || (val == 0);
20382         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20383         val_conv = BestBlock_clone(&val_conv);
20384         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
20385 }
20386
20387 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
20388         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
20389         LDKBestBlock best_block_arg_conv;
20390         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
20391         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
20392         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
20393         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
20394         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
20395         uint64_t ret_ref = 0;
20396         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20397         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20398         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20399         ret_ref = (uint64_t)ret_var.inner;
20400         if (ret_var.is_owned) {
20401                 ret_ref |= 1;
20402         }
20403         return ret_ref;
20404 }
20405
20406 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
20407         LDKChainParameters ret_var = ChainParameters_clone(arg);
20408 uint64_t ret_ref = 0;
20409 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20410 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20411 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20412 ret_ref = (uint64_t)ret_var.inner;
20413 if (ret_var.is_owned) {
20414         ret_ref |= 1;
20415 }
20416         return ret_ref;
20417 }
20418 int64_t  __attribute__((visibility("default"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
20419         LDKChainParameters arg_conv;
20420         arg_conv.inner = (void*)(arg & (~1));
20421         arg_conv.is_owned = false;
20422         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20423         int64_t ret_val = ChainParameters_clone_ptr(&arg_conv);
20424         return ret_val;
20425 }
20426
20427 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32_t orig) {
20428         LDKChainParameters orig_conv;
20429         orig_conv.inner = (void*)(orig & (~1));
20430         orig_conv.is_owned = false;
20431         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20432         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
20433         uint64_t ret_ref = 0;
20434         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20435         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20437         ret_ref = (uint64_t)ret_var.inner;
20438         if (ret_var.is_owned) {
20439                 ret_ref |= 1;
20440         }
20441         return ret_ref;
20442 }
20443
20444 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
20445         LDKCounterpartyForwardingInfo this_obj_conv;
20446         this_obj_conv.inner = (void*)(this_obj & (~1));
20447         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20449         CounterpartyForwardingInfo_free(this_obj_conv);
20450 }
20451
20452 int32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
20453         LDKCounterpartyForwardingInfo this_ptr_conv;
20454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20455         this_ptr_conv.is_owned = false;
20456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20457         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
20458         return ret_val;
20459 }
20460
20461 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
20462         LDKCounterpartyForwardingInfo this_ptr_conv;
20463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20464         this_ptr_conv.is_owned = false;
20465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20466         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
20467 }
20468
20469 int32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
20470         LDKCounterpartyForwardingInfo this_ptr_conv;
20471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20472         this_ptr_conv.is_owned = false;
20473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20474         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
20475         return ret_val;
20476 }
20477
20478 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
20479         LDKCounterpartyForwardingInfo this_ptr_conv;
20480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20481         this_ptr_conv.is_owned = false;
20482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20483         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
20484 }
20485
20486 int16_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
20487         LDKCounterpartyForwardingInfo this_ptr_conv;
20488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20489         this_ptr_conv.is_owned = false;
20490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20491         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
20492         return ret_val;
20493 }
20494
20495 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20496         LDKCounterpartyForwardingInfo this_ptr_conv;
20497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20498         this_ptr_conv.is_owned = false;
20499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20500         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
20501 }
20502
20503 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_new(int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg) {
20504         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
20505         uint64_t ret_ref = 0;
20506         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20507         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20509         ret_ref = (uint64_t)ret_var.inner;
20510         if (ret_var.is_owned) {
20511                 ret_ref |= 1;
20512         }
20513         return ret_ref;
20514 }
20515
20516 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
20517         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
20518 uint64_t ret_ref = 0;
20519 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20520 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20521 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20522 ret_ref = (uint64_t)ret_var.inner;
20523 if (ret_var.is_owned) {
20524         ret_ref |= 1;
20525 }
20526         return ret_ref;
20527 }
20528 int64_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
20529         LDKCounterpartyForwardingInfo arg_conv;
20530         arg_conv.inner = (void*)(arg & (~1));
20531         arg_conv.is_owned = false;
20532         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20533         int64_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
20534         return ret_val;
20535 }
20536
20537 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
20538         LDKCounterpartyForwardingInfo orig_conv;
20539         orig_conv.inner = (void*)(orig & (~1));
20540         orig_conv.is_owned = false;
20541         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20542         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
20543         uint64_t ret_ref = 0;
20544         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20545         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20547         ret_ref = (uint64_t)ret_var.inner;
20548         if (ret_var.is_owned) {
20549                 ret_ref |= 1;
20550         }
20551         return ret_ref;
20552 }
20553
20554 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
20555         LDKChannelCounterparty this_obj_conv;
20556         this_obj_conv.inner = (void*)(this_obj & (~1));
20557         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20559         ChannelCounterparty_free(this_obj_conv);
20560 }
20561
20562 int8_tArray  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
20563         LDKChannelCounterparty this_ptr_conv;
20564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20565         this_ptr_conv.is_owned = false;
20566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20567         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
20568         memcpy((uint8_t*)(ret_arr + 4), ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
20569         return ret_arr;
20570 }
20571
20572 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
20573         LDKChannelCounterparty this_ptr_conv;
20574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20575         this_ptr_conv.is_owned = false;
20576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20577         LDKPublicKey val_ref;
20578         CHECK(*((uint32_t*)val) == 33);
20579         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
20580         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
20581 }
20582
20583 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
20584         LDKChannelCounterparty this_ptr_conv;
20585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20586         this_ptr_conv.is_owned = false;
20587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20588         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
20589         uint64_t ret_ref = 0;
20590         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20591         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20593         ret_ref = (uint64_t)ret_var.inner;
20594         if (ret_var.is_owned) {
20595                 ret_ref |= 1;
20596         }
20597         return ret_ref;
20598 }
20599
20600 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
20601         LDKChannelCounterparty this_ptr_conv;
20602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20603         this_ptr_conv.is_owned = false;
20604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20605         LDKInitFeatures val_conv;
20606         val_conv.inner = (void*)(val & (~1));
20607         val_conv.is_owned = (val & 1) || (val == 0);
20608         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20609         val_conv = InitFeatures_clone(&val_conv);
20610         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
20611 }
20612
20613 int64_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
20614         LDKChannelCounterparty this_ptr_conv;
20615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20616         this_ptr_conv.is_owned = false;
20617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20618         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
20619         return ret_val;
20620 }
20621
20622 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
20623         LDKChannelCounterparty this_ptr_conv;
20624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20625         this_ptr_conv.is_owned = false;
20626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20627         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
20628 }
20629
20630 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
20631         LDKChannelCounterparty this_ptr_conv;
20632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20633         this_ptr_conv.is_owned = false;
20634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20635         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
20636         uint64_t ret_ref = 0;
20637         if ((uint64_t)ret_var.inner > 4096) {
20638                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20639                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20641                 ret_ref = (uint64_t)ret_var.inner;
20642                 if (ret_var.is_owned) {
20643                         ret_ref |= 1;
20644                 }
20645         }
20646         return ret_ref;
20647 }
20648
20649 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
20650         LDKChannelCounterparty this_ptr_conv;
20651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20652         this_ptr_conv.is_owned = false;
20653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20654         LDKCounterpartyForwardingInfo val_conv;
20655         val_conv.inner = (void*)(val & (~1));
20656         val_conv.is_owned = (val & 1) || (val == 0);
20657         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20658         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
20659         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
20660 }
20661
20662 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_new(int8_tArray node_id_arg, uint32_t features_arg, int64_t unspendable_punishment_reserve_arg, uint32_t forwarding_info_arg) {
20663         LDKPublicKey node_id_arg_ref;
20664         CHECK(*((uint32_t*)node_id_arg) == 33);
20665         memcpy(node_id_arg_ref.compressed_form, (uint8_t*)(node_id_arg + 4), 33);
20666         LDKInitFeatures features_arg_conv;
20667         features_arg_conv.inner = (void*)(features_arg & (~1));
20668         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
20669         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
20670         features_arg_conv = InitFeatures_clone(&features_arg_conv);
20671         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
20672         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
20673         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
20674         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
20675         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
20676         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
20677         uint64_t ret_ref = 0;
20678         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20679         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20681         ret_ref = (uint64_t)ret_var.inner;
20682         if (ret_var.is_owned) {
20683                 ret_ref |= 1;
20684         }
20685         return ret_ref;
20686 }
20687
20688 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
20689         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
20690 uint64_t ret_ref = 0;
20691 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20692 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20693 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20694 ret_ref = (uint64_t)ret_var.inner;
20695 if (ret_var.is_owned) {
20696         ret_ref |= 1;
20697 }
20698         return ret_ref;
20699 }
20700 int64_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
20701         LDKChannelCounterparty arg_conv;
20702         arg_conv.inner = (void*)(arg & (~1));
20703         arg_conv.is_owned = false;
20704         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20705         int64_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
20706         return ret_val;
20707 }
20708
20709 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_clone(uint32_t orig) {
20710         LDKChannelCounterparty orig_conv;
20711         orig_conv.inner = (void*)(orig & (~1));
20712         orig_conv.is_owned = false;
20713         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20714         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
20715         uint64_t ret_ref = 0;
20716         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20717         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20719         ret_ref = (uint64_t)ret_var.inner;
20720         if (ret_var.is_owned) {
20721                 ret_ref |= 1;
20722         }
20723         return ret_ref;
20724 }
20725
20726 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) {
20727         LDKChannelDetails this_obj_conv;
20728         this_obj_conv.inner = (void*)(this_obj & (~1));
20729         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20731         ChannelDetails_free(this_obj_conv);
20732 }
20733
20734 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
20735         LDKChannelDetails this_ptr_conv;
20736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20737         this_ptr_conv.is_owned = false;
20738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20739         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20740         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
20741         return ret_arr;
20742 }
20743
20744 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
20745         LDKChannelDetails this_ptr_conv;
20746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20747         this_ptr_conv.is_owned = false;
20748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20749         LDKThirtyTwoBytes val_ref;
20750         CHECK(*((uint32_t*)val) == 32);
20751         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20752         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
20753 }
20754
20755 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
20756         LDKChannelDetails this_ptr_conv;
20757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20758         this_ptr_conv.is_owned = false;
20759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20760         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
20761         uint64_t ret_ref = 0;
20762         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20763         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20765         ret_ref = (uint64_t)ret_var.inner;
20766         if (ret_var.is_owned) {
20767                 ret_ref |= 1;
20768         }
20769         return ret_ref;
20770 }
20771
20772 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
20773         LDKChannelDetails this_ptr_conv;
20774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20775         this_ptr_conv.is_owned = false;
20776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20777         LDKChannelCounterparty val_conv;
20778         val_conv.inner = (void*)(val & (~1));
20779         val_conv.is_owned = (val & 1) || (val == 0);
20780         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20781         val_conv = ChannelCounterparty_clone(&val_conv);
20782         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
20783 }
20784
20785 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
20786         LDKChannelDetails this_ptr_conv;
20787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20788         this_ptr_conv.is_owned = false;
20789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20790         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
20791         uint64_t ret_ref = 0;
20792         if ((uint64_t)ret_var.inner > 4096) {
20793                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20794                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20796                 ret_ref = (uint64_t)ret_var.inner;
20797                 if (ret_var.is_owned) {
20798                         ret_ref |= 1;
20799                 }
20800         }
20801         return ret_ref;
20802 }
20803
20804 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
20805         LDKChannelDetails this_ptr_conv;
20806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20807         this_ptr_conv.is_owned = false;
20808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20809         LDKOutPoint val_conv;
20810         val_conv.inner = (void*)(val & (~1));
20811         val_conv.is_owned = (val & 1) || (val == 0);
20812         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20813         val_conv = OutPoint_clone(&val_conv);
20814         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
20815 }
20816
20817 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
20818         LDKChannelDetails this_ptr_conv;
20819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20820         this_ptr_conv.is_owned = false;
20821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20822         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20823         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
20824         uint64_t ret_ref = (uint64_t)ret_copy;
20825         return ret_ref;
20826 }
20827
20828 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
20829         LDKChannelDetails this_ptr_conv;
20830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20831         this_ptr_conv.is_owned = false;
20832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20833         void* val_ptr = (void*)(((uint64_t)val) & ~1);
20834         CHECK_ACCESS(val_ptr);
20835         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
20836         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
20837         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
20838 }
20839
20840 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
20841         LDKChannelDetails this_ptr_conv;
20842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20843         this_ptr_conv.is_owned = false;
20844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20845         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
20846         return ret_val;
20847 }
20848
20849 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
20850         LDKChannelDetails this_ptr_conv;
20851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20852         this_ptr_conv.is_owned = false;
20853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20854         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
20855 }
20856
20857 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
20858         LDKChannelDetails this_ptr_conv;
20859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20860         this_ptr_conv.is_owned = false;
20861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20862         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
20863         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
20864         uint64_t ret_ref = (uint64_t)ret_copy;
20865         return ret_ref;
20866 }
20867
20868 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
20869         LDKChannelDetails this_ptr_conv;
20870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20871         this_ptr_conv.is_owned = false;
20872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20873         void* val_ptr = (void*)(((uint64_t)val) & ~1);
20874         CHECK_ACCESS(val_ptr);
20875         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
20876         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
20877         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
20878 }
20879
20880 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
20881         LDKChannelDetails this_ptr_conv;
20882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20883         this_ptr_conv.is_owned = false;
20884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20885         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
20886         return ret_val;
20887 }
20888
20889 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
20890         LDKChannelDetails this_ptr_conv;
20891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20892         this_ptr_conv.is_owned = false;
20893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20894         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
20895 }
20896
20897 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
20898         LDKChannelDetails this_ptr_conv;
20899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20900         this_ptr_conv.is_owned = false;
20901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20902         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
20903         return ret_val;
20904 }
20905
20906 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
20907         LDKChannelDetails this_ptr_conv;
20908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20909         this_ptr_conv.is_owned = false;
20910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20911         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
20912 }
20913
20914 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
20915         LDKChannelDetails this_ptr_conv;
20916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20917         this_ptr_conv.is_owned = false;
20918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20919         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
20920         return ret_val;
20921 }
20922
20923 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
20924         LDKChannelDetails this_ptr_conv;
20925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20926         this_ptr_conv.is_owned = false;
20927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20928         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
20929 }
20930
20931 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
20932         LDKChannelDetails this_ptr_conv;
20933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20934         this_ptr_conv.is_owned = false;
20935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20936         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
20937         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
20938         uint64_t ret_ref = (uint64_t)ret_copy;
20939         return ret_ref;
20940 }
20941
20942 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
20943         LDKChannelDetails this_ptr_conv;
20944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20945         this_ptr_conv.is_owned = false;
20946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20947         void* val_ptr = (void*)(((uint64_t)val) & ~1);
20948         CHECK_ACCESS(val_ptr);
20949         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
20950         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
20951         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
20952 }
20953
20954 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
20955         LDKChannelDetails this_ptr_conv;
20956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20957         this_ptr_conv.is_owned = false;
20958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20959         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20960         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
20961         uint64_t ret_ref = (uint64_t)ret_copy;
20962         return ret_ref;
20963 }
20964
20965 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_force_close_spend_delay(uint32_t this_ptr, uint32_t val) {
20966         LDKChannelDetails this_ptr_conv;
20967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20968         this_ptr_conv.is_owned = false;
20969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20970         void* val_ptr = (void*)(((uint64_t)val) & ~1);
20971         CHECK_ACCESS(val_ptr);
20972         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
20973         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
20974         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
20975 }
20976
20977 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
20978         LDKChannelDetails this_ptr_conv;
20979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20980         this_ptr_conv.is_owned = false;
20981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20982         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
20983         return ret_val;
20984 }
20985
20986 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
20987         LDKChannelDetails this_ptr_conv;
20988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20989         this_ptr_conv.is_owned = false;
20990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20991         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
20992 }
20993
20994 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
20995         LDKChannelDetails this_ptr_conv;
20996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20997         this_ptr_conv.is_owned = false;
20998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20999         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
21000         return ret_val;
21001 }
21002
21003 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
21004         LDKChannelDetails this_ptr_conv;
21005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21006         this_ptr_conv.is_owned = false;
21007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21008         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
21009 }
21010
21011 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
21012         LDKChannelDetails this_ptr_conv;
21013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21014         this_ptr_conv.is_owned = false;
21015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21016         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
21017         return ret_val;
21018 }
21019
21020 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
21021         LDKChannelDetails this_ptr_conv;
21022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21023         this_ptr_conv.is_owned = false;
21024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21025         ChannelDetails_set_is_usable(&this_ptr_conv, val);
21026 }
21027
21028 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
21029         LDKChannelDetails this_ptr_conv;
21030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21031         this_ptr_conv.is_owned = false;
21032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21033         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
21034         return ret_val;
21035 }
21036
21037 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
21038         LDKChannelDetails this_ptr_conv;
21039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21040         this_ptr_conv.is_owned = false;
21041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21042         ChannelDetails_set_is_public(&this_ptr_conv, val);
21043 }
21044
21045 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_new(int8_tArray channel_id_arg, uint32_t counterparty_arg, uint32_t funding_txo_arg, uint32_t short_channel_id_arg, int64_t channel_value_satoshis_arg, uint32_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, uint32_t confirmations_required_arg, uint32_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
21046         LDKThirtyTwoBytes channel_id_arg_ref;
21047         CHECK(*((uint32_t*)channel_id_arg) == 32);
21048         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
21049         LDKChannelCounterparty counterparty_arg_conv;
21050         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
21051         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
21052         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
21053         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
21054         LDKOutPoint funding_txo_arg_conv;
21055         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
21056         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
21057         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
21058         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
21059         void* short_channel_id_arg_ptr = (void*)(((uint64_t)short_channel_id_arg) & ~1);
21060         CHECK_ACCESS(short_channel_id_arg_ptr);
21061         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
21062         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1));
21063         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
21064         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
21065         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
21066         void* confirmations_required_arg_ptr = (void*)(((uint64_t)confirmations_required_arg) & ~1);
21067         CHECK_ACCESS(confirmations_required_arg_ptr);
21068         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
21069         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1));
21070         void* force_close_spend_delay_arg_ptr = (void*)(((uint64_t)force_close_spend_delay_arg) & ~1);
21071         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
21072         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
21073         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1));
21074         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
21075         uint64_t ret_ref = 0;
21076         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21077         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21079         ret_ref = (uint64_t)ret_var.inner;
21080         if (ret_var.is_owned) {
21081                 ret_ref |= 1;
21082         }
21083         return ret_ref;
21084 }
21085
21086 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
21087         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
21088 uint64_t ret_ref = 0;
21089 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21090 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21091 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21092 ret_ref = (uint64_t)ret_var.inner;
21093 if (ret_var.is_owned) {
21094         ret_ref |= 1;
21095 }
21096         return ret_ref;
21097 }
21098 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
21099         LDKChannelDetails arg_conv;
21100         arg_conv.inner = (void*)(arg & (~1));
21101         arg_conv.is_owned = false;
21102         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21103         int64_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
21104         return ret_val;
21105 }
21106
21107 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
21108         LDKChannelDetails orig_conv;
21109         orig_conv.inner = (void*)(orig & (~1));
21110         orig_conv.is_owned = false;
21111         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21112         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
21113         uint64_t ret_ref = 0;
21114         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21115         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21117         ret_ref = (uint64_t)ret_var.inner;
21118         if (ret_var.is_owned) {
21119                 ret_ref |= 1;
21120         }
21121         return ret_ref;
21122 }
21123
21124 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
21125         if ((this_ptr & 1) != 0) return;
21126         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21127         CHECK_ACCESS(this_ptr_ptr);
21128         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
21129         FREE((void*)this_ptr);
21130         PaymentSendFailure_free(this_ptr_conv);
21131 }
21132
21133 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
21134         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21135         *ret_copy = PaymentSendFailure_clone(arg);
21136 uint64_t ret_ref = (uint64_t)ret_copy;
21137         return ret_ref;
21138 }
21139 int64_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
21140         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
21141         int64_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
21142         return ret_val;
21143 }
21144
21145 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uint32_t orig) {
21146         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
21147         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21148         *ret_copy = PaymentSendFailure_clone(orig_conv);
21149         uint64_t ret_ref = (uint64_t)ret_copy;
21150         return ret_ref;
21151 }
21152
21153 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
21154         void* a_ptr = (void*)(((uint64_t)a) & ~1);
21155         CHECK_ACCESS(a_ptr);
21156         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
21157         a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
21158         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21159         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
21160         uint64_t ret_ref = (uint64_t)ret_copy;
21161         return ret_ref;
21162 }
21163
21164 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
21165         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
21166         a_constr.datalen = *((uint32_t*)a);
21167         if (a_constr.datalen > 0)
21168                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
21169         else
21170                 a_constr.data = NULL;
21171         uint32_t* a_vals = (uint32_t*)(a + 4);
21172         for (size_t w = 0; w < a_constr.datalen; w++) {
21173                 uint32_t a_conv_22 = a_vals[w];
21174                 void* a_conv_22_ptr = (void*)(((uint64_t)a_conv_22) & ~1);
21175                 CHECK_ACCESS(a_conv_22_ptr);
21176                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
21177                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
21178                 a_constr.data[w] = a_conv_22_conv;
21179         }
21180         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21181         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
21182         uint64_t ret_ref = (uint64_t)ret_copy;
21183         return ret_ref;
21184 }
21185
21186 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
21187         LDKCVec_APIErrorZ a_constr;
21188         a_constr.datalen = *((uint32_t*)a);
21189         if (a_constr.datalen > 0)
21190                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
21191         else
21192                 a_constr.data = NULL;
21193         uint32_t* a_vals = (uint32_t*)(a + 4);
21194         for (size_t k = 0; k < a_constr.datalen; k++) {
21195                 uint32_t a_conv_10 = a_vals[k];
21196                 void* a_conv_10_ptr = (void*)(((uint64_t)a_conv_10) & ~1);
21197                 CHECK_ACCESS(a_conv_10_ptr);
21198                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
21199                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
21200                 a_constr.data[k] = a_conv_10_conv;
21201         }
21202         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21203         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
21204         uint64_t ret_ref = (uint64_t)ret_copy;
21205         return ret_ref;
21206 }
21207
21208 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_partial_failure(uint32_tArray results, uint32_t failed_paths_retry, int8_tArray payment_id) {
21209         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
21210         results_constr.datalen = *((uint32_t*)results);
21211         if (results_constr.datalen > 0)
21212                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
21213         else
21214                 results_constr.data = NULL;
21215         uint32_t* results_vals = (uint32_t*)(results + 4);
21216         for (size_t w = 0; w < results_constr.datalen; w++) {
21217                 uint32_t results_conv_22 = results_vals[w];
21218                 void* results_conv_22_ptr = (void*)(((uint64_t)results_conv_22) & ~1);
21219                 CHECK_ACCESS(results_conv_22_ptr);
21220                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
21221                 results_constr.data[w] = results_conv_22_conv;
21222         }
21223         LDKRouteParameters failed_paths_retry_conv;
21224         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
21225         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
21226         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
21227         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
21228         LDKThirtyTwoBytes payment_id_ref;
21229         CHECK(*((uint32_t*)payment_id) == 32);
21230         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
21231         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21232         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
21233         uint64_t ret_ref = (uint64_t)ret_copy;
21234         return ret_ref;
21235 }
21236
21237 uint32_t  __attribute__((visibility("default"))) 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) {
21238         void* fee_est_ptr = (void*)(((uint64_t)fee_est) & ~1);
21239         CHECK_ACCESS(fee_est_ptr);
21240         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
21241         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
21242         CHECK_ACCESS(chain_monitor_ptr);
21243         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
21244         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
21245         CHECK_ACCESS(tx_broadcaster_ptr);
21246         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
21247         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
21248         CHECK_ACCESS(logger_ptr);
21249         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21250         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
21251         CHECK_ACCESS(keys_manager_ptr);
21252         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
21253         LDKUserConfig config_conv;
21254         config_conv.inner = (void*)(config & (~1));
21255         config_conv.is_owned = (config & 1) || (config == 0);
21256         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
21257         config_conv = UserConfig_clone(&config_conv);
21258         LDKChainParameters params_conv;
21259         params_conv.inner = (void*)(params & (~1));
21260         params_conv.is_owned = (params & 1) || (params == 0);
21261         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
21262         params_conv = ChainParameters_clone(&params_conv);
21263         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
21264         uint64_t ret_ref = 0;
21265         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21266         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21268         ret_ref = (uint64_t)ret_var.inner;
21269         if (ret_var.is_owned) {
21270                 ret_ref |= 1;
21271         }
21272         return ret_ref;
21273 }
21274
21275 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
21276         LDKChannelManager this_arg_conv;
21277         this_arg_conv.inner = (void*)(this_arg & (~1));
21278         this_arg_conv.is_owned = false;
21279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21280         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
21281         uint64_t ret_ref = 0;
21282         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21283         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21285         ret_ref = (uint64_t)ret_var.inner;
21286         if (ret_var.is_owned) {
21287                 ret_ref |= 1;
21288         }
21289         return ret_ref;
21290 }
21291
21292 uint32_t  __attribute__((visibility("default"))) 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) {
21293         LDKChannelManager this_arg_conv;
21294         this_arg_conv.inner = (void*)(this_arg & (~1));
21295         this_arg_conv.is_owned = false;
21296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21297         LDKPublicKey their_network_key_ref;
21298         CHECK(*((uint32_t*)their_network_key) == 33);
21299         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
21300         LDKUserConfig override_config_conv;
21301         override_config_conv.inner = (void*)(override_config & (~1));
21302         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
21303         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
21304         override_config_conv = UserConfig_clone(&override_config_conv);
21305         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21306         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
21307         return (uint64_t)ret_conv;
21308 }
21309
21310 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
21311         LDKChannelManager this_arg_conv;
21312         this_arg_conv.inner = (void*)(this_arg & (~1));
21313         this_arg_conv.is_owned = false;
21314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21315         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
21316         uint32_tArray ret_arr = NULL;
21317         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
21318         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
21319         for (size_t q = 0; q < ret_var.datalen; q++) {
21320                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
21321                 uint64_t ret_conv_16_ref = 0;
21322                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21323                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21324                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
21325                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
21326                 if (ret_conv_16_var.is_owned) {
21327                         ret_conv_16_ref |= 1;
21328                 }
21329                 ret_arr_ptr[q] = ret_conv_16_ref;
21330         }
21331         
21332         FREE(ret_var.data);
21333         return ret_arr;
21334 }
21335
21336 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
21337         LDKChannelManager this_arg_conv;
21338         this_arg_conv.inner = (void*)(this_arg & (~1));
21339         this_arg_conv.is_owned = false;
21340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21341         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
21342         uint32_tArray ret_arr = NULL;
21343         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
21344         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
21345         for (size_t q = 0; q < ret_var.datalen; q++) {
21346                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
21347                 uint64_t ret_conv_16_ref = 0;
21348                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21349                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21350                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
21351                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
21352                 if (ret_conv_16_var.is_owned) {
21353                         ret_conv_16_ref |= 1;
21354                 }
21355                 ret_arr_ptr[q] = ret_conv_16_ref;
21356         }
21357         
21358         FREE(ret_var.data);
21359         return ret_arr;
21360 }
21361
21362 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
21363         LDKChannelManager this_arg_conv;
21364         this_arg_conv.inner = (void*)(this_arg & (~1));
21365         this_arg_conv.is_owned = false;
21366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21367         unsigned char channel_id_arr[32];
21368         CHECK(*((uint32_t*)channel_id) == 32);
21369         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
21370         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21371         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21372         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
21373         return (uint64_t)ret_conv;
21374 }
21375
21376 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel_with_target_feerate(uint32_t this_arg, int8_tArray channel_id, int32_t target_feerate_sats_per_1000_weight) {
21377         LDKChannelManager this_arg_conv;
21378         this_arg_conv.inner = (void*)(this_arg & (~1));
21379         this_arg_conv.is_owned = false;
21380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21381         unsigned char channel_id_arr[32];
21382         CHECK(*((uint32_t*)channel_id) == 32);
21383         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
21384         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21385         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21386         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
21387         return (uint64_t)ret_conv;
21388 }
21389
21390 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
21391         LDKChannelManager this_arg_conv;
21392         this_arg_conv.inner = (void*)(this_arg & (~1));
21393         this_arg_conv.is_owned = false;
21394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21395         unsigned char channel_id_arr[32];
21396         CHECK(*((uint32_t*)channel_id) == 32);
21397         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
21398         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21399         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21400         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
21401         return (uint64_t)ret_conv;
21402 }
21403
21404 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
21405         LDKChannelManager this_arg_conv;
21406         this_arg_conv.inner = (void*)(this_arg & (~1));
21407         this_arg_conv.is_owned = false;
21408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21409         ChannelManager_force_close_all_channels(&this_arg_conv);
21410 }
21411
21412 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
21413         LDKChannelManager this_arg_conv;
21414         this_arg_conv.inner = (void*)(this_arg & (~1));
21415         this_arg_conv.is_owned = false;
21416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21417         LDKRoute route_conv;
21418         route_conv.inner = (void*)(route & (~1));
21419         route_conv.is_owned = false;
21420         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
21421         LDKThirtyTwoBytes payment_hash_ref;
21422         CHECK(*((uint32_t*)payment_hash) == 32);
21423         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
21424         LDKThirtyTwoBytes payment_secret_ref;
21425         CHECK(*((uint32_t*)payment_secret) == 32);
21426         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
21427         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
21428         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
21429         return (uint64_t)ret_conv;
21430 }
21431
21432 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
21433         LDKChannelManager this_arg_conv;
21434         this_arg_conv.inner = (void*)(this_arg & (~1));
21435         this_arg_conv.is_owned = false;
21436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21437         LDKRoute route_conv;
21438         route_conv.inner = (void*)(route & (~1));
21439         route_conv.is_owned = false;
21440         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
21441         LDKThirtyTwoBytes payment_id_ref;
21442         CHECK(*((uint32_t*)payment_id) == 32);
21443         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
21444         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21445         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
21446         return (uint64_t)ret_conv;
21447 }
21448
21449 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_spontaneous_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_preimage) {
21450         LDKChannelManager this_arg_conv;
21451         this_arg_conv.inner = (void*)(this_arg & (~1));
21452         this_arg_conv.is_owned = false;
21453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21454         LDKRoute route_conv;
21455         route_conv.inner = (void*)(route & (~1));
21456         route_conv.is_owned = false;
21457         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
21458         LDKThirtyTwoBytes payment_preimage_ref;
21459         CHECK(*((uint32_t*)payment_preimage) == 32);
21460         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
21461         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21462         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
21463         return (uint64_t)ret_conv;
21464 }
21465
21466 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
21467         LDKChannelManager this_arg_conv;
21468         this_arg_conv.inner = (void*)(this_arg & (~1));
21469         this_arg_conv.is_owned = false;
21470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21471         unsigned char temporary_channel_id_arr[32];
21472         CHECK(*((uint32_t*)temporary_channel_id) == 32);
21473         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
21474         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
21475         LDKTransaction funding_transaction_ref;
21476         funding_transaction_ref.datalen = *((uint32_t*)funding_transaction);
21477         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
21478         memcpy(funding_transaction_ref.data, (uint8_t*)(funding_transaction + 4), funding_transaction_ref.datalen);
21479         funding_transaction_ref.data_is_owned = true;
21480         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21481         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
21482         return (uint64_t)ret_conv;
21483 }
21484
21485 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
21486         LDKChannelManager this_arg_conv;
21487         this_arg_conv.inner = (void*)(this_arg & (~1));
21488         this_arg_conv.is_owned = false;
21489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21490         LDKThreeBytes rgb_ref;
21491         CHECK(*((uint32_t*)rgb) == 3);
21492         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
21493         LDKThirtyTwoBytes alias_ref;
21494         CHECK(*((uint32_t*)alias) == 32);
21495         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
21496         LDKCVec_NetAddressZ addresses_constr;
21497         addresses_constr.datalen = *((uint32_t*)addresses);
21498         if (addresses_constr.datalen > 0)
21499                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21500         else
21501                 addresses_constr.data = NULL;
21502         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
21503         for (size_t m = 0; m < addresses_constr.datalen; m++) {
21504                 uint32_t addresses_conv_12 = addresses_vals[m];
21505                 void* addresses_conv_12_ptr = (void*)(((uint64_t)addresses_conv_12) & ~1);
21506                 CHECK_ACCESS(addresses_conv_12_ptr);
21507                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
21508                 addresses_constr.data[m] = addresses_conv_12_conv;
21509         }
21510         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
21511 }
21512
21513 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
21514         LDKChannelManager this_arg_conv;
21515         this_arg_conv.inner = (void*)(this_arg & (~1));
21516         this_arg_conv.is_owned = false;
21517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21518         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
21519 }
21520
21521 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
21522         LDKChannelManager this_arg_conv;
21523         this_arg_conv.inner = (void*)(this_arg & (~1));
21524         this_arg_conv.is_owned = false;
21525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21526         ChannelManager_timer_tick_occurred(&this_arg_conv);
21527 }
21528
21529 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
21530         LDKChannelManager this_arg_conv;
21531         this_arg_conv.inner = (void*)(this_arg & (~1));
21532         this_arg_conv.is_owned = false;
21533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21534         unsigned char payment_hash_arr[32];
21535         CHECK(*((uint32_t*)payment_hash) == 32);
21536         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
21537         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
21538         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
21539         return ret_val;
21540 }
21541
21542 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
21543         LDKChannelManager this_arg_conv;
21544         this_arg_conv.inner = (void*)(this_arg & (~1));
21545         this_arg_conv.is_owned = false;
21546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21547         LDKThirtyTwoBytes payment_preimage_ref;
21548         CHECK(*((uint32_t*)payment_preimage) == 32);
21549         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
21550         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
21551         return ret_val;
21552 }
21553
21554 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
21555         LDKChannelManager this_arg_conv;
21556         this_arg_conv.inner = (void*)(this_arg & (~1));
21557         this_arg_conv.is_owned = false;
21558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21559         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21560         memcpy((uint8_t*)(ret_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
21561         return ret_arr;
21562 }
21563
21564 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_create_inbound_payment(uint32_t this_arg, uint32_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t user_payment_id) {
21565         LDKChannelManager this_arg_conv;
21566         this_arg_conv.inner = (void*)(this_arg & (~1));
21567         this_arg_conv.is_owned = false;
21568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21569         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
21570         CHECK_ACCESS(min_value_msat_ptr);
21571         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
21572         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
21573         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21574         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
21575         return ((uint64_t)ret_conv);
21576 }
21577
21578 uint32_t  __attribute__((visibility("default"))) 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, int64_t user_payment_id) {
21579         LDKChannelManager this_arg_conv;
21580         this_arg_conv.inner = (void*)(this_arg & (~1));
21581         this_arg_conv.is_owned = false;
21582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21583         LDKThirtyTwoBytes payment_hash_ref;
21584         CHECK(*((uint32_t*)payment_hash) == 32);
21585         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
21586         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
21587         CHECK_ACCESS(min_value_msat_ptr);
21588         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
21589         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
21590         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
21591         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
21592         return (uint64_t)ret_conv;
21593 }
21594
21595 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
21596         LDKChannelManager this_arg_conv;
21597         this_arg_conv.inner = (void*)(this_arg & (~1));
21598         this_arg_conv.is_owned = false;
21599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21600         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21601         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
21602         return (uint64_t)ret_ret;
21603 }
21604
21605 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
21606         LDKChannelManager this_arg_conv;
21607         this_arg_conv.inner = (void*)(this_arg & (~1));
21608         this_arg_conv.is_owned = false;
21609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21610         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
21611         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
21612         return (uint64_t)ret_ret;
21613 }
21614
21615 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
21616         LDKChannelManager this_arg_conv;
21617         this_arg_conv.inner = (void*)(this_arg & (~1));
21618         this_arg_conv.is_owned = false;
21619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21620         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
21621         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
21622         return (uint64_t)ret_ret;
21623 }
21624
21625 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
21626         LDKChannelManager this_arg_conv;
21627         this_arg_conv.inner = (void*)(this_arg & (~1));
21628         this_arg_conv.is_owned = false;
21629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21630         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
21631         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
21632         return (uint64_t)ret_ret;
21633 }
21634
21635 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update_timeout(uint32_t this_arg, int64_t max_wait) {
21636         LDKChannelManager this_arg_conv;
21637         this_arg_conv.inner = (void*)(this_arg & (~1));
21638         this_arg_conv.is_owned = false;
21639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21640         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
21641         return ret_val;
21642 }
21643
21644 void  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
21645         LDKChannelManager this_arg_conv;
21646         this_arg_conv.inner = (void*)(this_arg & (~1));
21647         this_arg_conv.is_owned = false;
21648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21649         ChannelManager_await_persistable_update(&this_arg_conv);
21650 }
21651
21652 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
21653         LDKChannelManager this_arg_conv;
21654         this_arg_conv.inner = (void*)(this_arg & (~1));
21655         this_arg_conv.is_owned = false;
21656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21657         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
21658         uint64_t ret_ref = 0;
21659         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21660         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21662         ret_ref = (uint64_t)ret_var.inner;
21663         if (ret_var.is_owned) {
21664                 ret_ref |= 1;
21665         }
21666         return ret_ref;
21667 }
21668
21669 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
21670         LDKChannelManager this_arg_conv;
21671         this_arg_conv.inner = (void*)(this_arg & (~1));
21672         this_arg_conv.is_owned = false;
21673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21674         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
21675         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
21676         return (uint64_t)ret_ret;
21677 }
21678
21679 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
21680         LDKChannelManager obj_conv;
21681         obj_conv.inner = (void*)(obj & (~1));
21682         obj_conv.is_owned = false;
21683         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21684         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
21685         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21686         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21687         CVec_u8Z_free(ret_var);
21688         return ret_arr;
21689 }
21690
21691 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
21692         LDKChannelManagerReadArgs this_obj_conv;
21693         this_obj_conv.inner = (void*)(this_obj & (~1));
21694         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21696         ChannelManagerReadArgs_free(this_obj_conv);
21697 }
21698
21699 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
21700         LDKChannelManagerReadArgs 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         // WARNING: This object doesn't live past this scope, needs clone!
21705         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
21706         return ret_ret;
21707 }
21708
21709 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
21710         LDKChannelManagerReadArgs this_ptr_conv;
21711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21712         this_ptr_conv.is_owned = false;
21713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21714         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21715         CHECK_ACCESS(val_ptr);
21716         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
21717         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
21718 }
21719
21720 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
21721         LDKChannelManagerReadArgs this_ptr_conv;
21722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21723         this_ptr_conv.is_owned = false;
21724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21725         // WARNING: This object doesn't live past this scope, needs clone!
21726         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
21727         return ret_ret;
21728 }
21729
21730 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
21731         LDKChannelManagerReadArgs this_ptr_conv;
21732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21733         this_ptr_conv.is_owned = false;
21734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21735         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21736         CHECK_ACCESS(val_ptr);
21737         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
21738         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
21739 }
21740
21741 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
21742         LDKChannelManagerReadArgs this_ptr_conv;
21743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21744         this_ptr_conv.is_owned = false;
21745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21746         // WARNING: This object doesn't live past this scope, needs clone!
21747         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
21748         return ret_ret;
21749 }
21750
21751 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
21752         LDKChannelManagerReadArgs this_ptr_conv;
21753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21754         this_ptr_conv.is_owned = false;
21755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21756         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21757         CHECK_ACCESS(val_ptr);
21758         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
21759         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
21760 }
21761
21762 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
21763         LDKChannelManagerReadArgs this_ptr_conv;
21764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21765         this_ptr_conv.is_owned = false;
21766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21767         // WARNING: This object doesn't live past this scope, needs clone!
21768         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
21769         return ret_ret;
21770 }
21771
21772 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
21773         LDKChannelManagerReadArgs this_ptr_conv;
21774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21775         this_ptr_conv.is_owned = false;
21776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21777         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21778         CHECK_ACCESS(val_ptr);
21779         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
21780         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
21781 }
21782
21783 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
21784         LDKChannelManagerReadArgs this_ptr_conv;
21785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21786         this_ptr_conv.is_owned = false;
21787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21788         // WARNING: This object doesn't live past this scope, needs clone!
21789         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
21790         return ret_ret;
21791 }
21792
21793 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
21794         LDKChannelManagerReadArgs 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         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21799         CHECK_ACCESS(val_ptr);
21800         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
21801         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
21802 }
21803
21804 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
21805         LDKChannelManagerReadArgs this_ptr_conv;
21806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21807         this_ptr_conv.is_owned = false;
21808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21809         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
21810         uint64_t ret_ref = 0;
21811         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21812         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21814         ret_ref = (uint64_t)ret_var.inner;
21815         if (ret_var.is_owned) {
21816                 ret_ref |= 1;
21817         }
21818         return ret_ref;
21819 }
21820
21821 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
21822         LDKChannelManagerReadArgs this_ptr_conv;
21823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21824         this_ptr_conv.is_owned = false;
21825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21826         LDKUserConfig val_conv;
21827         val_conv.inner = (void*)(val & (~1));
21828         val_conv.is_owned = (val & 1) || (val == 0);
21829         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21830         val_conv = UserConfig_clone(&val_conv);
21831         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
21832 }
21833
21834 uint32_t  __attribute__((visibility("default"))) 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) {
21835         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
21836         CHECK_ACCESS(keys_manager_ptr);
21837         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
21838         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
21839         CHECK_ACCESS(fee_estimator_ptr);
21840         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
21841         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
21842         CHECK_ACCESS(chain_monitor_ptr);
21843         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
21844         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
21845         CHECK_ACCESS(tx_broadcaster_ptr);
21846         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
21847         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
21848         CHECK_ACCESS(logger_ptr);
21849         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21850         LDKUserConfig default_config_conv;
21851         default_config_conv.inner = (void*)(default_config & (~1));
21852         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
21853         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
21854         default_config_conv = UserConfig_clone(&default_config_conv);
21855         LDKCVec_ChannelMonitorZ channel_monitors_constr;
21856         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
21857         if (channel_monitors_constr.datalen > 0)
21858                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
21859         else
21860                 channel_monitors_constr.data = NULL;
21861         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
21862         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
21863                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
21864                 LDKChannelMonitor channel_monitors_conv_16_conv;
21865                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
21866                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
21867                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
21868                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
21869         }
21870         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);
21871         uint64_t ret_ref = 0;
21872         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21873         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21875         ret_ref = (uint64_t)ret_var.inner;
21876         if (ret_var.is_owned) {
21877                 ret_ref |= 1;
21878         }
21879         return ret_ref;
21880 }
21881
21882 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
21883         LDKu8slice ser_ref;
21884         ser_ref.datalen = *((uint32_t*)ser);
21885         ser_ref.data = (int8_t*)(ser + 4);
21886         LDKChannelManagerReadArgs arg_conv;
21887         arg_conv.inner = (void*)(arg & (~1));
21888         arg_conv.is_owned = (arg & 1) || (arg == 0);
21889         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21890         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
21891         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
21892         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
21893         return (uint64_t)ret_conv;
21894 }
21895
21896 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_obj) {
21897         LDKDecodeError this_obj_conv;
21898         this_obj_conv.inner = (void*)(this_obj & (~1));
21899         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21901         DecodeError_free(this_obj_conv);
21902 }
21903
21904 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
21905         LDKDecodeError ret_var = DecodeError_clone(arg);
21906 uint64_t ret_ref = 0;
21907 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21908 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21909 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21910 ret_ref = (uint64_t)ret_var.inner;
21911 if (ret_var.is_owned) {
21912         ret_ref |= 1;
21913 }
21914         return ret_ref;
21915 }
21916 int64_t  __attribute__((visibility("default"))) TS_DecodeError_clone_ptr(uint32_t arg) {
21917         LDKDecodeError arg_conv;
21918         arg_conv.inner = (void*)(arg & (~1));
21919         arg_conv.is_owned = false;
21920         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21921         int64_t ret_val = DecodeError_clone_ptr(&arg_conv);
21922         return ret_val;
21923 }
21924
21925 uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t orig) {
21926         LDKDecodeError orig_conv;
21927         orig_conv.inner = (void*)(orig & (~1));
21928         orig_conv.is_owned = false;
21929         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21930         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
21931         uint64_t ret_ref = 0;
21932         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21933         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21935         ret_ref = (uint64_t)ret_var.inner;
21936         if (ret_var.is_owned) {
21937                 ret_ref |= 1;
21938         }
21939         return ret_ref;
21940 }
21941
21942 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_obj) {
21943         LDKInit this_obj_conv;
21944         this_obj_conv.inner = (void*)(this_obj & (~1));
21945         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21947         Init_free(this_obj_conv);
21948 }
21949
21950 uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t this_ptr) {
21951         LDKInit 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         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
21956         uint64_t ret_ref = 0;
21957         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21958         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21960         ret_ref = (uint64_t)ret_var.inner;
21961         if (ret_var.is_owned) {
21962                 ret_ref |= 1;
21963         }
21964         return ret_ref;
21965 }
21966
21967 void  __attribute__((visibility("default"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
21968         LDKInit 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         LDKInitFeatures val_conv;
21973         val_conv.inner = (void*)(val & (~1));
21974         val_conv.is_owned = (val & 1) || (val == 0);
21975         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21976         val_conv = InitFeatures_clone(&val_conv);
21977         Init_set_features(&this_ptr_conv, val_conv);
21978 }
21979
21980 uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_arg) {
21981         LDKInitFeatures features_arg_conv;
21982         features_arg_conv.inner = (void*)(features_arg & (~1));
21983         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
21984         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
21985         features_arg_conv = InitFeatures_clone(&features_arg_conv);
21986         LDKInit ret_var = Init_new(features_arg_conv);
21987         uint64_t ret_ref = 0;
21988         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21989         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21991         ret_ref = (uint64_t)ret_var.inner;
21992         if (ret_var.is_owned) {
21993                 ret_ref |= 1;
21994         }
21995         return ret_ref;
21996 }
21997
21998 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
21999         LDKInit ret_var = Init_clone(arg);
22000 uint64_t ret_ref = 0;
22001 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22002 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22003 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22004 ret_ref = (uint64_t)ret_var.inner;
22005 if (ret_var.is_owned) {
22006         ret_ref |= 1;
22007 }
22008         return ret_ref;
22009 }
22010 int64_t  __attribute__((visibility("default"))) TS_Init_clone_ptr(uint32_t arg) {
22011         LDKInit arg_conv;
22012         arg_conv.inner = (void*)(arg & (~1));
22013         arg_conv.is_owned = false;
22014         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22015         int64_t ret_val = Init_clone_ptr(&arg_conv);
22016         return ret_val;
22017 }
22018
22019 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
22020         LDKInit orig_conv;
22021         orig_conv.inner = (void*)(orig & (~1));
22022         orig_conv.is_owned = false;
22023         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22024         LDKInit ret_var = Init_clone(&orig_conv);
22025         uint64_t ret_ref = 0;
22026         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22027         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22029         ret_ref = (uint64_t)ret_var.inner;
22030         if (ret_var.is_owned) {
22031                 ret_ref |= 1;
22032         }
22033         return ret_ref;
22034 }
22035
22036 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_obj) {
22037         LDKErrorMessage this_obj_conv;
22038         this_obj_conv.inner = (void*)(this_obj & (~1));
22039         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22041         ErrorMessage_free(this_obj_conv);
22042 }
22043
22044 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
22045         LDKErrorMessage this_ptr_conv;
22046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22047         this_ptr_conv.is_owned = false;
22048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22049         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22050         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
22051         return ret_arr;
22052 }
22053
22054 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
22055         LDKErrorMessage this_ptr_conv;
22056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22057         this_ptr_conv.is_owned = false;
22058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22059         LDKThirtyTwoBytes val_ref;
22060         CHECK(*((uint32_t*)val) == 32);
22061         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
22062         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
22063 }
22064
22065 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
22066         LDKErrorMessage this_ptr_conv;
22067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22068         this_ptr_conv.is_owned = false;
22069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22070         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
22071         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22072         Str_free(ret_str);
22073         return ret_conv;
22074 }
22075
22076 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
22077         LDKErrorMessage this_ptr_conv;
22078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22079         this_ptr_conv.is_owned = false;
22080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22081         LDKStr val_conv = str_ref_to_owned_c(val);
22082         ErrorMessage_set_data(&this_ptr_conv, val_conv);
22083 }
22084
22085 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
22086         LDKThirtyTwoBytes channel_id_arg_ref;
22087         CHECK(*((uint32_t*)channel_id_arg) == 32);
22088         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
22089         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
22090         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
22091         uint64_t ret_ref = 0;
22092         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22093         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22095         ret_ref = (uint64_t)ret_var.inner;
22096         if (ret_var.is_owned) {
22097                 ret_ref |= 1;
22098         }
22099         return ret_ref;
22100 }
22101
22102 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
22103         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
22104 uint64_t ret_ref = 0;
22105 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22106 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22107 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22108 ret_ref = (uint64_t)ret_var.inner;
22109 if (ret_var.is_owned) {
22110         ret_ref |= 1;
22111 }
22112         return ret_ref;
22113 }
22114 int64_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
22115         LDKErrorMessage arg_conv;
22116         arg_conv.inner = (void*)(arg & (~1));
22117         arg_conv.is_owned = false;
22118         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22119         int64_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
22120         return ret_val;
22121 }
22122
22123 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
22124         LDKErrorMessage orig_conv;
22125         orig_conv.inner = (void*)(orig & (~1));
22126         orig_conv.is_owned = false;
22127         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22128         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
22129         uint64_t ret_ref = 0;
22130         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22131         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22133         ret_ref = (uint64_t)ret_var.inner;
22134         if (ret_var.is_owned) {
22135                 ret_ref |= 1;
22136         }
22137         return ret_ref;
22138 }
22139
22140 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_obj) {
22141         LDKPing this_obj_conv;
22142         this_obj_conv.inner = (void*)(this_obj & (~1));
22143         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22145         Ping_free(this_obj_conv);
22146 }
22147
22148 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
22149         LDKPing this_ptr_conv;
22150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22151         this_ptr_conv.is_owned = false;
22152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22153         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
22154         return ret_val;
22155 }
22156
22157 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
22158         LDKPing this_ptr_conv;
22159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22160         this_ptr_conv.is_owned = false;
22161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22162         Ping_set_ponglen(&this_ptr_conv, val);
22163 }
22164
22165 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
22166         LDKPing this_ptr_conv;
22167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22168         this_ptr_conv.is_owned = false;
22169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22170         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
22171         return ret_val;
22172 }
22173
22174 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
22175         LDKPing this_ptr_conv;
22176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22177         this_ptr_conv.is_owned = false;
22178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22179         Ping_set_byteslen(&this_ptr_conv, val);
22180 }
22181
22182 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
22183         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
22184         uint64_t ret_ref = 0;
22185         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22186         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22188         ret_ref = (uint64_t)ret_var.inner;
22189         if (ret_var.is_owned) {
22190                 ret_ref |= 1;
22191         }
22192         return ret_ref;
22193 }
22194
22195 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
22196         LDKPing ret_var = Ping_clone(arg);
22197 uint64_t ret_ref = 0;
22198 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22199 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22200 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22201 ret_ref = (uint64_t)ret_var.inner;
22202 if (ret_var.is_owned) {
22203         ret_ref |= 1;
22204 }
22205         return ret_ref;
22206 }
22207 int64_t  __attribute__((visibility("default"))) TS_Ping_clone_ptr(uint32_t arg) {
22208         LDKPing arg_conv;
22209         arg_conv.inner = (void*)(arg & (~1));
22210         arg_conv.is_owned = false;
22211         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22212         int64_t ret_val = Ping_clone_ptr(&arg_conv);
22213         return ret_val;
22214 }
22215
22216 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
22217         LDKPing orig_conv;
22218         orig_conv.inner = (void*)(orig & (~1));
22219         orig_conv.is_owned = false;
22220         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22221         LDKPing ret_var = Ping_clone(&orig_conv);
22222         uint64_t ret_ref = 0;
22223         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22224         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22226         ret_ref = (uint64_t)ret_var.inner;
22227         if (ret_var.is_owned) {
22228                 ret_ref |= 1;
22229         }
22230         return ret_ref;
22231 }
22232
22233 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_obj) {
22234         LDKPong this_obj_conv;
22235         this_obj_conv.inner = (void*)(this_obj & (~1));
22236         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22238         Pong_free(this_obj_conv);
22239 }
22240
22241 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
22242         LDKPong this_ptr_conv;
22243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22244         this_ptr_conv.is_owned = false;
22245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22246         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
22247         return ret_val;
22248 }
22249
22250 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
22251         LDKPong this_ptr_conv;
22252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22253         this_ptr_conv.is_owned = false;
22254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22255         Pong_set_byteslen(&this_ptr_conv, val);
22256 }
22257
22258 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
22259         LDKPong ret_var = Pong_new(byteslen_arg);
22260         uint64_t ret_ref = 0;
22261         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22262         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22264         ret_ref = (uint64_t)ret_var.inner;
22265         if (ret_var.is_owned) {
22266                 ret_ref |= 1;
22267         }
22268         return ret_ref;
22269 }
22270
22271 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
22272         LDKPong ret_var = Pong_clone(arg);
22273 uint64_t ret_ref = 0;
22274 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22275 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22276 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22277 ret_ref = (uint64_t)ret_var.inner;
22278 if (ret_var.is_owned) {
22279         ret_ref |= 1;
22280 }
22281         return ret_ref;
22282 }
22283 int64_t  __attribute__((visibility("default"))) TS_Pong_clone_ptr(uint32_t arg) {
22284         LDKPong arg_conv;
22285         arg_conv.inner = (void*)(arg & (~1));
22286         arg_conv.is_owned = false;
22287         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22288         int64_t ret_val = Pong_clone_ptr(&arg_conv);
22289         return ret_val;
22290 }
22291
22292 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
22293         LDKPong orig_conv;
22294         orig_conv.inner = (void*)(orig & (~1));
22295         orig_conv.is_owned = false;
22296         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22297         LDKPong ret_var = Pong_clone(&orig_conv);
22298         uint64_t ret_ref = 0;
22299         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22300         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22302         ret_ref = (uint64_t)ret_var.inner;
22303         if (ret_var.is_owned) {
22304                 ret_ref |= 1;
22305         }
22306         return ret_ref;
22307 }
22308
22309 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_obj) {
22310         LDKOpenChannel this_obj_conv;
22311         this_obj_conv.inner = (void*)(this_obj & (~1));
22312         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22314         OpenChannel_free(this_obj_conv);
22315 }
22316
22317 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
22318         LDKOpenChannel this_ptr_conv;
22319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22320         this_ptr_conv.is_owned = false;
22321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22322         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22323         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
22324         return ret_arr;
22325 }
22326
22327 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
22328         LDKOpenChannel this_ptr_conv;
22329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22330         this_ptr_conv.is_owned = false;
22331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22332         LDKThirtyTwoBytes val_ref;
22333         CHECK(*((uint32_t*)val) == 32);
22334         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
22335         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
22336 }
22337
22338 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
22339         LDKOpenChannel this_ptr_conv;
22340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22341         this_ptr_conv.is_owned = false;
22342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22343         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22344         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
22345         return ret_arr;
22346 }
22347
22348 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
22349         LDKOpenChannel this_ptr_conv;
22350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22351         this_ptr_conv.is_owned = false;
22352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22353         LDKThirtyTwoBytes val_ref;
22354         CHECK(*((uint32_t*)val) == 32);
22355         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
22356         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
22357 }
22358
22359 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
22360         LDKOpenChannel this_ptr_conv;
22361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22362         this_ptr_conv.is_owned = false;
22363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22364         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
22365         return ret_val;
22366 }
22367
22368 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
22369         LDKOpenChannel this_ptr_conv;
22370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22371         this_ptr_conv.is_owned = false;
22372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22373         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
22374 }
22375
22376 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
22377         LDKOpenChannel this_ptr_conv;
22378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22379         this_ptr_conv.is_owned = false;
22380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22381         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
22382         return ret_val;
22383 }
22384
22385 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
22386         LDKOpenChannel this_ptr_conv;
22387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22388         this_ptr_conv.is_owned = false;
22389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22390         OpenChannel_set_push_msat(&this_ptr_conv, val);
22391 }
22392
22393 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
22394         LDKOpenChannel this_ptr_conv;
22395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22396         this_ptr_conv.is_owned = false;
22397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22398         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
22399         return ret_val;
22400 }
22401
22402 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
22403         LDKOpenChannel this_ptr_conv;
22404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22405         this_ptr_conv.is_owned = false;
22406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22407         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
22408 }
22409
22410 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
22411         LDKOpenChannel this_ptr_conv;
22412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22413         this_ptr_conv.is_owned = false;
22414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22415         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
22416         return ret_val;
22417 }
22418
22419 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
22420         LDKOpenChannel this_ptr_conv;
22421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22422         this_ptr_conv.is_owned = false;
22423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22424         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
22425 }
22426
22427 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
22428         LDKOpenChannel this_ptr_conv;
22429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22430         this_ptr_conv.is_owned = false;
22431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22432         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
22433         return ret_val;
22434 }
22435
22436 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
22437         LDKOpenChannel this_ptr_conv;
22438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22439         this_ptr_conv.is_owned = false;
22440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22441         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
22442 }
22443
22444 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
22445         LDKOpenChannel this_ptr_conv;
22446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22447         this_ptr_conv.is_owned = false;
22448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22449         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
22450         return ret_val;
22451 }
22452
22453 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
22454         LDKOpenChannel this_ptr_conv;
22455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22456         this_ptr_conv.is_owned = false;
22457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22458         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
22459 }
22460
22461 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
22462         LDKOpenChannel this_ptr_conv;
22463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22464         this_ptr_conv.is_owned = false;
22465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22466         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
22467         return ret_val;
22468 }
22469
22470 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
22471         LDKOpenChannel this_ptr_conv;
22472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22473         this_ptr_conv.is_owned = false;
22474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22475         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
22476 }
22477
22478 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
22479         LDKOpenChannel this_ptr_conv;
22480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22481         this_ptr_conv.is_owned = false;
22482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22483         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
22484         return ret_val;
22485 }
22486
22487 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
22488         LDKOpenChannel this_ptr_conv;
22489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22490         this_ptr_conv.is_owned = false;
22491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22492         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
22493 }
22494
22495 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
22496         LDKOpenChannel this_ptr_conv;
22497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22498         this_ptr_conv.is_owned = false;
22499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22500         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
22501         return ret_val;
22502 }
22503
22504 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
22505         LDKOpenChannel this_ptr_conv;
22506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22507         this_ptr_conv.is_owned = false;
22508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22509         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
22510 }
22511
22512 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
22513         LDKOpenChannel this_ptr_conv;
22514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22515         this_ptr_conv.is_owned = false;
22516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22517         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22518         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
22519         return ret_arr;
22520 }
22521
22522 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
22523         LDKOpenChannel this_ptr_conv;
22524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22525         this_ptr_conv.is_owned = false;
22526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22527         LDKPublicKey val_ref;
22528         CHECK(*((uint32_t*)val) == 33);
22529         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22530         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
22531 }
22532
22533 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
22534         LDKOpenChannel this_ptr_conv;
22535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22536         this_ptr_conv.is_owned = false;
22537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22538         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22539         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
22540         return ret_arr;
22541 }
22542
22543 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
22544         LDKOpenChannel this_ptr_conv;
22545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22546         this_ptr_conv.is_owned = false;
22547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22548         LDKPublicKey val_ref;
22549         CHECK(*((uint32_t*)val) == 33);
22550         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22551         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
22552 }
22553
22554 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
22555         LDKOpenChannel this_ptr_conv;
22556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22557         this_ptr_conv.is_owned = false;
22558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22559         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22560         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
22561         return ret_arr;
22562 }
22563
22564 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
22565         LDKOpenChannel this_ptr_conv;
22566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22567         this_ptr_conv.is_owned = false;
22568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22569         LDKPublicKey val_ref;
22570         CHECK(*((uint32_t*)val) == 33);
22571         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22572         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
22573 }
22574
22575 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
22576         LDKOpenChannel this_ptr_conv;
22577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22578         this_ptr_conv.is_owned = false;
22579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22580         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22581         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
22582         return ret_arr;
22583 }
22584
22585 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
22586         LDKOpenChannel this_ptr_conv;
22587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22588         this_ptr_conv.is_owned = false;
22589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22590         LDKPublicKey val_ref;
22591         CHECK(*((uint32_t*)val) == 33);
22592         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22593         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
22594 }
22595
22596 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
22597         LDKOpenChannel this_ptr_conv;
22598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22599         this_ptr_conv.is_owned = false;
22600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22601         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22602         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
22603         return ret_arr;
22604 }
22605
22606 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
22607         LDKOpenChannel this_ptr_conv;
22608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22609         this_ptr_conv.is_owned = false;
22610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22611         LDKPublicKey val_ref;
22612         CHECK(*((uint32_t*)val) == 33);
22613         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22614         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
22615 }
22616
22617 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
22618         LDKOpenChannel this_ptr_conv;
22619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22620         this_ptr_conv.is_owned = false;
22621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22622         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22623         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
22624         return ret_arr;
22625 }
22626
22627 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
22628         LDKOpenChannel this_ptr_conv;
22629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22630         this_ptr_conv.is_owned = false;
22631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22632         LDKPublicKey val_ref;
22633         CHECK(*((uint32_t*)val) == 33);
22634         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22635         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
22636 }
22637
22638 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
22639         LDKOpenChannel this_ptr_conv;
22640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22641         this_ptr_conv.is_owned = false;
22642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22643         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
22644         return ret_val;
22645 }
22646
22647 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
22648         LDKOpenChannel this_ptr_conv;
22649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22650         this_ptr_conv.is_owned = false;
22651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22652         OpenChannel_set_channel_flags(&this_ptr_conv, val);
22653 }
22654
22655 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
22656         LDKOpenChannel ret_var = OpenChannel_clone(arg);
22657 uint64_t ret_ref = 0;
22658 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22659 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22660 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22661 ret_ref = (uint64_t)ret_var.inner;
22662 if (ret_var.is_owned) {
22663         ret_ref |= 1;
22664 }
22665         return ret_ref;
22666 }
22667 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
22668         LDKOpenChannel arg_conv;
22669         arg_conv.inner = (void*)(arg & (~1));
22670         arg_conv.is_owned = false;
22671         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22672         int64_t ret_val = OpenChannel_clone_ptr(&arg_conv);
22673         return ret_val;
22674 }
22675
22676 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
22677         LDKOpenChannel orig_conv;
22678         orig_conv.inner = (void*)(orig & (~1));
22679         orig_conv.is_owned = false;
22680         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22681         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
22682         uint64_t ret_ref = 0;
22683         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22684         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22686         ret_ref = (uint64_t)ret_var.inner;
22687         if (ret_var.is_owned) {
22688                 ret_ref |= 1;
22689         }
22690         return ret_ref;
22691 }
22692
22693 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_obj) {
22694         LDKAcceptChannel this_obj_conv;
22695         this_obj_conv.inner = (void*)(this_obj & (~1));
22696         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22698         AcceptChannel_free(this_obj_conv);
22699 }
22700
22701 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
22702         LDKAcceptChannel this_ptr_conv;
22703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22704         this_ptr_conv.is_owned = false;
22705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22706         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22707         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
22708         return ret_arr;
22709 }
22710
22711 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
22712         LDKAcceptChannel this_ptr_conv;
22713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22714         this_ptr_conv.is_owned = false;
22715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22716         LDKThirtyTwoBytes val_ref;
22717         CHECK(*((uint32_t*)val) == 32);
22718         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
22719         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
22720 }
22721
22722 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
22723         LDKAcceptChannel this_ptr_conv;
22724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22725         this_ptr_conv.is_owned = false;
22726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22727         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
22728         return ret_val;
22729 }
22730
22731 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
22732         LDKAcceptChannel this_ptr_conv;
22733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22734         this_ptr_conv.is_owned = false;
22735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22736         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
22737 }
22738
22739 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
22740         LDKAcceptChannel this_ptr_conv;
22741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22742         this_ptr_conv.is_owned = false;
22743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22744         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
22745         return ret_val;
22746 }
22747
22748 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
22749         LDKAcceptChannel this_ptr_conv;
22750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22751         this_ptr_conv.is_owned = false;
22752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22753         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
22754 }
22755
22756 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
22757         LDKAcceptChannel this_ptr_conv;
22758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22759         this_ptr_conv.is_owned = false;
22760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22761         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
22762         return ret_val;
22763 }
22764
22765 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
22766         LDKAcceptChannel this_ptr_conv;
22767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22768         this_ptr_conv.is_owned = false;
22769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22770         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
22771 }
22772
22773 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
22774         LDKAcceptChannel this_ptr_conv;
22775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22776         this_ptr_conv.is_owned = false;
22777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22778         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
22779         return ret_val;
22780 }
22781
22782 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
22783         LDKAcceptChannel this_ptr_conv;
22784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22785         this_ptr_conv.is_owned = false;
22786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22787         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
22788 }
22789
22790 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
22791         LDKAcceptChannel this_ptr_conv;
22792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22793         this_ptr_conv.is_owned = false;
22794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22795         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
22796         return ret_val;
22797 }
22798
22799 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
22800         LDKAcceptChannel this_ptr_conv;
22801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22802         this_ptr_conv.is_owned = false;
22803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22804         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
22805 }
22806
22807 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
22808         LDKAcceptChannel this_ptr_conv;
22809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22810         this_ptr_conv.is_owned = false;
22811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22812         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
22813         return ret_val;
22814 }
22815
22816 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
22817         LDKAcceptChannel this_ptr_conv;
22818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22819         this_ptr_conv.is_owned = false;
22820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22821         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
22822 }
22823
22824 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
22825         LDKAcceptChannel this_ptr_conv;
22826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22827         this_ptr_conv.is_owned = false;
22828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22829         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
22830         return ret_val;
22831 }
22832
22833 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
22834         LDKAcceptChannel this_ptr_conv;
22835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22836         this_ptr_conv.is_owned = false;
22837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22838         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
22839 }
22840
22841 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
22842         LDKAcceptChannel this_ptr_conv;
22843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22844         this_ptr_conv.is_owned = false;
22845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22846         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22847         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
22848         return ret_arr;
22849 }
22850
22851 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
22852         LDKAcceptChannel this_ptr_conv;
22853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22854         this_ptr_conv.is_owned = false;
22855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22856         LDKPublicKey val_ref;
22857         CHECK(*((uint32_t*)val) == 33);
22858         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22859         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
22860 }
22861
22862 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
22863         LDKAcceptChannel this_ptr_conv;
22864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22865         this_ptr_conv.is_owned = false;
22866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22867         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22868         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
22869         return ret_arr;
22870 }
22871
22872 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
22873         LDKAcceptChannel this_ptr_conv;
22874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22875         this_ptr_conv.is_owned = false;
22876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22877         LDKPublicKey val_ref;
22878         CHECK(*((uint32_t*)val) == 33);
22879         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22880         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
22881 }
22882
22883 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
22884         LDKAcceptChannel this_ptr_conv;
22885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22886         this_ptr_conv.is_owned = false;
22887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22888         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22889         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
22890         return ret_arr;
22891 }
22892
22893 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
22894         LDKAcceptChannel this_ptr_conv;
22895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22896         this_ptr_conv.is_owned = false;
22897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22898         LDKPublicKey val_ref;
22899         CHECK(*((uint32_t*)val) == 33);
22900         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22901         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
22902 }
22903
22904 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
22905         LDKAcceptChannel this_ptr_conv;
22906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22907         this_ptr_conv.is_owned = false;
22908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22909         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22910         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
22911         return ret_arr;
22912 }
22913
22914 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
22915         LDKAcceptChannel this_ptr_conv;
22916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22917         this_ptr_conv.is_owned = false;
22918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22919         LDKPublicKey val_ref;
22920         CHECK(*((uint32_t*)val) == 33);
22921         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22922         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
22923 }
22924
22925 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
22926         LDKAcceptChannel this_ptr_conv;
22927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22928         this_ptr_conv.is_owned = false;
22929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22930         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22931         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
22932         return ret_arr;
22933 }
22934
22935 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
22936         LDKAcceptChannel this_ptr_conv;
22937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22938         this_ptr_conv.is_owned = false;
22939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22940         LDKPublicKey val_ref;
22941         CHECK(*((uint32_t*)val) == 33);
22942         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22943         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
22944 }
22945
22946 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
22947         LDKAcceptChannel this_ptr_conv;
22948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22949         this_ptr_conv.is_owned = false;
22950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22951         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22952         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
22953         return ret_arr;
22954 }
22955
22956 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
22957         LDKAcceptChannel this_ptr_conv;
22958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22959         this_ptr_conv.is_owned = false;
22960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22961         LDKPublicKey val_ref;
22962         CHECK(*((uint32_t*)val) == 33);
22963         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
22964         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
22965 }
22966
22967 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
22968         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
22969 uint64_t ret_ref = 0;
22970 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22971 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22972 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22973 ret_ref = (uint64_t)ret_var.inner;
22974 if (ret_var.is_owned) {
22975         ret_ref |= 1;
22976 }
22977         return ret_ref;
22978 }
22979 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
22980         LDKAcceptChannel arg_conv;
22981         arg_conv.inner = (void*)(arg & (~1));
22982         arg_conv.is_owned = false;
22983         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22984         int64_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
22985         return ret_val;
22986 }
22987
22988 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
22989         LDKAcceptChannel orig_conv;
22990         orig_conv.inner = (void*)(orig & (~1));
22991         orig_conv.is_owned = false;
22992         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22993         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
22994         uint64_t ret_ref = 0;
22995         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22996         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22998         ret_ref = (uint64_t)ret_var.inner;
22999         if (ret_var.is_owned) {
23000                 ret_ref |= 1;
23001         }
23002         return ret_ref;
23003 }
23004
23005 void  __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_obj) {
23006         LDKFundingCreated this_obj_conv;
23007         this_obj_conv.inner = (void*)(this_obj & (~1));
23008         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23010         FundingCreated_free(this_obj_conv);
23011 }
23012
23013 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
23014         LDKFundingCreated this_ptr_conv;
23015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23016         this_ptr_conv.is_owned = false;
23017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23018         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23019         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
23020         return ret_arr;
23021 }
23022
23023 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
23024         LDKFundingCreated this_ptr_conv;
23025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23026         this_ptr_conv.is_owned = false;
23027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23028         LDKThirtyTwoBytes val_ref;
23029         CHECK(*((uint32_t*)val) == 32);
23030         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
23031         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
23032 }
23033
23034 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
23035         LDKFundingCreated this_ptr_conv;
23036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23037         this_ptr_conv.is_owned = false;
23038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23039         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23040         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
23041         return ret_arr;
23042 }
23043
23044 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
23045         LDKFundingCreated this_ptr_conv;
23046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23047         this_ptr_conv.is_owned = false;
23048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23049         LDKThirtyTwoBytes val_ref;
23050         CHECK(*((uint32_t*)val) == 32);
23051         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
23052         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
23053 }
23054
23055 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
23056         LDKFundingCreated this_ptr_conv;
23057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23058         this_ptr_conv.is_owned = false;
23059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23060         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
23061         return ret_val;
23062 }
23063
23064 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
23065         LDKFundingCreated this_ptr_conv;
23066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23067         this_ptr_conv.is_owned = false;
23068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23069         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
23070 }
23071
23072 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
23073         LDKFundingCreated this_ptr_conv;
23074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23075         this_ptr_conv.is_owned = false;
23076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23077         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
23078         memcpy((uint8_t*)(ret_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
23079         return ret_arr;
23080 }
23081
23082 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
23083         LDKFundingCreated this_ptr_conv;
23084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23085         this_ptr_conv.is_owned = false;
23086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23087         LDKSignature val_ref;
23088         CHECK(*((uint32_t*)val) == 64);
23089         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
23090         FundingCreated_set_signature(&this_ptr_conv, val_ref);
23091 }
23092
23093 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_new(int8_tArray temporary_channel_id_arg, int8_tArray funding_txid_arg, int16_t funding_output_index_arg, int8_tArray signature_arg) {
23094         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
23095         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
23096         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
23097         LDKThirtyTwoBytes funding_txid_arg_ref;
23098         CHECK(*((uint32_t*)funding_txid_arg) == 32);
23099         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
23100         LDKSignature signature_arg_ref;
23101         CHECK(*((uint32_t*)signature_arg) == 64);
23102         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
23103         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
23104         uint64_t ret_ref = 0;
23105         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23106         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23108         ret_ref = (uint64_t)ret_var.inner;
23109         if (ret_var.is_owned) {
23110                 ret_ref |= 1;
23111         }
23112         return ret_ref;
23113 }
23114
23115 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
23116         LDKFundingCreated ret_var = FundingCreated_clone(arg);
23117 uint64_t ret_ref = 0;
23118 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23119 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23120 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23121 ret_ref = (uint64_t)ret_var.inner;
23122 if (ret_var.is_owned) {
23123         ret_ref |= 1;
23124 }
23125         return ret_ref;
23126 }
23127 int64_t  __attribute__((visibility("default"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
23128         LDKFundingCreated arg_conv;
23129         arg_conv.inner = (void*)(arg & (~1));
23130         arg_conv.is_owned = false;
23131         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23132         int64_t ret_val = FundingCreated_clone_ptr(&arg_conv);
23133         return ret_val;
23134 }
23135
23136 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
23137         LDKFundingCreated orig_conv;
23138         orig_conv.inner = (void*)(orig & (~1));
23139         orig_conv.is_owned = false;
23140         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23141         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
23142         uint64_t ret_ref = 0;
23143         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23144         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23146         ret_ref = (uint64_t)ret_var.inner;
23147         if (ret_var.is_owned) {
23148                 ret_ref |= 1;
23149         }
23150         return ret_ref;
23151 }
23152
23153 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_obj) {
23154         LDKFundingSigned this_obj_conv;
23155         this_obj_conv.inner = (void*)(this_obj & (~1));
23156         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23158         FundingSigned_free(this_obj_conv);
23159 }
23160
23161 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
23162         LDKFundingSigned this_ptr_conv;
23163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23164         this_ptr_conv.is_owned = false;
23165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23166         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23167         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
23168         return ret_arr;
23169 }
23170
23171 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23172         LDKFundingSigned this_ptr_conv;
23173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23174         this_ptr_conv.is_owned = false;
23175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23176         LDKThirtyTwoBytes val_ref;
23177         CHECK(*((uint32_t*)val) == 32);
23178         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
23179         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
23180 }
23181
23182 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
23183         LDKFundingSigned this_ptr_conv;
23184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23185         this_ptr_conv.is_owned = false;
23186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23187         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
23188         memcpy((uint8_t*)(ret_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
23189         return ret_arr;
23190 }
23191
23192 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
23193         LDKFundingSigned this_ptr_conv;
23194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23195         this_ptr_conv.is_owned = false;
23196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23197         LDKSignature val_ref;
23198         CHECK(*((uint32_t*)val) == 64);
23199         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
23200         FundingSigned_set_signature(&this_ptr_conv, val_ref);
23201 }
23202
23203 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
23204         LDKThirtyTwoBytes channel_id_arg_ref;
23205         CHECK(*((uint32_t*)channel_id_arg) == 32);
23206         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
23207         LDKSignature signature_arg_ref;
23208         CHECK(*((uint32_t*)signature_arg) == 64);
23209         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
23210         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
23211         uint64_t ret_ref = 0;
23212         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23213         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23215         ret_ref = (uint64_t)ret_var.inner;
23216         if (ret_var.is_owned) {
23217                 ret_ref |= 1;
23218         }
23219         return ret_ref;
23220 }
23221
23222 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
23223         LDKFundingSigned ret_var = FundingSigned_clone(arg);
23224 uint64_t ret_ref = 0;
23225 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23226 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23227 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23228 ret_ref = (uint64_t)ret_var.inner;
23229 if (ret_var.is_owned) {
23230         ret_ref |= 1;
23231 }
23232         return ret_ref;
23233 }
23234 int64_t  __attribute__((visibility("default"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
23235         LDKFundingSigned arg_conv;
23236         arg_conv.inner = (void*)(arg & (~1));
23237         arg_conv.is_owned = false;
23238         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23239         int64_t ret_val = FundingSigned_clone_ptr(&arg_conv);
23240         return ret_val;
23241 }
23242
23243 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
23244         LDKFundingSigned orig_conv;
23245         orig_conv.inner = (void*)(orig & (~1));
23246         orig_conv.is_owned = false;
23247         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23248         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
23249         uint64_t ret_ref = 0;
23250         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23251         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23253         ret_ref = (uint64_t)ret_var.inner;
23254         if (ret_var.is_owned) {
23255                 ret_ref |= 1;
23256         }
23257         return ret_ref;
23258 }
23259
23260 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_obj) {
23261         LDKFundingLocked this_obj_conv;
23262         this_obj_conv.inner = (void*)(this_obj & (~1));
23263         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23265         FundingLocked_free(this_obj_conv);
23266 }
23267
23268 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
23269         LDKFundingLocked this_ptr_conv;
23270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23271         this_ptr_conv.is_owned = false;
23272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23273         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23274         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
23275         return ret_arr;
23276 }
23277
23278 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23279         LDKFundingLocked this_ptr_conv;
23280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23281         this_ptr_conv.is_owned = false;
23282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23283         LDKThirtyTwoBytes val_ref;
23284         CHECK(*((uint32_t*)val) == 32);
23285         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
23286         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
23287 }
23288
23289 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
23290         LDKFundingLocked this_ptr_conv;
23291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23292         this_ptr_conv.is_owned = false;
23293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23294         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23295         memcpy((uint8_t*)(ret_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23296         return ret_arr;
23297 }
23298
23299 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
23300         LDKFundingLocked this_ptr_conv;
23301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23302         this_ptr_conv.is_owned = false;
23303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23304         LDKPublicKey val_ref;
23305         CHECK(*((uint32_t*)val) == 33);
23306         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23307         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
23308 }
23309
23310 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
23311         LDKThirtyTwoBytes channel_id_arg_ref;
23312         CHECK(*((uint32_t*)channel_id_arg) == 32);
23313         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
23314         LDKPublicKey next_per_commitment_point_arg_ref;
23315         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
23316         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
23317         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
23318         uint64_t ret_ref = 0;
23319         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23320         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23322         ret_ref = (uint64_t)ret_var.inner;
23323         if (ret_var.is_owned) {
23324                 ret_ref |= 1;
23325         }
23326         return ret_ref;
23327 }
23328
23329 static inline uint64_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
23330         LDKFundingLocked ret_var = FundingLocked_clone(arg);
23331 uint64_t ret_ref = 0;
23332 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23333 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23334 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23335 ret_ref = (uint64_t)ret_var.inner;
23336 if (ret_var.is_owned) {
23337         ret_ref |= 1;
23338 }
23339         return ret_ref;
23340 }
23341 int64_t  __attribute__((visibility("default"))) TS_FundingLocked_clone_ptr(uint32_t arg) {
23342         LDKFundingLocked arg_conv;
23343         arg_conv.inner = (void*)(arg & (~1));
23344         arg_conv.is_owned = false;
23345         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23346         int64_t ret_val = FundingLocked_clone_ptr(&arg_conv);
23347         return ret_val;
23348 }
23349
23350 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
23351         LDKFundingLocked orig_conv;
23352         orig_conv.inner = (void*)(orig & (~1));
23353         orig_conv.is_owned = false;
23354         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23355         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
23356         uint64_t ret_ref = 0;
23357         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23358         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23360         ret_ref = (uint64_t)ret_var.inner;
23361         if (ret_var.is_owned) {
23362                 ret_ref |= 1;
23363         }
23364         return ret_ref;
23365 }
23366
23367 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_obj) {
23368         LDKShutdown this_obj_conv;
23369         this_obj_conv.inner = (void*)(this_obj & (~1));
23370         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23372         Shutdown_free(this_obj_conv);
23373 }
23374
23375 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
23376         LDKShutdown this_ptr_conv;
23377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23378         this_ptr_conv.is_owned = false;
23379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23380         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23381         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
23382         return ret_arr;
23383 }
23384
23385 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23386         LDKShutdown this_ptr_conv;
23387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23388         this_ptr_conv.is_owned = false;
23389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23390         LDKThirtyTwoBytes val_ref;
23391         CHECK(*((uint32_t*)val) == 32);
23392         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
23393         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
23394 }
23395
23396 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
23397         LDKShutdown this_ptr_conv;
23398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23399         this_ptr_conv.is_owned = false;
23400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23401         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
23402         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23403         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23404         return ret_arr;
23405 }
23406
23407 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
23408         LDKShutdown this_ptr_conv;
23409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23410         this_ptr_conv.is_owned = false;
23411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23412         LDKCVec_u8Z val_ref;
23413         val_ref.datalen = *((uint32_t*)val);
23414         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
23415         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
23416         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
23417 }
23418
23419 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
23420         LDKThirtyTwoBytes channel_id_arg_ref;
23421         CHECK(*((uint32_t*)channel_id_arg) == 32);
23422         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
23423         LDKCVec_u8Z scriptpubkey_arg_ref;
23424         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
23425         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
23426         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
23427         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
23428         uint64_t ret_ref = 0;
23429         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23430         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23432         ret_ref = (uint64_t)ret_var.inner;
23433         if (ret_var.is_owned) {
23434                 ret_ref |= 1;
23435         }
23436         return ret_ref;
23437 }
23438
23439 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
23440         LDKShutdown ret_var = Shutdown_clone(arg);
23441 uint64_t ret_ref = 0;
23442 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23443 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23444 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23445 ret_ref = (uint64_t)ret_var.inner;
23446 if (ret_var.is_owned) {
23447         ret_ref |= 1;
23448 }
23449         return ret_ref;
23450 }
23451 int64_t  __attribute__((visibility("default"))) TS_Shutdown_clone_ptr(uint32_t arg) {
23452         LDKShutdown arg_conv;
23453         arg_conv.inner = (void*)(arg & (~1));
23454         arg_conv.is_owned = false;
23455         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23456         int64_t ret_val = Shutdown_clone_ptr(&arg_conv);
23457         return ret_val;
23458 }
23459
23460 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
23461         LDKShutdown orig_conv;
23462         orig_conv.inner = (void*)(orig & (~1));
23463         orig_conv.is_owned = false;
23464         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23465         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
23466         uint64_t ret_ref = 0;
23467         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23468         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23470         ret_ref = (uint64_t)ret_var.inner;
23471         if (ret_var.is_owned) {
23472                 ret_ref |= 1;
23473         }
23474         return ret_ref;
23475 }
23476
23477 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
23478         LDKClosingSignedFeeRange this_obj_conv;
23479         this_obj_conv.inner = (void*)(this_obj & (~1));
23480         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23482         ClosingSignedFeeRange_free(this_obj_conv);
23483 }
23484
23485 int64_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
23486         LDKClosingSignedFeeRange this_ptr_conv;
23487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23488         this_ptr_conv.is_owned = false;
23489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23490         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
23491         return ret_val;
23492 }
23493
23494 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
23495         LDKClosingSignedFeeRange this_ptr_conv;
23496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23497         this_ptr_conv.is_owned = false;
23498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23499         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
23500 }
23501
23502 int64_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
23503         LDKClosingSignedFeeRange this_ptr_conv;
23504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23505         this_ptr_conv.is_owned = false;
23506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23507         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
23508         return ret_val;
23509 }
23510
23511 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
23512         LDKClosingSignedFeeRange this_ptr_conv;
23513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23514         this_ptr_conv.is_owned = false;
23515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23516         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
23517 }
23518
23519 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
23520         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
23521         uint64_t ret_ref = 0;
23522         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23523         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23525         ret_ref = (uint64_t)ret_var.inner;
23526         if (ret_var.is_owned) {
23527                 ret_ref |= 1;
23528         }
23529         return ret_ref;
23530 }
23531
23532 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
23533         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
23534 uint64_t ret_ref = 0;
23535 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23536 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23537 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23538 ret_ref = (uint64_t)ret_var.inner;
23539 if (ret_var.is_owned) {
23540         ret_ref |= 1;
23541 }
23542         return ret_ref;
23543 }
23544 int64_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
23545         LDKClosingSignedFeeRange arg_conv;
23546         arg_conv.inner = (void*)(arg & (~1));
23547         arg_conv.is_owned = false;
23548         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23549         int64_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
23550         return ret_val;
23551 }
23552
23553 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
23554         LDKClosingSignedFeeRange orig_conv;
23555         orig_conv.inner = (void*)(orig & (~1));
23556         orig_conv.is_owned = false;
23557         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23558         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
23559         uint64_t ret_ref = 0;
23560         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23561         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23563         ret_ref = (uint64_t)ret_var.inner;
23564         if (ret_var.is_owned) {
23565                 ret_ref |= 1;
23566         }
23567         return ret_ref;
23568 }
23569
23570 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_obj) {
23571         LDKClosingSigned this_obj_conv;
23572         this_obj_conv.inner = (void*)(this_obj & (~1));
23573         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23575         ClosingSigned_free(this_obj_conv);
23576 }
23577
23578 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
23579         LDKClosingSigned this_ptr_conv;
23580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23581         this_ptr_conv.is_owned = false;
23582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23583         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23584         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
23585         return ret_arr;
23586 }
23587
23588 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23589         LDKClosingSigned this_ptr_conv;
23590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23591         this_ptr_conv.is_owned = false;
23592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23593         LDKThirtyTwoBytes val_ref;
23594         CHECK(*((uint32_t*)val) == 32);
23595         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
23596         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
23597 }
23598
23599 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
23600         LDKClosingSigned this_ptr_conv;
23601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23602         this_ptr_conv.is_owned = false;
23603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23604         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
23605         return ret_val;
23606 }
23607
23608 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
23609         LDKClosingSigned this_ptr_conv;
23610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23611         this_ptr_conv.is_owned = false;
23612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23613         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
23614 }
23615
23616 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
23617         LDKClosingSigned this_ptr_conv;
23618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23619         this_ptr_conv.is_owned = false;
23620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23621         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
23622         memcpy((uint8_t*)(ret_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
23623         return ret_arr;
23624 }
23625
23626 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
23627         LDKClosingSigned this_ptr_conv;
23628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23629         this_ptr_conv.is_owned = false;
23630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23631         LDKSignature val_ref;
23632         CHECK(*((uint32_t*)val) == 64);
23633         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
23634         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
23635 }
23636
23637 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
23638         LDKClosingSigned this_ptr_conv;
23639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23640         this_ptr_conv.is_owned = false;
23641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23642         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
23643         uint64_t ret_ref = 0;
23644         if ((uint64_t)ret_var.inner > 4096) {
23645                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23646                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23648                 ret_ref = (uint64_t)ret_var.inner;
23649                 if (ret_var.is_owned) {
23650                         ret_ref |= 1;
23651                 }
23652         }
23653         return ret_ref;
23654 }
23655
23656 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
23657         LDKClosingSigned this_ptr_conv;
23658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23659         this_ptr_conv.is_owned = false;
23660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23661         LDKClosingSignedFeeRange val_conv;
23662         val_conv.inner = (void*)(val & (~1));
23663         val_conv.is_owned = (val & 1) || (val == 0);
23664         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23665         val_conv = ClosingSignedFeeRange_clone(&val_conv);
23666         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
23667 }
23668
23669 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg, uint32_t fee_range_arg) {
23670         LDKThirtyTwoBytes channel_id_arg_ref;
23671         CHECK(*((uint32_t*)channel_id_arg) == 32);
23672         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
23673         LDKSignature signature_arg_ref;
23674         CHECK(*((uint32_t*)signature_arg) == 64);
23675         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
23676         LDKClosingSignedFeeRange fee_range_arg_conv;
23677         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
23678         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
23679         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
23680         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
23681         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
23682         uint64_t ret_ref = 0;
23683         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23684         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23686         ret_ref = (uint64_t)ret_var.inner;
23687         if (ret_var.is_owned) {
23688                 ret_ref |= 1;
23689         }
23690         return ret_ref;
23691 }
23692
23693 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
23694         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
23695 uint64_t ret_ref = 0;
23696 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23697 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23698 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23699 ret_ref = (uint64_t)ret_var.inner;
23700 if (ret_var.is_owned) {
23701         ret_ref |= 1;
23702 }
23703         return ret_ref;
23704 }
23705 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
23706         LDKClosingSigned arg_conv;
23707         arg_conv.inner = (void*)(arg & (~1));
23708         arg_conv.is_owned = false;
23709         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23710         int64_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
23711         return ret_val;
23712 }
23713
23714 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
23715         LDKClosingSigned orig_conv;
23716         orig_conv.inner = (void*)(orig & (~1));
23717         orig_conv.is_owned = false;
23718         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23719         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
23720         uint64_t ret_ref = 0;
23721         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23722         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23724         ret_ref = (uint64_t)ret_var.inner;
23725         if (ret_var.is_owned) {
23726                 ret_ref |= 1;
23727         }
23728         return ret_ref;
23729 }
23730
23731 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
23732         LDKUpdateAddHTLC this_obj_conv;
23733         this_obj_conv.inner = (void*)(this_obj & (~1));
23734         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23736         UpdateAddHTLC_free(this_obj_conv);
23737 }
23738
23739 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
23740         LDKUpdateAddHTLC this_ptr_conv;
23741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23742         this_ptr_conv.is_owned = false;
23743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23744         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23745         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
23746         return ret_arr;
23747 }
23748
23749 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23750         LDKUpdateAddHTLC this_ptr_conv;
23751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23752         this_ptr_conv.is_owned = false;
23753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23754         LDKThirtyTwoBytes val_ref;
23755         CHECK(*((uint32_t*)val) == 32);
23756         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
23757         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
23758 }
23759
23760 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
23761         LDKUpdateAddHTLC this_ptr_conv;
23762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23763         this_ptr_conv.is_owned = false;
23764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23765         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
23766         return ret_val;
23767 }
23768
23769 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
23770         LDKUpdateAddHTLC this_ptr_conv;
23771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23772         this_ptr_conv.is_owned = false;
23773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23774         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
23775 }
23776
23777 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
23778         LDKUpdateAddHTLC this_ptr_conv;
23779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23780         this_ptr_conv.is_owned = false;
23781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23782         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
23783         return ret_val;
23784 }
23785
23786 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
23787         LDKUpdateAddHTLC this_ptr_conv;
23788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23789         this_ptr_conv.is_owned = false;
23790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23791         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
23792 }
23793
23794 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
23795         LDKUpdateAddHTLC this_ptr_conv;
23796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23797         this_ptr_conv.is_owned = false;
23798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23799         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23800         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
23801         return ret_arr;
23802 }
23803
23804 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
23805         LDKUpdateAddHTLC this_ptr_conv;
23806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23807         this_ptr_conv.is_owned = false;
23808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23809         LDKThirtyTwoBytes val_ref;
23810         CHECK(*((uint32_t*)val) == 32);
23811         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
23812         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
23813 }
23814
23815 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
23816         LDKUpdateAddHTLC this_ptr_conv;
23817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23818         this_ptr_conv.is_owned = false;
23819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23820         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
23821         return ret_val;
23822 }
23823
23824 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
23825         LDKUpdateAddHTLC this_ptr_conv;
23826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23827         this_ptr_conv.is_owned = false;
23828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23829         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
23830 }
23831
23832 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
23833         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
23834 uint64_t ret_ref = 0;
23835 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23836 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23837 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23838 ret_ref = (uint64_t)ret_var.inner;
23839 if (ret_var.is_owned) {
23840         ret_ref |= 1;
23841 }
23842         return ret_ref;
23843 }
23844 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
23845         LDKUpdateAddHTLC arg_conv;
23846         arg_conv.inner = (void*)(arg & (~1));
23847         arg_conv.is_owned = false;
23848         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23849         int64_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
23850         return ret_val;
23851 }
23852
23853 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
23854         LDKUpdateAddHTLC orig_conv;
23855         orig_conv.inner = (void*)(orig & (~1));
23856         orig_conv.is_owned = false;
23857         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23858         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
23859         uint64_t ret_ref = 0;
23860         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23861         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23863         ret_ref = (uint64_t)ret_var.inner;
23864         if (ret_var.is_owned) {
23865                 ret_ref |= 1;
23866         }
23867         return ret_ref;
23868 }
23869
23870 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
23871         LDKUpdateFulfillHTLC this_obj_conv;
23872         this_obj_conv.inner = (void*)(this_obj & (~1));
23873         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23875         UpdateFulfillHTLC_free(this_obj_conv);
23876 }
23877
23878 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
23879         LDKUpdateFulfillHTLC this_ptr_conv;
23880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23881         this_ptr_conv.is_owned = false;
23882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23883         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23884         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
23885         return ret_arr;
23886 }
23887
23888 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23889         LDKUpdateFulfillHTLC this_ptr_conv;
23890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23891         this_ptr_conv.is_owned = false;
23892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23893         LDKThirtyTwoBytes val_ref;
23894         CHECK(*((uint32_t*)val) == 32);
23895         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
23896         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
23897 }
23898
23899 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
23900         LDKUpdateFulfillHTLC this_ptr_conv;
23901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23902         this_ptr_conv.is_owned = false;
23903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23904         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
23905         return ret_val;
23906 }
23907
23908 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
23909         LDKUpdateFulfillHTLC this_ptr_conv;
23910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23911         this_ptr_conv.is_owned = false;
23912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23913         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
23914 }
23915
23916 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
23917         LDKUpdateFulfillHTLC this_ptr_conv;
23918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23919         this_ptr_conv.is_owned = false;
23920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23921         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23922         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
23923         return ret_arr;
23924 }
23925
23926 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
23927         LDKUpdateFulfillHTLC this_ptr_conv;
23928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23929         this_ptr_conv.is_owned = false;
23930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23931         LDKThirtyTwoBytes val_ref;
23932         CHECK(*((uint32_t*)val) == 32);
23933         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
23934         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
23935 }
23936
23937 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
23938         LDKThirtyTwoBytes channel_id_arg_ref;
23939         CHECK(*((uint32_t*)channel_id_arg) == 32);
23940         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
23941         LDKThirtyTwoBytes payment_preimage_arg_ref;
23942         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
23943         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
23944         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
23945         uint64_t ret_ref = 0;
23946         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23947         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23949         ret_ref = (uint64_t)ret_var.inner;
23950         if (ret_var.is_owned) {
23951                 ret_ref |= 1;
23952         }
23953         return ret_ref;
23954 }
23955
23956 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
23957         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
23958 uint64_t ret_ref = 0;
23959 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23960 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23961 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23962 ret_ref = (uint64_t)ret_var.inner;
23963 if (ret_var.is_owned) {
23964         ret_ref |= 1;
23965 }
23966         return ret_ref;
23967 }
23968 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
23969         LDKUpdateFulfillHTLC arg_conv;
23970         arg_conv.inner = (void*)(arg & (~1));
23971         arg_conv.is_owned = false;
23972         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23973         int64_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
23974         return ret_val;
23975 }
23976
23977 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
23978         LDKUpdateFulfillHTLC orig_conv;
23979         orig_conv.inner = (void*)(orig & (~1));
23980         orig_conv.is_owned = false;
23981         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23982         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
23983         uint64_t ret_ref = 0;
23984         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23985         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23987         ret_ref = (uint64_t)ret_var.inner;
23988         if (ret_var.is_owned) {
23989                 ret_ref |= 1;
23990         }
23991         return ret_ref;
23992 }
23993
23994 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
23995         LDKUpdateFailHTLC this_obj_conv;
23996         this_obj_conv.inner = (void*)(this_obj & (~1));
23997         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23999         UpdateFailHTLC_free(this_obj_conv);
24000 }
24001
24002 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
24003         LDKUpdateFailHTLC this_ptr_conv;
24004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24005         this_ptr_conv.is_owned = false;
24006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24007         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24008         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
24009         return ret_arr;
24010 }
24011
24012 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24013         LDKUpdateFailHTLC this_ptr_conv;
24014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24015         this_ptr_conv.is_owned = false;
24016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24017         LDKThirtyTwoBytes val_ref;
24018         CHECK(*((uint32_t*)val) == 32);
24019         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24020         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
24021 }
24022
24023 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
24024         LDKUpdateFailHTLC this_ptr_conv;
24025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24026         this_ptr_conv.is_owned = false;
24027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24028         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
24029         return ret_val;
24030 }
24031
24032 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24033         LDKUpdateFailHTLC this_ptr_conv;
24034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24035         this_ptr_conv.is_owned = false;
24036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24037         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
24038 }
24039
24040 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
24041         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
24042 uint64_t ret_ref = 0;
24043 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24044 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24045 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24046 ret_ref = (uint64_t)ret_var.inner;
24047 if (ret_var.is_owned) {
24048         ret_ref |= 1;
24049 }
24050         return ret_ref;
24051 }
24052 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
24053         LDKUpdateFailHTLC arg_conv;
24054         arg_conv.inner = (void*)(arg & (~1));
24055         arg_conv.is_owned = false;
24056         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24057         int64_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
24058         return ret_val;
24059 }
24060
24061 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
24062         LDKUpdateFailHTLC orig_conv;
24063         orig_conv.inner = (void*)(orig & (~1));
24064         orig_conv.is_owned = false;
24065         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24066         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
24067         uint64_t ret_ref = 0;
24068         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24069         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24071         ret_ref = (uint64_t)ret_var.inner;
24072         if (ret_var.is_owned) {
24073                 ret_ref |= 1;
24074         }
24075         return ret_ref;
24076 }
24077
24078 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
24079         LDKUpdateFailMalformedHTLC this_obj_conv;
24080         this_obj_conv.inner = (void*)(this_obj & (~1));
24081         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24083         UpdateFailMalformedHTLC_free(this_obj_conv);
24084 }
24085
24086 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
24087         LDKUpdateFailMalformedHTLC this_ptr_conv;
24088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24089         this_ptr_conv.is_owned = false;
24090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24091         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24092         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
24093         return ret_arr;
24094 }
24095
24096 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24097         LDKUpdateFailMalformedHTLC this_ptr_conv;
24098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24099         this_ptr_conv.is_owned = false;
24100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24101         LDKThirtyTwoBytes val_ref;
24102         CHECK(*((uint32_t*)val) == 32);
24103         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24104         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
24105 }
24106
24107 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
24108         LDKUpdateFailMalformedHTLC this_ptr_conv;
24109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24110         this_ptr_conv.is_owned = false;
24111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24112         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
24113         return ret_val;
24114 }
24115
24116 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24117         LDKUpdateFailMalformedHTLC this_ptr_conv;
24118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24119         this_ptr_conv.is_owned = false;
24120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24121         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
24122 }
24123
24124 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
24125         LDKUpdateFailMalformedHTLC this_ptr_conv;
24126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24127         this_ptr_conv.is_owned = false;
24128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24129         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
24130         return ret_val;
24131 }
24132
24133 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
24134         LDKUpdateFailMalformedHTLC this_ptr_conv;
24135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24136         this_ptr_conv.is_owned = false;
24137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24138         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
24139 }
24140
24141 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
24142         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
24143 uint64_t ret_ref = 0;
24144 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24145 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24146 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24147 ret_ref = (uint64_t)ret_var.inner;
24148 if (ret_var.is_owned) {
24149         ret_ref |= 1;
24150 }
24151         return ret_ref;
24152 }
24153 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
24154         LDKUpdateFailMalformedHTLC arg_conv;
24155         arg_conv.inner = (void*)(arg & (~1));
24156         arg_conv.is_owned = false;
24157         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24158         int64_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
24159         return ret_val;
24160 }
24161
24162 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
24163         LDKUpdateFailMalformedHTLC orig_conv;
24164         orig_conv.inner = (void*)(orig & (~1));
24165         orig_conv.is_owned = false;
24166         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24167         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
24168         uint64_t ret_ref = 0;
24169         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24170         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24172         ret_ref = (uint64_t)ret_var.inner;
24173         if (ret_var.is_owned) {
24174                 ret_ref |= 1;
24175         }
24176         return ret_ref;
24177 }
24178
24179 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_obj) {
24180         LDKCommitmentSigned this_obj_conv;
24181         this_obj_conv.inner = (void*)(this_obj & (~1));
24182         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24184         CommitmentSigned_free(this_obj_conv);
24185 }
24186
24187 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
24188         LDKCommitmentSigned this_ptr_conv;
24189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24190         this_ptr_conv.is_owned = false;
24191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24192         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24193         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
24194         return ret_arr;
24195 }
24196
24197 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24198         LDKCommitmentSigned 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         LDKThirtyTwoBytes val_ref;
24203         CHECK(*((uint32_t*)val) == 32);
24204         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24205         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
24206 }
24207
24208 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
24209         LDKCommitmentSigned this_ptr_conv;
24210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24211         this_ptr_conv.is_owned = false;
24212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24213         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
24214         memcpy((uint8_t*)(ret_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
24215         return ret_arr;
24216 }
24217
24218 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
24219         LDKCommitmentSigned this_ptr_conv;
24220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24221         this_ptr_conv.is_owned = false;
24222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24223         LDKSignature val_ref;
24224         CHECK(*((uint32_t*)val) == 64);
24225         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
24226         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
24227 }
24228
24229 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
24230         LDKCommitmentSigned this_ptr_conv;
24231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24232         this_ptr_conv.is_owned = false;
24233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24234         LDKCVec_SignatureZ val_constr;
24235         val_constr.datalen = *((uint32_t*)val);
24236         if (val_constr.datalen > 0)
24237                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
24238         else
24239                 val_constr.data = NULL;
24240         int8_tArray* val_vals = (int8_tArray*)(val + 4);
24241         for (size_t m = 0; m < val_constr.datalen; m++) {
24242                 int8_tArray val_conv_12 = val_vals[m];
24243                 LDKSignature val_conv_12_ref;
24244                 CHECK(*((uint32_t*)val_conv_12) == 64);
24245                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
24246                 val_constr.data[m] = val_conv_12_ref;
24247         }
24248         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
24249 }
24250
24251 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
24252         LDKThirtyTwoBytes channel_id_arg_ref;
24253         CHECK(*((uint32_t*)channel_id_arg) == 32);
24254         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
24255         LDKSignature signature_arg_ref;
24256         CHECK(*((uint32_t*)signature_arg) == 64);
24257         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
24258         LDKCVec_SignatureZ htlc_signatures_arg_constr;
24259         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
24260         if (htlc_signatures_arg_constr.datalen > 0)
24261                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
24262         else
24263                 htlc_signatures_arg_constr.data = NULL;
24264         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
24265         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
24266                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
24267                 LDKSignature htlc_signatures_arg_conv_12_ref;
24268                 CHECK(*((uint32_t*)htlc_signatures_arg_conv_12) == 64);
24269                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, (uint8_t*)(htlc_signatures_arg_conv_12 + 4), 64);
24270                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
24271         }
24272         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
24273         uint64_t ret_ref = 0;
24274         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24275         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24277         ret_ref = (uint64_t)ret_var.inner;
24278         if (ret_var.is_owned) {
24279                 ret_ref |= 1;
24280         }
24281         return ret_ref;
24282 }
24283
24284 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
24285         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
24286 uint64_t ret_ref = 0;
24287 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24288 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24289 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24290 ret_ref = (uint64_t)ret_var.inner;
24291 if (ret_var.is_owned) {
24292         ret_ref |= 1;
24293 }
24294         return ret_ref;
24295 }
24296 int64_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
24297         LDKCommitmentSigned arg_conv;
24298         arg_conv.inner = (void*)(arg & (~1));
24299         arg_conv.is_owned = false;
24300         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24301         int64_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
24302         return ret_val;
24303 }
24304
24305 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
24306         LDKCommitmentSigned orig_conv;
24307         orig_conv.inner = (void*)(orig & (~1));
24308         orig_conv.is_owned = false;
24309         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24310         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
24311         uint64_t ret_ref = 0;
24312         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24313         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24315         ret_ref = (uint64_t)ret_var.inner;
24316         if (ret_var.is_owned) {
24317                 ret_ref |= 1;
24318         }
24319         return ret_ref;
24320 }
24321
24322 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_obj) {
24323         LDKRevokeAndACK this_obj_conv;
24324         this_obj_conv.inner = (void*)(this_obj & (~1));
24325         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24327         RevokeAndACK_free(this_obj_conv);
24328 }
24329
24330 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
24331         LDKRevokeAndACK this_ptr_conv;
24332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24333         this_ptr_conv.is_owned = false;
24334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24335         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24336         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
24337         return ret_arr;
24338 }
24339
24340 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24341         LDKRevokeAndACK this_ptr_conv;
24342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24343         this_ptr_conv.is_owned = false;
24344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24345         LDKThirtyTwoBytes val_ref;
24346         CHECK(*((uint32_t*)val) == 32);
24347         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24348         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
24349 }
24350
24351 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
24352         LDKRevokeAndACK this_ptr_conv;
24353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24354         this_ptr_conv.is_owned = false;
24355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24356         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24357         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
24358         return ret_arr;
24359 }
24360
24361 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
24362         LDKRevokeAndACK this_ptr_conv;
24363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24364         this_ptr_conv.is_owned = false;
24365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24366         LDKThirtyTwoBytes val_ref;
24367         CHECK(*((uint32_t*)val) == 32);
24368         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24369         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
24370 }
24371
24372 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
24373         LDKRevokeAndACK this_ptr_conv;
24374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24375         this_ptr_conv.is_owned = false;
24376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24377         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
24378         memcpy((uint8_t*)(ret_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
24379         return ret_arr;
24380 }
24381
24382 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
24383         LDKRevokeAndACK this_ptr_conv;
24384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24385         this_ptr_conv.is_owned = false;
24386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24387         LDKPublicKey val_ref;
24388         CHECK(*((uint32_t*)val) == 33);
24389         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
24390         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
24391 }
24392
24393 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_new(int8_tArray channel_id_arg, int8_tArray per_commitment_secret_arg, int8_tArray next_per_commitment_point_arg) {
24394         LDKThirtyTwoBytes channel_id_arg_ref;
24395         CHECK(*((uint32_t*)channel_id_arg) == 32);
24396         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
24397         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
24398         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
24399         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
24400         LDKPublicKey next_per_commitment_point_arg_ref;
24401         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
24402         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
24403         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
24404         uint64_t ret_ref = 0;
24405         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24406         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24408         ret_ref = (uint64_t)ret_var.inner;
24409         if (ret_var.is_owned) {
24410                 ret_ref |= 1;
24411         }
24412         return ret_ref;
24413 }
24414
24415 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
24416         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
24417 uint64_t ret_ref = 0;
24418 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24419 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24420 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24421 ret_ref = (uint64_t)ret_var.inner;
24422 if (ret_var.is_owned) {
24423         ret_ref |= 1;
24424 }
24425         return ret_ref;
24426 }
24427 int64_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
24428         LDKRevokeAndACK arg_conv;
24429         arg_conv.inner = (void*)(arg & (~1));
24430         arg_conv.is_owned = false;
24431         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24432         int64_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
24433         return ret_val;
24434 }
24435
24436 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
24437         LDKRevokeAndACK orig_conv;
24438         orig_conv.inner = (void*)(orig & (~1));
24439         orig_conv.is_owned = false;
24440         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24441         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
24442         uint64_t ret_ref = 0;
24443         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24444         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24446         ret_ref = (uint64_t)ret_var.inner;
24447         if (ret_var.is_owned) {
24448                 ret_ref |= 1;
24449         }
24450         return ret_ref;
24451 }
24452
24453 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_obj) {
24454         LDKUpdateFee this_obj_conv;
24455         this_obj_conv.inner = (void*)(this_obj & (~1));
24456         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24458         UpdateFee_free(this_obj_conv);
24459 }
24460
24461 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
24462         LDKUpdateFee this_ptr_conv;
24463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24464         this_ptr_conv.is_owned = false;
24465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24466         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24467         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
24468         return ret_arr;
24469 }
24470
24471 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24472         LDKUpdateFee this_ptr_conv;
24473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24474         this_ptr_conv.is_owned = false;
24475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24476         LDKThirtyTwoBytes val_ref;
24477         CHECK(*((uint32_t*)val) == 32);
24478         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24479         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
24480 }
24481
24482 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
24483         LDKUpdateFee this_ptr_conv;
24484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24485         this_ptr_conv.is_owned = false;
24486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24487         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
24488         return ret_val;
24489 }
24490
24491 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
24492         LDKUpdateFee this_ptr_conv;
24493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24494         this_ptr_conv.is_owned = false;
24495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24496         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
24497 }
24498
24499 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
24500         LDKThirtyTwoBytes channel_id_arg_ref;
24501         CHECK(*((uint32_t*)channel_id_arg) == 32);
24502         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
24503         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
24504         uint64_t ret_ref = 0;
24505         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24506         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24508         ret_ref = (uint64_t)ret_var.inner;
24509         if (ret_var.is_owned) {
24510                 ret_ref |= 1;
24511         }
24512         return ret_ref;
24513 }
24514
24515 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
24516         LDKUpdateFee ret_var = UpdateFee_clone(arg);
24517 uint64_t ret_ref = 0;
24518 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24519 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24520 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24521 ret_ref = (uint64_t)ret_var.inner;
24522 if (ret_var.is_owned) {
24523         ret_ref |= 1;
24524 }
24525         return ret_ref;
24526 }
24527 int64_t  __attribute__((visibility("default"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
24528         LDKUpdateFee arg_conv;
24529         arg_conv.inner = (void*)(arg & (~1));
24530         arg_conv.is_owned = false;
24531         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24532         int64_t ret_val = UpdateFee_clone_ptr(&arg_conv);
24533         return ret_val;
24534 }
24535
24536 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
24537         LDKUpdateFee orig_conv;
24538         orig_conv.inner = (void*)(orig & (~1));
24539         orig_conv.is_owned = false;
24540         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24541         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
24542         uint64_t ret_ref = 0;
24543         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24544         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24546         ret_ref = (uint64_t)ret_var.inner;
24547         if (ret_var.is_owned) {
24548                 ret_ref |= 1;
24549         }
24550         return ret_ref;
24551 }
24552
24553 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_obj) {
24554         LDKDataLossProtect this_obj_conv;
24555         this_obj_conv.inner = (void*)(this_obj & (~1));
24556         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24558         DataLossProtect_free(this_obj_conv);
24559 }
24560
24561 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
24562         LDKDataLossProtect this_ptr_conv;
24563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24564         this_ptr_conv.is_owned = false;
24565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24566         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24567         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
24568         return ret_arr;
24569 }
24570
24571 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
24572         LDKDataLossProtect this_ptr_conv;
24573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24574         this_ptr_conv.is_owned = false;
24575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24576         LDKThirtyTwoBytes val_ref;
24577         CHECK(*((uint32_t*)val) == 32);
24578         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24579         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
24580 }
24581
24582 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
24583         LDKDataLossProtect this_ptr_conv;
24584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24585         this_ptr_conv.is_owned = false;
24586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24587         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
24588         memcpy((uint8_t*)(ret_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
24589         return ret_arr;
24590 }
24591
24592 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
24593         LDKDataLossProtect this_ptr_conv;
24594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24595         this_ptr_conv.is_owned = false;
24596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24597         LDKPublicKey val_ref;
24598         CHECK(*((uint32_t*)val) == 33);
24599         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
24600         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
24601 }
24602
24603 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
24604         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
24605         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
24606         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
24607         LDKPublicKey my_current_per_commitment_point_arg_ref;
24608         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
24609         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
24610         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
24611         uint64_t ret_ref = 0;
24612         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24613         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24615         ret_ref = (uint64_t)ret_var.inner;
24616         if (ret_var.is_owned) {
24617                 ret_ref |= 1;
24618         }
24619         return ret_ref;
24620 }
24621
24622 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
24623         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
24624 uint64_t ret_ref = 0;
24625 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24626 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24627 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24628 ret_ref = (uint64_t)ret_var.inner;
24629 if (ret_var.is_owned) {
24630         ret_ref |= 1;
24631 }
24632         return ret_ref;
24633 }
24634 int64_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
24635         LDKDataLossProtect arg_conv;
24636         arg_conv.inner = (void*)(arg & (~1));
24637         arg_conv.is_owned = false;
24638         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24639         int64_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
24640         return ret_val;
24641 }
24642
24643 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
24644         LDKDataLossProtect orig_conv;
24645         orig_conv.inner = (void*)(orig & (~1));
24646         orig_conv.is_owned = false;
24647         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24648         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
24649         uint64_t ret_ref = 0;
24650         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24651         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24653         ret_ref = (uint64_t)ret_var.inner;
24654         if (ret_var.is_owned) {
24655                 ret_ref |= 1;
24656         }
24657         return ret_ref;
24658 }
24659
24660 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_obj) {
24661         LDKChannelReestablish this_obj_conv;
24662         this_obj_conv.inner = (void*)(this_obj & (~1));
24663         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24665         ChannelReestablish_free(this_obj_conv);
24666 }
24667
24668 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
24669         LDKChannelReestablish this_ptr_conv;
24670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24671         this_ptr_conv.is_owned = false;
24672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24673         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24674         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
24675         return ret_arr;
24676 }
24677
24678 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24679         LDKChannelReestablish this_ptr_conv;
24680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24681         this_ptr_conv.is_owned = false;
24682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24683         LDKThirtyTwoBytes val_ref;
24684         CHECK(*((uint32_t*)val) == 32);
24685         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24686         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
24687 }
24688
24689 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
24690         LDKChannelReestablish this_ptr_conv;
24691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24692         this_ptr_conv.is_owned = false;
24693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24694         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
24695         return ret_val;
24696 }
24697
24698 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
24699         LDKChannelReestablish this_ptr_conv;
24700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24701         this_ptr_conv.is_owned = false;
24702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24703         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
24704 }
24705
24706 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
24707         LDKChannelReestablish this_ptr_conv;
24708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24709         this_ptr_conv.is_owned = false;
24710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24711         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
24712         return ret_val;
24713 }
24714
24715 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
24716         LDKChannelReestablish this_ptr_conv;
24717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24718         this_ptr_conv.is_owned = false;
24719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24720         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
24721 }
24722
24723 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
24724         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
24725 uint64_t ret_ref = 0;
24726 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24727 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24728 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24729 ret_ref = (uint64_t)ret_var.inner;
24730 if (ret_var.is_owned) {
24731         ret_ref |= 1;
24732 }
24733         return ret_ref;
24734 }
24735 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
24736         LDKChannelReestablish arg_conv;
24737         arg_conv.inner = (void*)(arg & (~1));
24738         arg_conv.is_owned = false;
24739         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24740         int64_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
24741         return ret_val;
24742 }
24743
24744 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
24745         LDKChannelReestablish orig_conv;
24746         orig_conv.inner = (void*)(orig & (~1));
24747         orig_conv.is_owned = false;
24748         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24749         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
24750         uint64_t ret_ref = 0;
24751         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24752         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24754         ret_ref = (uint64_t)ret_var.inner;
24755         if (ret_var.is_owned) {
24756                 ret_ref |= 1;
24757         }
24758         return ret_ref;
24759 }
24760
24761 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
24762         LDKAnnouncementSignatures this_obj_conv;
24763         this_obj_conv.inner = (void*)(this_obj & (~1));
24764         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24766         AnnouncementSignatures_free(this_obj_conv);
24767 }
24768
24769 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
24770         LDKAnnouncementSignatures this_ptr_conv;
24771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24772         this_ptr_conv.is_owned = false;
24773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24774         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24775         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
24776         return ret_arr;
24777 }
24778
24779 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24780         LDKAnnouncementSignatures this_ptr_conv;
24781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24782         this_ptr_conv.is_owned = false;
24783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24784         LDKThirtyTwoBytes val_ref;
24785         CHECK(*((uint32_t*)val) == 32);
24786         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24787         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
24788 }
24789
24790 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
24791         LDKAnnouncementSignatures this_ptr_conv;
24792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24793         this_ptr_conv.is_owned = false;
24794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24795         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
24796         return ret_val;
24797 }
24798
24799 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
24800         LDKAnnouncementSignatures this_ptr_conv;
24801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24802         this_ptr_conv.is_owned = false;
24803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24804         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
24805 }
24806
24807 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
24808         LDKAnnouncementSignatures this_ptr_conv;
24809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24810         this_ptr_conv.is_owned = false;
24811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24812         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
24813         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
24814         return ret_arr;
24815 }
24816
24817 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
24818         LDKAnnouncementSignatures this_ptr_conv;
24819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24820         this_ptr_conv.is_owned = false;
24821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24822         LDKSignature val_ref;
24823         CHECK(*((uint32_t*)val) == 64);
24824         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
24825         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
24826 }
24827
24828 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
24829         LDKAnnouncementSignatures this_ptr_conv;
24830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24831         this_ptr_conv.is_owned = false;
24832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24833         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
24834         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
24835         return ret_arr;
24836 }
24837
24838 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
24839         LDKAnnouncementSignatures this_ptr_conv;
24840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24841         this_ptr_conv.is_owned = false;
24842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24843         LDKSignature val_ref;
24844         CHECK(*((uint32_t*)val) == 64);
24845         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
24846         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
24847 }
24848
24849 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_new(int8_tArray channel_id_arg, int64_t short_channel_id_arg, int8_tArray node_signature_arg, int8_tArray bitcoin_signature_arg) {
24850         LDKThirtyTwoBytes channel_id_arg_ref;
24851         CHECK(*((uint32_t*)channel_id_arg) == 32);
24852         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
24853         LDKSignature node_signature_arg_ref;
24854         CHECK(*((uint32_t*)node_signature_arg) == 64);
24855         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
24856         LDKSignature bitcoin_signature_arg_ref;
24857         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
24858         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
24859         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
24860         uint64_t ret_ref = 0;
24861         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24862         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24864         ret_ref = (uint64_t)ret_var.inner;
24865         if (ret_var.is_owned) {
24866                 ret_ref |= 1;
24867         }
24868         return ret_ref;
24869 }
24870
24871 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
24872         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
24873 uint64_t ret_ref = 0;
24874 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24875 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24876 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24877 ret_ref = (uint64_t)ret_var.inner;
24878 if (ret_var.is_owned) {
24879         ret_ref |= 1;
24880 }
24881         return ret_ref;
24882 }
24883 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
24884         LDKAnnouncementSignatures arg_conv;
24885         arg_conv.inner = (void*)(arg & (~1));
24886         arg_conv.is_owned = false;
24887         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24888         int64_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
24889         return ret_val;
24890 }
24891
24892 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
24893         LDKAnnouncementSignatures orig_conv;
24894         orig_conv.inner = (void*)(orig & (~1));
24895         orig_conv.is_owned = false;
24896         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24897         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
24898         uint64_t ret_ref = 0;
24899         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24900         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24902         ret_ref = (uint64_t)ret_var.inner;
24903         if (ret_var.is_owned) {
24904                 ret_ref |= 1;
24905         }
24906         return ret_ref;
24907 }
24908
24909 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
24910         if ((this_ptr & 1) != 0) return;
24911         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
24912         CHECK_ACCESS(this_ptr_ptr);
24913         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
24914         FREE((void*)this_ptr);
24915         NetAddress_free(this_ptr_conv);
24916 }
24917
24918 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
24919         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
24920         *ret_copy = NetAddress_clone(arg);
24921 uint64_t ret_ref = (uint64_t)ret_copy;
24922         return ret_ref;
24923 }
24924 int64_t  __attribute__((visibility("default"))) TS_NetAddress_clone_ptr(uint32_t arg) {
24925         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
24926         int64_t ret_val = NetAddress_clone_ptr(arg_conv);
24927         return ret_val;
24928 }
24929
24930 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
24931         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
24932         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
24933         *ret_copy = NetAddress_clone(orig_conv);
24934         uint64_t ret_ref = (uint64_t)ret_copy;
24935         return ret_ref;
24936 }
24937
24938 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
24939         LDKFourBytes addr_ref;
24940         CHECK(*((uint32_t*)addr) == 4);
24941         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 4);
24942         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
24943         *ret_copy = NetAddress_ipv4(addr_ref, port);
24944         uint64_t ret_ref = (uint64_t)ret_copy;
24945         return ret_ref;
24946 }
24947
24948 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
24949         LDKSixteenBytes addr_ref;
24950         CHECK(*((uint32_t*)addr) == 16);
24951         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 16);
24952         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
24953         *ret_copy = NetAddress_ipv6(addr_ref, port);
24954         uint64_t ret_ref = (uint64_t)ret_copy;
24955         return ret_ref;
24956 }
24957
24958 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_onion_v2(int8_tArray addr, int16_t port) {
24959         LDKTenBytes addr_ref;
24960         CHECK(*((uint32_t*)addr) == 10);
24961         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 10);
24962         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
24963         *ret_copy = NetAddress_onion_v2(addr_ref, port);
24964         uint64_t ret_ref = (uint64_t)ret_copy;
24965         return ret_ref;
24966 }
24967
24968 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_onion_v3(int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
24969         LDKThirtyTwoBytes ed25519_pubkey_ref;
24970         CHECK(*((uint32_t*)ed25519_pubkey) == 32);
24971         memcpy(ed25519_pubkey_ref.data, (uint8_t*)(ed25519_pubkey + 4), 32);
24972         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
24973         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
24974         uint64_t ret_ref = (uint64_t)ret_copy;
24975         return ret_ref;
24976 }
24977
24978 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
24979         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
24980         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
24981         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24982         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24983         CVec_u8Z_free(ret_var);
24984         return ret_arr;
24985 }
24986
24987 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_read(int8_tArray ser) {
24988         LDKu8slice ser_ref;
24989         ser_ref.datalen = *((uint32_t*)ser);
24990         ser_ref.data = (int8_t*)(ser + 4);
24991         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
24992         *ret_conv = NetAddress_read(ser_ref);
24993         return (uint64_t)ret_conv;
24994 }
24995
24996 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
24997         LDKUnsignedNodeAnnouncement this_obj_conv;
24998         this_obj_conv.inner = (void*)(this_obj & (~1));
24999         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25001         UnsignedNodeAnnouncement_free(this_obj_conv);
25002 }
25003
25004 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
25005         LDKUnsignedNodeAnnouncement this_ptr_conv;
25006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25007         this_ptr_conv.is_owned = false;
25008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25009         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
25010         uint64_t ret_ref = 0;
25011         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25012         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25014         ret_ref = (uint64_t)ret_var.inner;
25015         if (ret_var.is_owned) {
25016                 ret_ref |= 1;
25017         }
25018         return ret_ref;
25019 }
25020
25021 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
25022         LDKUnsignedNodeAnnouncement this_ptr_conv;
25023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25024         this_ptr_conv.is_owned = false;
25025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25026         LDKNodeFeatures val_conv;
25027         val_conv.inner = (void*)(val & (~1));
25028         val_conv.is_owned = (val & 1) || (val == 0);
25029         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25030         val_conv = NodeFeatures_clone(&val_conv);
25031         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
25032 }
25033
25034 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
25035         LDKUnsignedNodeAnnouncement this_ptr_conv;
25036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25037         this_ptr_conv.is_owned = false;
25038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25039         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
25040         return ret_val;
25041 }
25042
25043 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
25044         LDKUnsignedNodeAnnouncement this_ptr_conv;
25045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25046         this_ptr_conv.is_owned = false;
25047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25048         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
25049 }
25050
25051 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
25052         LDKUnsignedNodeAnnouncement this_ptr_conv;
25053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25054         this_ptr_conv.is_owned = false;
25055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25056         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
25057         memcpy((uint8_t*)(ret_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
25058         return ret_arr;
25059 }
25060
25061 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
25062         LDKUnsignedNodeAnnouncement this_ptr_conv;
25063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25064         this_ptr_conv.is_owned = false;
25065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25066         LDKPublicKey val_ref;
25067         CHECK(*((uint32_t*)val) == 33);
25068         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
25069         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
25070 }
25071
25072 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
25073         LDKUnsignedNodeAnnouncement this_ptr_conv;
25074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25075         this_ptr_conv.is_owned = false;
25076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25077         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
25078         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
25079         return ret_arr;
25080 }
25081
25082 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
25083         LDKUnsignedNodeAnnouncement this_ptr_conv;
25084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25085         this_ptr_conv.is_owned = false;
25086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25087         LDKThreeBytes val_ref;
25088         CHECK(*((uint32_t*)val) == 3);
25089         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
25090         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
25091 }
25092
25093 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
25094         LDKUnsignedNodeAnnouncement this_ptr_conv;
25095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25096         this_ptr_conv.is_owned = false;
25097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25098         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25099         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
25100         return ret_arr;
25101 }
25102
25103 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
25104         LDKUnsignedNodeAnnouncement this_ptr_conv;
25105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25106         this_ptr_conv.is_owned = false;
25107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25108         LDKThirtyTwoBytes val_ref;
25109         CHECK(*((uint32_t*)val) == 32);
25110         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
25111         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
25112 }
25113
25114 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
25115         LDKUnsignedNodeAnnouncement this_ptr_conv;
25116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25117         this_ptr_conv.is_owned = false;
25118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25119         LDKCVec_NetAddressZ val_constr;
25120         val_constr.datalen = *((uint32_t*)val);
25121         if (val_constr.datalen > 0)
25122                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25123         else
25124                 val_constr.data = NULL;
25125         uint32_t* val_vals = (uint32_t*)(val + 4);
25126         for (size_t m = 0; m < val_constr.datalen; m++) {
25127                 uint32_t val_conv_12 = val_vals[m];
25128                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
25129                 CHECK_ACCESS(val_conv_12_ptr);
25130                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
25131                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
25132                 val_constr.data[m] = val_conv_12_conv;
25133         }
25134         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
25135 }
25136
25137 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
25138         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
25139 uint64_t ret_ref = 0;
25140 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25141 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25142 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25143 ret_ref = (uint64_t)ret_var.inner;
25144 if (ret_var.is_owned) {
25145         ret_ref |= 1;
25146 }
25147         return ret_ref;
25148 }
25149 int64_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
25150         LDKUnsignedNodeAnnouncement arg_conv;
25151         arg_conv.inner = (void*)(arg & (~1));
25152         arg_conv.is_owned = false;
25153         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25154         int64_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
25155         return ret_val;
25156 }
25157
25158 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
25159         LDKUnsignedNodeAnnouncement orig_conv;
25160         orig_conv.inner = (void*)(orig & (~1));
25161         orig_conv.is_owned = false;
25162         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25163         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
25164         uint64_t ret_ref = 0;
25165         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25166         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25168         ret_ref = (uint64_t)ret_var.inner;
25169         if (ret_var.is_owned) {
25170                 ret_ref |= 1;
25171         }
25172         return ret_ref;
25173 }
25174
25175 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
25176         LDKNodeAnnouncement this_obj_conv;
25177         this_obj_conv.inner = (void*)(this_obj & (~1));
25178         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25180         NodeAnnouncement_free(this_obj_conv);
25181 }
25182
25183 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
25184         LDKNodeAnnouncement this_ptr_conv;
25185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25186         this_ptr_conv.is_owned = false;
25187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25188         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
25189         memcpy((uint8_t*)(ret_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
25190         return ret_arr;
25191 }
25192
25193 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
25194         LDKNodeAnnouncement this_ptr_conv;
25195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25196         this_ptr_conv.is_owned = false;
25197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25198         LDKSignature val_ref;
25199         CHECK(*((uint32_t*)val) == 64);
25200         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
25201         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
25202 }
25203
25204 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
25205         LDKNodeAnnouncement this_ptr_conv;
25206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25207         this_ptr_conv.is_owned = false;
25208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25209         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
25210         uint64_t ret_ref = 0;
25211         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25212         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25214         ret_ref = (uint64_t)ret_var.inner;
25215         if (ret_var.is_owned) {
25216                 ret_ref |= 1;
25217         }
25218         return ret_ref;
25219 }
25220
25221 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
25222         LDKNodeAnnouncement this_ptr_conv;
25223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25224         this_ptr_conv.is_owned = false;
25225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25226         LDKUnsignedNodeAnnouncement val_conv;
25227         val_conv.inner = (void*)(val & (~1));
25228         val_conv.is_owned = (val & 1) || (val == 0);
25229         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25230         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
25231         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
25232 }
25233
25234 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
25235         LDKSignature signature_arg_ref;
25236         CHECK(*((uint32_t*)signature_arg) == 64);
25237         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
25238         LDKUnsignedNodeAnnouncement contents_arg_conv;
25239         contents_arg_conv.inner = (void*)(contents_arg & (~1));
25240         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
25241         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
25242         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
25243         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
25244         uint64_t ret_ref = 0;
25245         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25246         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25248         ret_ref = (uint64_t)ret_var.inner;
25249         if (ret_var.is_owned) {
25250                 ret_ref |= 1;
25251         }
25252         return ret_ref;
25253 }
25254
25255 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
25256         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
25257 uint64_t ret_ref = 0;
25258 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25259 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25260 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25261 ret_ref = (uint64_t)ret_var.inner;
25262 if (ret_var.is_owned) {
25263         ret_ref |= 1;
25264 }
25265         return ret_ref;
25266 }
25267 int64_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
25268         LDKNodeAnnouncement arg_conv;
25269         arg_conv.inner = (void*)(arg & (~1));
25270         arg_conv.is_owned = false;
25271         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25272         int64_t ret_val = NodeAnnouncement_clone_ptr(&arg_conv);
25273         return ret_val;
25274 }
25275
25276 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint32_t orig) {
25277         LDKNodeAnnouncement orig_conv;
25278         orig_conv.inner = (void*)(orig & (~1));
25279         orig_conv.is_owned = false;
25280         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25281         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
25282         uint64_t ret_ref = 0;
25283         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25284         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25286         ret_ref = (uint64_t)ret_var.inner;
25287         if (ret_var.is_owned) {
25288                 ret_ref |= 1;
25289         }
25290         return ret_ref;
25291 }
25292
25293 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
25294         LDKUnsignedChannelAnnouncement this_obj_conv;
25295         this_obj_conv.inner = (void*)(this_obj & (~1));
25296         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25298         UnsignedChannelAnnouncement_free(this_obj_conv);
25299 }
25300
25301 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
25302         LDKUnsignedChannelAnnouncement this_ptr_conv;
25303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25304         this_ptr_conv.is_owned = false;
25305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25306         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
25307         uint64_t ret_ref = 0;
25308         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25309         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25311         ret_ref = (uint64_t)ret_var.inner;
25312         if (ret_var.is_owned) {
25313                 ret_ref |= 1;
25314         }
25315         return ret_ref;
25316 }
25317
25318 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
25319         LDKUnsignedChannelAnnouncement this_ptr_conv;
25320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25321         this_ptr_conv.is_owned = false;
25322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25323         LDKChannelFeatures val_conv;
25324         val_conv.inner = (void*)(val & (~1));
25325         val_conv.is_owned = (val & 1) || (val == 0);
25326         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25327         val_conv = ChannelFeatures_clone(&val_conv);
25328         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
25329 }
25330
25331 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
25332         LDKUnsignedChannelAnnouncement this_ptr_conv;
25333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25334         this_ptr_conv.is_owned = false;
25335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25336         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25337         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
25338         return ret_arr;
25339 }
25340
25341 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
25342         LDKUnsignedChannelAnnouncement this_ptr_conv;
25343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25344         this_ptr_conv.is_owned = false;
25345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25346         LDKThirtyTwoBytes val_ref;
25347         CHECK(*((uint32_t*)val) == 32);
25348         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
25349         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
25350 }
25351
25352 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
25353         LDKUnsignedChannelAnnouncement this_ptr_conv;
25354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25355         this_ptr_conv.is_owned = false;
25356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25357         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
25358         return ret_val;
25359 }
25360
25361 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
25362         LDKUnsignedChannelAnnouncement this_ptr_conv;
25363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25364         this_ptr_conv.is_owned = false;
25365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25366         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
25367 }
25368
25369 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
25370         LDKUnsignedChannelAnnouncement this_ptr_conv;
25371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25372         this_ptr_conv.is_owned = false;
25373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25374         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
25375         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
25376         return ret_arr;
25377 }
25378
25379 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
25380         LDKUnsignedChannelAnnouncement 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         LDKPublicKey val_ref;
25385         CHECK(*((uint32_t*)val) == 33);
25386         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
25387         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
25388 }
25389
25390 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
25391         LDKUnsignedChannelAnnouncement this_ptr_conv;
25392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25393         this_ptr_conv.is_owned = false;
25394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25395         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
25396         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
25397         return ret_arr;
25398 }
25399
25400 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
25401         LDKUnsignedChannelAnnouncement this_ptr_conv;
25402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25403         this_ptr_conv.is_owned = false;
25404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25405         LDKPublicKey val_ref;
25406         CHECK(*((uint32_t*)val) == 33);
25407         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
25408         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
25409 }
25410
25411 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
25412         LDKUnsignedChannelAnnouncement 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         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
25417         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
25418         return ret_arr;
25419 }
25420
25421 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
25422         LDKUnsignedChannelAnnouncement this_ptr_conv;
25423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25424         this_ptr_conv.is_owned = false;
25425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25426         LDKPublicKey val_ref;
25427         CHECK(*((uint32_t*)val) == 33);
25428         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
25429         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
25430 }
25431
25432 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
25433         LDKUnsignedChannelAnnouncement this_ptr_conv;
25434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25435         this_ptr_conv.is_owned = false;
25436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25437         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
25438         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
25439         return ret_arr;
25440 }
25441
25442 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
25443         LDKUnsignedChannelAnnouncement this_ptr_conv;
25444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25445         this_ptr_conv.is_owned = false;
25446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25447         LDKPublicKey val_ref;
25448         CHECK(*((uint32_t*)val) == 33);
25449         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
25450         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
25451 }
25452
25453 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
25454         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
25455 uint64_t ret_ref = 0;
25456 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25457 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25458 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25459 ret_ref = (uint64_t)ret_var.inner;
25460 if (ret_var.is_owned) {
25461         ret_ref |= 1;
25462 }
25463         return ret_ref;
25464 }
25465 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
25466         LDKUnsignedChannelAnnouncement arg_conv;
25467         arg_conv.inner = (void*)(arg & (~1));
25468         arg_conv.is_owned = false;
25469         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25470         int64_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
25471         return ret_val;
25472 }
25473
25474 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
25475         LDKUnsignedChannelAnnouncement orig_conv;
25476         orig_conv.inner = (void*)(orig & (~1));
25477         orig_conv.is_owned = false;
25478         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25479         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
25480         uint64_t ret_ref = 0;
25481         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25482         CHECK((((uint64_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 = (uint64_t)ret_var.inner;
25485         if (ret_var.is_owned) {
25486                 ret_ref |= 1;
25487         }
25488         return ret_ref;
25489 }
25490
25491 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
25492         LDKChannelAnnouncement this_obj_conv;
25493         this_obj_conv.inner = (void*)(this_obj & (~1));
25494         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25496         ChannelAnnouncement_free(this_obj_conv);
25497 }
25498
25499 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
25500         LDKChannelAnnouncement this_ptr_conv;
25501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25502         this_ptr_conv.is_owned = false;
25503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25504         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
25505         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
25506         return ret_arr;
25507 }
25508
25509 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
25510         LDKChannelAnnouncement this_ptr_conv;
25511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25512         this_ptr_conv.is_owned = false;
25513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25514         LDKSignature val_ref;
25515         CHECK(*((uint32_t*)val) == 64);
25516         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
25517         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
25518 }
25519
25520 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
25521         LDKChannelAnnouncement this_ptr_conv;
25522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25523         this_ptr_conv.is_owned = false;
25524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25525         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
25526         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
25527         return ret_arr;
25528 }
25529
25530 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
25531         LDKChannelAnnouncement this_ptr_conv;
25532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25533         this_ptr_conv.is_owned = false;
25534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25535         LDKSignature val_ref;
25536         CHECK(*((uint32_t*)val) == 64);
25537         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
25538         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
25539 }
25540
25541 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
25542         LDKChannelAnnouncement this_ptr_conv;
25543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25544         this_ptr_conv.is_owned = false;
25545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25546         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
25547         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
25548         return ret_arr;
25549 }
25550
25551 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
25552         LDKChannelAnnouncement this_ptr_conv;
25553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25554         this_ptr_conv.is_owned = false;
25555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25556         LDKSignature val_ref;
25557         CHECK(*((uint32_t*)val) == 64);
25558         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
25559         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
25560 }
25561
25562 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
25563         LDKChannelAnnouncement this_ptr_conv;
25564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25565         this_ptr_conv.is_owned = false;
25566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25567         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
25568         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
25569         return ret_arr;
25570 }
25571
25572 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
25573         LDKChannelAnnouncement this_ptr_conv;
25574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25575         this_ptr_conv.is_owned = false;
25576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25577         LDKSignature val_ref;
25578         CHECK(*((uint32_t*)val) == 64);
25579         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
25580         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
25581 }
25582
25583 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
25584         LDKChannelAnnouncement this_ptr_conv;
25585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25586         this_ptr_conv.is_owned = false;
25587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25588         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
25589         uint64_t ret_ref = 0;
25590         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25591         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25593         ret_ref = (uint64_t)ret_var.inner;
25594         if (ret_var.is_owned) {
25595                 ret_ref |= 1;
25596         }
25597         return ret_ref;
25598 }
25599
25600 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
25601         LDKChannelAnnouncement this_ptr_conv;
25602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25603         this_ptr_conv.is_owned = false;
25604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25605         LDKUnsignedChannelAnnouncement val_conv;
25606         val_conv.inner = (void*)(val & (~1));
25607         val_conv.is_owned = (val & 1) || (val == 0);
25608         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25609         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
25610         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
25611 }
25612
25613 uint32_t  __attribute__((visibility("default"))) 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) {
25614         LDKSignature node_signature_1_arg_ref;
25615         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
25616         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
25617         LDKSignature node_signature_2_arg_ref;
25618         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
25619         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
25620         LDKSignature bitcoin_signature_1_arg_ref;
25621         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
25622         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
25623         LDKSignature bitcoin_signature_2_arg_ref;
25624         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
25625         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
25626         LDKUnsignedChannelAnnouncement contents_arg_conv;
25627         contents_arg_conv.inner = (void*)(contents_arg & (~1));
25628         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
25629         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
25630         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
25631         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);
25632         uint64_t ret_ref = 0;
25633         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25634         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25636         ret_ref = (uint64_t)ret_var.inner;
25637         if (ret_var.is_owned) {
25638                 ret_ref |= 1;
25639         }
25640         return ret_ref;
25641 }
25642
25643 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
25644         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
25645 uint64_t ret_ref = 0;
25646 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25647 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25648 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25649 ret_ref = (uint64_t)ret_var.inner;
25650 if (ret_var.is_owned) {
25651         ret_ref |= 1;
25652 }
25653         return ret_ref;
25654 }
25655 int64_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
25656         LDKChannelAnnouncement arg_conv;
25657         arg_conv.inner = (void*)(arg & (~1));
25658         arg_conv.is_owned = false;
25659         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25660         int64_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
25661         return ret_val;
25662 }
25663
25664 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
25665         LDKChannelAnnouncement orig_conv;
25666         orig_conv.inner = (void*)(orig & (~1));
25667         orig_conv.is_owned = false;
25668         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25669         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
25670         uint64_t ret_ref = 0;
25671         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25672         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25674         ret_ref = (uint64_t)ret_var.inner;
25675         if (ret_var.is_owned) {
25676                 ret_ref |= 1;
25677         }
25678         return ret_ref;
25679 }
25680
25681 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
25682         LDKUnsignedChannelUpdate this_obj_conv;
25683         this_obj_conv.inner = (void*)(this_obj & (~1));
25684         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25686         UnsignedChannelUpdate_free(this_obj_conv);
25687 }
25688
25689 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
25690         LDKUnsignedChannelUpdate this_ptr_conv;
25691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25692         this_ptr_conv.is_owned = false;
25693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25694         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25695         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
25696         return ret_arr;
25697 }
25698
25699 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
25700         LDKUnsignedChannelUpdate this_ptr_conv;
25701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25702         this_ptr_conv.is_owned = false;
25703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25704         LDKThirtyTwoBytes val_ref;
25705         CHECK(*((uint32_t*)val) == 32);
25706         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
25707         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
25708 }
25709
25710 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
25711         LDKUnsignedChannelUpdate this_ptr_conv;
25712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25713         this_ptr_conv.is_owned = false;
25714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25715         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
25716         return ret_val;
25717 }
25718
25719 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
25720         LDKUnsignedChannelUpdate this_ptr_conv;
25721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25722         this_ptr_conv.is_owned = false;
25723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25724         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
25725 }
25726
25727 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
25728         LDKUnsignedChannelUpdate this_ptr_conv;
25729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25730         this_ptr_conv.is_owned = false;
25731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25732         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
25733         return ret_val;
25734 }
25735
25736 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
25737         LDKUnsignedChannelUpdate this_ptr_conv;
25738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25739         this_ptr_conv.is_owned = false;
25740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25741         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
25742 }
25743
25744 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
25745         LDKUnsignedChannelUpdate this_ptr_conv;
25746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25747         this_ptr_conv.is_owned = false;
25748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25749         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
25750         return ret_val;
25751 }
25752
25753 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
25754         LDKUnsignedChannelUpdate this_ptr_conv;
25755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25756         this_ptr_conv.is_owned = false;
25757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25758         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
25759 }
25760
25761 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
25762         LDKUnsignedChannelUpdate 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         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
25767         return ret_val;
25768 }
25769
25770 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
25771         LDKUnsignedChannelUpdate 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         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
25776 }
25777
25778 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
25779         LDKUnsignedChannelUpdate 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_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
25784         return ret_val;
25785 }
25786
25787 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
25788         LDKUnsignedChannelUpdate 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         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
25793 }
25794
25795 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
25796         LDKUnsignedChannelUpdate 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         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
25801         return ret_val;
25802 }
25803
25804 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
25805         LDKUnsignedChannelUpdate 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         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
25810 }
25811
25812 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
25813         LDKUnsignedChannelUpdate 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         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
25818         return ret_val;
25819 }
25820
25821 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
25822         LDKUnsignedChannelUpdate 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         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
25827 }
25828
25829 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
25830         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
25831 uint64_t ret_ref = 0;
25832 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25833 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25834 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25835 ret_ref = (uint64_t)ret_var.inner;
25836 if (ret_var.is_owned) {
25837         ret_ref |= 1;
25838 }
25839         return ret_ref;
25840 }
25841 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
25842         LDKUnsignedChannelUpdate arg_conv;
25843         arg_conv.inner = (void*)(arg & (~1));
25844         arg_conv.is_owned = false;
25845         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25846         int64_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
25847         return ret_val;
25848 }
25849
25850 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
25851         LDKUnsignedChannelUpdate orig_conv;
25852         orig_conv.inner = (void*)(orig & (~1));
25853         orig_conv.is_owned = false;
25854         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25855         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
25856         uint64_t ret_ref = 0;
25857         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25858         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25860         ret_ref = (uint64_t)ret_var.inner;
25861         if (ret_var.is_owned) {
25862                 ret_ref |= 1;
25863         }
25864         return ret_ref;
25865 }
25866
25867 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_obj) {
25868         LDKChannelUpdate this_obj_conv;
25869         this_obj_conv.inner = (void*)(this_obj & (~1));
25870         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25872         ChannelUpdate_free(this_obj_conv);
25873 }
25874
25875 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
25876         LDKChannelUpdate this_ptr_conv;
25877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25878         this_ptr_conv.is_owned = false;
25879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25880         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
25881         memcpy((uint8_t*)(ret_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
25882         return ret_arr;
25883 }
25884
25885 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
25886         LDKChannelUpdate this_ptr_conv;
25887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25888         this_ptr_conv.is_owned = false;
25889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25890         LDKSignature val_ref;
25891         CHECK(*((uint32_t*)val) == 64);
25892         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
25893         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
25894 }
25895
25896 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
25897         LDKChannelUpdate this_ptr_conv;
25898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25899         this_ptr_conv.is_owned = false;
25900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25901         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
25902         uint64_t ret_ref = 0;
25903         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25904         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25906         ret_ref = (uint64_t)ret_var.inner;
25907         if (ret_var.is_owned) {
25908                 ret_ref |= 1;
25909         }
25910         return ret_ref;
25911 }
25912
25913 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
25914         LDKChannelUpdate this_ptr_conv;
25915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25916         this_ptr_conv.is_owned = false;
25917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25918         LDKUnsignedChannelUpdate val_conv;
25919         val_conv.inner = (void*)(val & (~1));
25920         val_conv.is_owned = (val & 1) || (val == 0);
25921         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25922         val_conv = UnsignedChannelUpdate_clone(&val_conv);
25923         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
25924 }
25925
25926 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
25927         LDKSignature signature_arg_ref;
25928         CHECK(*((uint32_t*)signature_arg) == 64);
25929         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
25930         LDKUnsignedChannelUpdate contents_arg_conv;
25931         contents_arg_conv.inner = (void*)(contents_arg & (~1));
25932         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
25933         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
25934         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
25935         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
25936         uint64_t ret_ref = 0;
25937         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25938         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25940         ret_ref = (uint64_t)ret_var.inner;
25941         if (ret_var.is_owned) {
25942                 ret_ref |= 1;
25943         }
25944         return ret_ref;
25945 }
25946
25947 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
25948         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
25949 uint64_t ret_ref = 0;
25950 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25951 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25952 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25953 ret_ref = (uint64_t)ret_var.inner;
25954 if (ret_var.is_owned) {
25955         ret_ref |= 1;
25956 }
25957         return ret_ref;
25958 }
25959 int64_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
25960         LDKChannelUpdate arg_conv;
25961         arg_conv.inner = (void*)(arg & (~1));
25962         arg_conv.is_owned = false;
25963         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25964         int64_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
25965         return ret_val;
25966 }
25967
25968 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
25969         LDKChannelUpdate orig_conv;
25970         orig_conv.inner = (void*)(orig & (~1));
25971         orig_conv.is_owned = false;
25972         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25973         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
25974         uint64_t ret_ref = 0;
25975         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25976         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25978         ret_ref = (uint64_t)ret_var.inner;
25979         if (ret_var.is_owned) {
25980                 ret_ref |= 1;
25981         }
25982         return ret_ref;
25983 }
25984
25985 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_obj) {
25986         LDKQueryChannelRange this_obj_conv;
25987         this_obj_conv.inner = (void*)(this_obj & (~1));
25988         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25990         QueryChannelRange_free(this_obj_conv);
25991 }
25992
25993 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
25994         LDKQueryChannelRange this_ptr_conv;
25995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25996         this_ptr_conv.is_owned = false;
25997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25998         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25999         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
26000         return ret_arr;
26001 }
26002
26003 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26004         LDKQueryChannelRange this_ptr_conv;
26005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26006         this_ptr_conv.is_owned = false;
26007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26008         LDKThirtyTwoBytes val_ref;
26009         CHECK(*((uint32_t*)val) == 32);
26010         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
26011         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
26012 }
26013
26014 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
26015         LDKQueryChannelRange this_ptr_conv;
26016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26017         this_ptr_conv.is_owned = false;
26018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26019         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
26020         return ret_val;
26021 }
26022
26023 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
26024         LDKQueryChannelRange this_ptr_conv;
26025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26026         this_ptr_conv.is_owned = false;
26027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26028         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
26029 }
26030
26031 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
26032         LDKQueryChannelRange this_ptr_conv;
26033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26034         this_ptr_conv.is_owned = false;
26035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26036         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
26037         return ret_val;
26038 }
26039
26040 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
26041         LDKQueryChannelRange this_ptr_conv;
26042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26043         this_ptr_conv.is_owned = false;
26044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26045         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
26046 }
26047
26048 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
26049         LDKThirtyTwoBytes chain_hash_arg_ref;
26050         CHECK(*((uint32_t*)chain_hash_arg) == 32);
26051         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
26052         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
26053         uint64_t ret_ref = 0;
26054         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26055         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26057         ret_ref = (uint64_t)ret_var.inner;
26058         if (ret_var.is_owned) {
26059                 ret_ref |= 1;
26060         }
26061         return ret_ref;
26062 }
26063
26064 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
26065         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
26066 uint64_t ret_ref = 0;
26067 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26068 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26069 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26070 ret_ref = (uint64_t)ret_var.inner;
26071 if (ret_var.is_owned) {
26072         ret_ref |= 1;
26073 }
26074         return ret_ref;
26075 }
26076 int64_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
26077         LDKQueryChannelRange arg_conv;
26078         arg_conv.inner = (void*)(arg & (~1));
26079         arg_conv.is_owned = false;
26080         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26081         int64_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
26082         return ret_val;
26083 }
26084
26085 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
26086         LDKQueryChannelRange orig_conv;
26087         orig_conv.inner = (void*)(orig & (~1));
26088         orig_conv.is_owned = false;
26089         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26090         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
26091         uint64_t ret_ref = 0;
26092         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26093         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26095         ret_ref = (uint64_t)ret_var.inner;
26096         if (ret_var.is_owned) {
26097                 ret_ref |= 1;
26098         }
26099         return ret_ref;
26100 }
26101
26102 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
26103         LDKReplyChannelRange this_obj_conv;
26104         this_obj_conv.inner = (void*)(this_obj & (~1));
26105         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26107         ReplyChannelRange_free(this_obj_conv);
26108 }
26109
26110 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
26111         LDKReplyChannelRange this_ptr_conv;
26112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26113         this_ptr_conv.is_owned = false;
26114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26115         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26116         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
26117         return ret_arr;
26118 }
26119
26120 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26121         LDKReplyChannelRange this_ptr_conv;
26122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26123         this_ptr_conv.is_owned = false;
26124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26125         LDKThirtyTwoBytes val_ref;
26126         CHECK(*((uint32_t*)val) == 32);
26127         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
26128         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
26129 }
26130
26131 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
26132         LDKReplyChannelRange this_ptr_conv;
26133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26134         this_ptr_conv.is_owned = false;
26135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26136         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
26137         return ret_val;
26138 }
26139
26140 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
26141         LDKReplyChannelRange this_ptr_conv;
26142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26143         this_ptr_conv.is_owned = false;
26144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26145         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
26146 }
26147
26148 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
26149         LDKReplyChannelRange this_ptr_conv;
26150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26151         this_ptr_conv.is_owned = false;
26152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26153         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
26154         return ret_val;
26155 }
26156
26157 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
26158         LDKReplyChannelRange this_ptr_conv;
26159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26160         this_ptr_conv.is_owned = false;
26161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26162         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
26163 }
26164
26165 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
26166         LDKReplyChannelRange this_ptr_conv;
26167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26168         this_ptr_conv.is_owned = false;
26169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26170         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
26171         return ret_val;
26172 }
26173
26174 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
26175         LDKReplyChannelRange this_ptr_conv;
26176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26177         this_ptr_conv.is_owned = false;
26178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26179         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
26180 }
26181
26182 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
26183         LDKReplyChannelRange this_ptr_conv;
26184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26185         this_ptr_conv.is_owned = false;
26186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26187         LDKCVec_u64Z val_constr;
26188         val_constr.datalen = *((uint32_t*)val);
26189         if (val_constr.datalen > 0)
26190                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26191         else
26192                 val_constr.data = NULL;
26193         int64_t* val_vals = (int64_t*)(val + 4);
26194         for (size_t i = 0; i < val_constr.datalen; i++) {
26195                 int64_t val_conv_8 = val_vals[i];
26196                 val_constr.data[i] = val_conv_8;
26197         }
26198         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
26199 }
26200
26201 uint32_t  __attribute__((visibility("default"))) 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) {
26202         LDKThirtyTwoBytes chain_hash_arg_ref;
26203         CHECK(*((uint32_t*)chain_hash_arg) == 32);
26204         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
26205         LDKCVec_u64Z short_channel_ids_arg_constr;
26206         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
26207         if (short_channel_ids_arg_constr.datalen > 0)
26208                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26209         else
26210                 short_channel_ids_arg_constr.data = NULL;
26211         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
26212         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
26213                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
26214                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
26215         }
26216         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
26217         uint64_t ret_ref = 0;
26218         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26219         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26221         ret_ref = (uint64_t)ret_var.inner;
26222         if (ret_var.is_owned) {
26223                 ret_ref |= 1;
26224         }
26225         return ret_ref;
26226 }
26227
26228 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
26229         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
26230 uint64_t ret_ref = 0;
26231 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26232 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26233 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26234 ret_ref = (uint64_t)ret_var.inner;
26235 if (ret_var.is_owned) {
26236         ret_ref |= 1;
26237 }
26238         return ret_ref;
26239 }
26240 int64_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
26241         LDKReplyChannelRange arg_conv;
26242         arg_conv.inner = (void*)(arg & (~1));
26243         arg_conv.is_owned = false;
26244         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26245         int64_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
26246         return ret_val;
26247 }
26248
26249 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
26250         LDKReplyChannelRange orig_conv;
26251         orig_conv.inner = (void*)(orig & (~1));
26252         orig_conv.is_owned = false;
26253         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26254         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
26255         uint64_t ret_ref = 0;
26256         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26257         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26259         ret_ref = (uint64_t)ret_var.inner;
26260         if (ret_var.is_owned) {
26261                 ret_ref |= 1;
26262         }
26263         return ret_ref;
26264 }
26265
26266 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
26267         LDKQueryShortChannelIds this_obj_conv;
26268         this_obj_conv.inner = (void*)(this_obj & (~1));
26269         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26271         QueryShortChannelIds_free(this_obj_conv);
26272 }
26273
26274 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
26275         LDKQueryShortChannelIds this_ptr_conv;
26276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26277         this_ptr_conv.is_owned = false;
26278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26279         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26280         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
26281         return ret_arr;
26282 }
26283
26284 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26285         LDKQueryShortChannelIds this_ptr_conv;
26286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26287         this_ptr_conv.is_owned = false;
26288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26289         LDKThirtyTwoBytes val_ref;
26290         CHECK(*((uint32_t*)val) == 32);
26291         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
26292         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
26293 }
26294
26295 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
26296         LDKQueryShortChannelIds this_ptr_conv;
26297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26298         this_ptr_conv.is_owned = false;
26299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26300         LDKCVec_u64Z val_constr;
26301         val_constr.datalen = *((uint32_t*)val);
26302         if (val_constr.datalen > 0)
26303                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26304         else
26305                 val_constr.data = NULL;
26306         int64_t* val_vals = (int64_t*)(val + 4);
26307         for (size_t i = 0; i < val_constr.datalen; i++) {
26308                 int64_t val_conv_8 = val_vals[i];
26309                 val_constr.data[i] = val_conv_8;
26310         }
26311         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
26312 }
26313
26314 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
26315         LDKThirtyTwoBytes chain_hash_arg_ref;
26316         CHECK(*((uint32_t*)chain_hash_arg) == 32);
26317         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
26318         LDKCVec_u64Z short_channel_ids_arg_constr;
26319         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
26320         if (short_channel_ids_arg_constr.datalen > 0)
26321                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26322         else
26323                 short_channel_ids_arg_constr.data = NULL;
26324         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
26325         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
26326                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
26327                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
26328         }
26329         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
26330         uint64_t ret_ref = 0;
26331         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26332         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26334         ret_ref = (uint64_t)ret_var.inner;
26335         if (ret_var.is_owned) {
26336                 ret_ref |= 1;
26337         }
26338         return ret_ref;
26339 }
26340
26341 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
26342         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
26343 uint64_t ret_ref = 0;
26344 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26345 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26346 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26347 ret_ref = (uint64_t)ret_var.inner;
26348 if (ret_var.is_owned) {
26349         ret_ref |= 1;
26350 }
26351         return ret_ref;
26352 }
26353 int64_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
26354         LDKQueryShortChannelIds arg_conv;
26355         arg_conv.inner = (void*)(arg & (~1));
26356         arg_conv.is_owned = false;
26357         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26358         int64_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
26359         return ret_val;
26360 }
26361
26362 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
26363         LDKQueryShortChannelIds orig_conv;
26364         orig_conv.inner = (void*)(orig & (~1));
26365         orig_conv.is_owned = false;
26366         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26367         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
26368         uint64_t ret_ref = 0;
26369         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26370         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26372         ret_ref = (uint64_t)ret_var.inner;
26373         if (ret_var.is_owned) {
26374                 ret_ref |= 1;
26375         }
26376         return ret_ref;
26377 }
26378
26379 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
26380         LDKReplyShortChannelIdsEnd this_obj_conv;
26381         this_obj_conv.inner = (void*)(this_obj & (~1));
26382         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26384         ReplyShortChannelIdsEnd_free(this_obj_conv);
26385 }
26386
26387 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
26388         LDKReplyShortChannelIdsEnd this_ptr_conv;
26389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26390         this_ptr_conv.is_owned = false;
26391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26392         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26393         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
26394         return ret_arr;
26395 }
26396
26397 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26398         LDKReplyShortChannelIdsEnd this_ptr_conv;
26399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26400         this_ptr_conv.is_owned = false;
26401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26402         LDKThirtyTwoBytes val_ref;
26403         CHECK(*((uint32_t*)val) == 32);
26404         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
26405         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
26406 }
26407
26408 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
26409         LDKReplyShortChannelIdsEnd this_ptr_conv;
26410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26411         this_ptr_conv.is_owned = false;
26412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26413         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
26414         return ret_val;
26415 }
26416
26417 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
26418         LDKReplyShortChannelIdsEnd this_ptr_conv;
26419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26420         this_ptr_conv.is_owned = false;
26421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26422         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
26423 }
26424
26425 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
26426         LDKThirtyTwoBytes chain_hash_arg_ref;
26427         CHECK(*((uint32_t*)chain_hash_arg) == 32);
26428         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
26429         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
26430         uint64_t ret_ref = 0;
26431         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26432         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26434         ret_ref = (uint64_t)ret_var.inner;
26435         if (ret_var.is_owned) {
26436                 ret_ref |= 1;
26437         }
26438         return ret_ref;
26439 }
26440
26441 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
26442         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
26443 uint64_t ret_ref = 0;
26444 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26445 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26446 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26447 ret_ref = (uint64_t)ret_var.inner;
26448 if (ret_var.is_owned) {
26449         ret_ref |= 1;
26450 }
26451         return ret_ref;
26452 }
26453 int64_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
26454         LDKReplyShortChannelIdsEnd arg_conv;
26455         arg_conv.inner = (void*)(arg & (~1));
26456         arg_conv.is_owned = false;
26457         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26458         int64_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
26459         return ret_val;
26460 }
26461
26462 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
26463         LDKReplyShortChannelIdsEnd orig_conv;
26464         orig_conv.inner = (void*)(orig & (~1));
26465         orig_conv.is_owned = false;
26466         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26467         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
26468         uint64_t ret_ref = 0;
26469         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26470         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26472         ret_ref = (uint64_t)ret_var.inner;
26473         if (ret_var.is_owned) {
26474                 ret_ref |= 1;
26475         }
26476         return ret_ref;
26477 }
26478
26479 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
26480         LDKGossipTimestampFilter this_obj_conv;
26481         this_obj_conv.inner = (void*)(this_obj & (~1));
26482         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26484         GossipTimestampFilter_free(this_obj_conv);
26485 }
26486
26487 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
26488         LDKGossipTimestampFilter this_ptr_conv;
26489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26490         this_ptr_conv.is_owned = false;
26491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26492         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26493         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
26494         return ret_arr;
26495 }
26496
26497 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26498         LDKGossipTimestampFilter this_ptr_conv;
26499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26500         this_ptr_conv.is_owned = false;
26501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26502         LDKThirtyTwoBytes val_ref;
26503         CHECK(*((uint32_t*)val) == 32);
26504         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
26505         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
26506 }
26507
26508 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
26509         LDKGossipTimestampFilter this_ptr_conv;
26510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26511         this_ptr_conv.is_owned = false;
26512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26513         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
26514         return ret_val;
26515 }
26516
26517 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
26518         LDKGossipTimestampFilter this_ptr_conv;
26519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26520         this_ptr_conv.is_owned = false;
26521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26522         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
26523 }
26524
26525 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
26526         LDKGossipTimestampFilter this_ptr_conv;
26527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26528         this_ptr_conv.is_owned = false;
26529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26530         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
26531         return ret_val;
26532 }
26533
26534 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
26535         LDKGossipTimestampFilter this_ptr_conv;
26536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26537         this_ptr_conv.is_owned = false;
26538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26539         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
26540 }
26541
26542 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
26543         LDKThirtyTwoBytes chain_hash_arg_ref;
26544         CHECK(*((uint32_t*)chain_hash_arg) == 32);
26545         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
26546         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
26547         uint64_t ret_ref = 0;
26548         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26549         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26551         ret_ref = (uint64_t)ret_var.inner;
26552         if (ret_var.is_owned) {
26553                 ret_ref |= 1;
26554         }
26555         return ret_ref;
26556 }
26557
26558 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
26559         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
26560 uint64_t ret_ref = 0;
26561 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26562 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26563 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26564 ret_ref = (uint64_t)ret_var.inner;
26565 if (ret_var.is_owned) {
26566         ret_ref |= 1;
26567 }
26568         return ret_ref;
26569 }
26570 int64_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
26571         LDKGossipTimestampFilter arg_conv;
26572         arg_conv.inner = (void*)(arg & (~1));
26573         arg_conv.is_owned = false;
26574         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26575         int64_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
26576         return ret_val;
26577 }
26578
26579 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
26580         LDKGossipTimestampFilter orig_conv;
26581         orig_conv.inner = (void*)(orig & (~1));
26582         orig_conv.is_owned = false;
26583         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26584         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
26585         uint64_t ret_ref = 0;
26586         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26587         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26589         ret_ref = (uint64_t)ret_var.inner;
26590         if (ret_var.is_owned) {
26591                 ret_ref |= 1;
26592         }
26593         return ret_ref;
26594 }
26595
26596 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
26597         if ((this_ptr & 1) != 0) return;
26598         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
26599         CHECK_ACCESS(this_ptr_ptr);
26600         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
26601         FREE((void*)this_ptr);
26602         ErrorAction_free(this_ptr_conv);
26603 }
26604
26605 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
26606         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
26607         *ret_copy = ErrorAction_clone(arg);
26608 uint64_t ret_ref = (uint64_t)ret_copy;
26609         return ret_ref;
26610 }
26611 int64_t  __attribute__((visibility("default"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
26612         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
26613         int64_t ret_val = ErrorAction_clone_ptr(arg_conv);
26614         return ret_val;
26615 }
26616
26617 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
26618         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
26619         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
26620         *ret_copy = ErrorAction_clone(orig_conv);
26621         uint64_t ret_ref = (uint64_t)ret_copy;
26622         return ret_ref;
26623 }
26624
26625 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
26626         LDKErrorMessage msg_conv;
26627         msg_conv.inner = (void*)(msg & (~1));
26628         msg_conv.is_owned = (msg & 1) || (msg == 0);
26629         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26630         msg_conv = ErrorMessage_clone(&msg_conv);
26631         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
26632         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
26633         uint64_t ret_ref = (uint64_t)ret_copy;
26634         return ret_ref;
26635 }
26636
26637 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_ignore_error() {
26638         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
26639         *ret_copy = ErrorAction_ignore_error();
26640         uint64_t ret_ref = (uint64_t)ret_copy;
26641         return ret_ref;
26642 }
26643
26644 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
26645         LDKLevel a_conv = LDKLevel_from_js(a);
26646         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
26647         *ret_copy = ErrorAction_ignore_and_log(a_conv);
26648         uint64_t ret_ref = (uint64_t)ret_copy;
26649         return ret_ref;
26650 }
26651
26652 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_send_error_message(uint32_t msg) {
26653         LDKErrorMessage msg_conv;
26654         msg_conv.inner = (void*)(msg & (~1));
26655         msg_conv.is_owned = (msg & 1) || (msg == 0);
26656         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26657         msg_conv = ErrorMessage_clone(&msg_conv);
26658         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
26659         *ret_copy = ErrorAction_send_error_message(msg_conv);
26660         uint64_t ret_ref = (uint64_t)ret_copy;
26661         return ret_ref;
26662 }
26663
26664 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_obj) {
26665         LDKLightningError this_obj_conv;
26666         this_obj_conv.inner = (void*)(this_obj & (~1));
26667         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26669         LightningError_free(this_obj_conv);
26670 }
26671
26672 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
26673         LDKLightningError this_ptr_conv;
26674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26675         this_ptr_conv.is_owned = false;
26676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26677         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
26678         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26679         Str_free(ret_str);
26680         return ret_conv;
26681 }
26682
26683 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
26684         LDKLightningError this_ptr_conv;
26685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26686         this_ptr_conv.is_owned = false;
26687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26688         LDKStr val_conv = str_ref_to_owned_c(val);
26689         LightningError_set_err(&this_ptr_conv, val_conv);
26690 }
26691
26692 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
26693         LDKLightningError this_ptr_conv;
26694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26695         this_ptr_conv.is_owned = false;
26696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26697         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
26698         *ret_copy = LightningError_get_action(&this_ptr_conv);
26699         uint64_t ret_ref = (uint64_t)ret_copy;
26700         return ret_ref;
26701 }
26702
26703 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
26704         LDKLightningError this_ptr_conv;
26705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26706         this_ptr_conv.is_owned = false;
26707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26708         void* val_ptr = (void*)(((uint64_t)val) & ~1);
26709         CHECK_ACCESS(val_ptr);
26710         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
26711         val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1));
26712         LightningError_set_action(&this_ptr_conv, val_conv);
26713 }
26714
26715 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
26716         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
26717         void* action_arg_ptr = (void*)(((uint64_t)action_arg) & ~1);
26718         CHECK_ACCESS(action_arg_ptr);
26719         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
26720         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
26721         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
26722         uint64_t ret_ref = 0;
26723         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26724         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26726         ret_ref = (uint64_t)ret_var.inner;
26727         if (ret_var.is_owned) {
26728                 ret_ref |= 1;
26729         }
26730         return ret_ref;
26731 }
26732
26733 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
26734         LDKLightningError ret_var = LightningError_clone(arg);
26735 uint64_t ret_ref = 0;
26736 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26737 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26738 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26739 ret_ref = (uint64_t)ret_var.inner;
26740 if (ret_var.is_owned) {
26741         ret_ref |= 1;
26742 }
26743         return ret_ref;
26744 }
26745 int64_t  __attribute__((visibility("default"))) TS_LightningError_clone_ptr(uint32_t arg) {
26746         LDKLightningError arg_conv;
26747         arg_conv.inner = (void*)(arg & (~1));
26748         arg_conv.is_owned = false;
26749         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26750         int64_t ret_val = LightningError_clone_ptr(&arg_conv);
26751         return ret_val;
26752 }
26753
26754 uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_t orig) {
26755         LDKLightningError orig_conv;
26756         orig_conv.inner = (void*)(orig & (~1));
26757         orig_conv.is_owned = false;
26758         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26759         LDKLightningError ret_var = LightningError_clone(&orig_conv);
26760         uint64_t ret_ref = 0;
26761         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26762         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26764         ret_ref = (uint64_t)ret_var.inner;
26765         if (ret_var.is_owned) {
26766                 ret_ref |= 1;
26767         }
26768         return ret_ref;
26769 }
26770
26771 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
26772         LDKCommitmentUpdate this_obj_conv;
26773         this_obj_conv.inner = (void*)(this_obj & (~1));
26774         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26776         CommitmentUpdate_free(this_obj_conv);
26777 }
26778
26779 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
26780         LDKCommitmentUpdate this_ptr_conv;
26781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26782         this_ptr_conv.is_owned = false;
26783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26784         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
26785         uint32_tArray ret_arr = NULL;
26786         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
26787         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
26788         for (size_t p = 0; p < ret_var.datalen; p++) {
26789                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
26790                 uint64_t ret_conv_15_ref = 0;
26791                 CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26792                 CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26793                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
26794                 ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner;
26795                 if (ret_conv_15_var.is_owned) {
26796                         ret_conv_15_ref |= 1;
26797                 }
26798                 ret_arr_ptr[p] = ret_conv_15_ref;
26799         }
26800         
26801         FREE(ret_var.data);
26802         return ret_arr;
26803 }
26804
26805 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
26806         LDKCommitmentUpdate this_ptr_conv;
26807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26808         this_ptr_conv.is_owned = false;
26809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26810         LDKCVec_UpdateAddHTLCZ val_constr;
26811         val_constr.datalen = *((uint32_t*)val);
26812         if (val_constr.datalen > 0)
26813                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
26814         else
26815                 val_constr.data = NULL;
26816         uint32_t* val_vals = (uint32_t*)(val + 4);
26817         for (size_t p = 0; p < val_constr.datalen; p++) {
26818                 uint32_t val_conv_15 = val_vals[p];
26819                 LDKUpdateAddHTLC val_conv_15_conv;
26820                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
26821                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
26822                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
26823                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
26824                 val_constr.data[p] = val_conv_15_conv;
26825         }
26826         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
26827 }
26828
26829 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
26830         LDKCommitmentUpdate this_ptr_conv;
26831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26832         this_ptr_conv.is_owned = false;
26833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26834         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
26835         uint32_tArray ret_arr = NULL;
26836         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
26837         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
26838         for (size_t t = 0; t < ret_var.datalen; t++) {
26839                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
26840                 uint64_t ret_conv_19_ref = 0;
26841                 CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26842                 CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26843                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
26844                 ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner;
26845                 if (ret_conv_19_var.is_owned) {
26846                         ret_conv_19_ref |= 1;
26847                 }
26848                 ret_arr_ptr[t] = ret_conv_19_ref;
26849         }
26850         
26851         FREE(ret_var.data);
26852         return ret_arr;
26853 }
26854
26855 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
26856         LDKCommitmentUpdate this_ptr_conv;
26857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26858         this_ptr_conv.is_owned = false;
26859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26860         LDKCVec_UpdateFulfillHTLCZ val_constr;
26861         val_constr.datalen = *((uint32_t*)val);
26862         if (val_constr.datalen > 0)
26863                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
26864         else
26865                 val_constr.data = NULL;
26866         uint32_t* val_vals = (uint32_t*)(val + 4);
26867         for (size_t t = 0; t < val_constr.datalen; t++) {
26868                 uint32_t val_conv_19 = val_vals[t];
26869                 LDKUpdateFulfillHTLC val_conv_19_conv;
26870                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
26871                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
26872                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
26873                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
26874                 val_constr.data[t] = val_conv_19_conv;
26875         }
26876         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
26877 }
26878
26879 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
26880         LDKCommitmentUpdate this_ptr_conv;
26881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26882         this_ptr_conv.is_owned = false;
26883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26884         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
26885         uint32_tArray ret_arr = NULL;
26886         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
26887         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
26888         for (size_t q = 0; q < ret_var.datalen; q++) {
26889                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
26890                 uint64_t ret_conv_16_ref = 0;
26891                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26892                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26893                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
26894                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
26895                 if (ret_conv_16_var.is_owned) {
26896                         ret_conv_16_ref |= 1;
26897                 }
26898                 ret_arr_ptr[q] = ret_conv_16_ref;
26899         }
26900         
26901         FREE(ret_var.data);
26902         return ret_arr;
26903 }
26904
26905 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
26906         LDKCommitmentUpdate this_ptr_conv;
26907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26908         this_ptr_conv.is_owned = false;
26909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26910         LDKCVec_UpdateFailHTLCZ val_constr;
26911         val_constr.datalen = *((uint32_t*)val);
26912         if (val_constr.datalen > 0)
26913                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
26914         else
26915                 val_constr.data = NULL;
26916         uint32_t* val_vals = (uint32_t*)(val + 4);
26917         for (size_t q = 0; q < val_constr.datalen; q++) {
26918                 uint32_t val_conv_16 = val_vals[q];
26919                 LDKUpdateFailHTLC val_conv_16_conv;
26920                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
26921                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
26922                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
26923                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
26924                 val_constr.data[q] = val_conv_16_conv;
26925         }
26926         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
26927 }
26928
26929 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
26930         LDKCommitmentUpdate this_ptr_conv;
26931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26932         this_ptr_conv.is_owned = false;
26933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26934         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
26935         uint32_tArray ret_arr = NULL;
26936         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
26937         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
26938         for (size_t z = 0; z < ret_var.datalen; z++) {
26939                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
26940                 uint64_t ret_conv_25_ref = 0;
26941                 CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26942                 CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26943                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
26944                 ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner;
26945                 if (ret_conv_25_var.is_owned) {
26946                         ret_conv_25_ref |= 1;
26947                 }
26948                 ret_arr_ptr[z] = ret_conv_25_ref;
26949         }
26950         
26951         FREE(ret_var.data);
26952         return ret_arr;
26953 }
26954
26955 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
26956         LDKCommitmentUpdate this_ptr_conv;
26957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26958         this_ptr_conv.is_owned = false;
26959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26960         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
26961         val_constr.datalen = *((uint32_t*)val);
26962         if (val_constr.datalen > 0)
26963                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
26964         else
26965                 val_constr.data = NULL;
26966         uint32_t* val_vals = (uint32_t*)(val + 4);
26967         for (size_t z = 0; z < val_constr.datalen; z++) {
26968                 uint32_t val_conv_25 = val_vals[z];
26969                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
26970                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
26971                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
26972                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
26973                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
26974                 val_constr.data[z] = val_conv_25_conv;
26975         }
26976         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
26977 }
26978
26979 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
26980         LDKCommitmentUpdate this_ptr_conv;
26981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26982         this_ptr_conv.is_owned = false;
26983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26984         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
26985         uint64_t ret_ref = 0;
26986         if ((uint64_t)ret_var.inner > 4096) {
26987                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26988                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26990                 ret_ref = (uint64_t)ret_var.inner;
26991                 if (ret_var.is_owned) {
26992                         ret_ref |= 1;
26993                 }
26994         }
26995         return ret_ref;
26996 }
26997
26998 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
26999         LDKCommitmentUpdate this_ptr_conv;
27000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27001         this_ptr_conv.is_owned = false;
27002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27003         LDKUpdateFee val_conv;
27004         val_conv.inner = (void*)(val & (~1));
27005         val_conv.is_owned = (val & 1) || (val == 0);
27006         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27007         val_conv = UpdateFee_clone(&val_conv);
27008         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
27009 }
27010
27011 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
27012         LDKCommitmentUpdate this_ptr_conv;
27013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27014         this_ptr_conv.is_owned = false;
27015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27016         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
27017         uint64_t ret_ref = 0;
27018         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27019         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27021         ret_ref = (uint64_t)ret_var.inner;
27022         if (ret_var.is_owned) {
27023                 ret_ref |= 1;
27024         }
27025         return ret_ref;
27026 }
27027
27028 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
27029         LDKCommitmentUpdate this_ptr_conv;
27030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27031         this_ptr_conv.is_owned = false;
27032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27033         LDKCommitmentSigned val_conv;
27034         val_conv.inner = (void*)(val & (~1));
27035         val_conv.is_owned = (val & 1) || (val == 0);
27036         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27037         val_conv = CommitmentSigned_clone(&val_conv);
27038         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
27039 }
27040
27041 uint32_t  __attribute__((visibility("default"))) 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) {
27042         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
27043         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
27044         if (update_add_htlcs_arg_constr.datalen > 0)
27045                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
27046         else
27047                 update_add_htlcs_arg_constr.data = NULL;
27048         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
27049         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
27050                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
27051                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
27052                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
27053                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
27054                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
27055                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
27056                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
27057         }
27058         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
27059         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
27060         if (update_fulfill_htlcs_arg_constr.datalen > 0)
27061                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
27062         else
27063                 update_fulfill_htlcs_arg_constr.data = NULL;
27064         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
27065         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
27066                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
27067                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
27068                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
27069                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
27070                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
27071                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
27072                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
27073         }
27074         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
27075         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
27076         if (update_fail_htlcs_arg_constr.datalen > 0)
27077                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
27078         else
27079                 update_fail_htlcs_arg_constr.data = NULL;
27080         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
27081         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
27082                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
27083                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
27084                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
27085                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
27086                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
27087                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
27088                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
27089         }
27090         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
27091         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
27092         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
27093                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
27094         else
27095                 update_fail_malformed_htlcs_arg_constr.data = NULL;
27096         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
27097         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
27098                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
27099                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
27100                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
27101                 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);
27102                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
27103                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
27104                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
27105         }
27106         LDKUpdateFee update_fee_arg_conv;
27107         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
27108         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
27109         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
27110         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
27111         LDKCommitmentSigned commitment_signed_arg_conv;
27112         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
27113         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
27114         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
27115         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
27116         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);
27117         uint64_t ret_ref = 0;
27118         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27119         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27121         ret_ref = (uint64_t)ret_var.inner;
27122         if (ret_var.is_owned) {
27123                 ret_ref |= 1;
27124         }
27125         return ret_ref;
27126 }
27127
27128 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
27129         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
27130 uint64_t ret_ref = 0;
27131 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27132 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27133 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27134 ret_ref = (uint64_t)ret_var.inner;
27135 if (ret_var.is_owned) {
27136         ret_ref |= 1;
27137 }
27138         return ret_ref;
27139 }
27140 int64_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
27141         LDKCommitmentUpdate arg_conv;
27142         arg_conv.inner = (void*)(arg & (~1));
27143         arg_conv.is_owned = false;
27144         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27145         int64_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
27146         return ret_val;
27147 }
27148
27149 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
27150         LDKCommitmentUpdate orig_conv;
27151         orig_conv.inner = (void*)(orig & (~1));
27152         orig_conv.is_owned = false;
27153         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27154         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
27155         uint64_t ret_ref = 0;
27156         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27157         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27159         ret_ref = (uint64_t)ret_var.inner;
27160         if (ret_var.is_owned) {
27161                 ret_ref |= 1;
27162         }
27163         return ret_ref;
27164 }
27165
27166 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
27167         if ((this_ptr & 1) != 0) return;
27168         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
27169         CHECK_ACCESS(this_ptr_ptr);
27170         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
27171         FREE((void*)this_ptr);
27172         ChannelMessageHandler_free(this_ptr_conv);
27173 }
27174
27175 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
27176         if ((this_ptr & 1) != 0) return;
27177         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
27178         CHECK_ACCESS(this_ptr_ptr);
27179         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
27180         FREE((void*)this_ptr);
27181         RoutingMessageHandler_free(this_ptr_conv);
27182 }
27183
27184 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
27185         LDKAcceptChannel obj_conv;
27186         obj_conv.inner = (void*)(obj & (~1));
27187         obj_conv.is_owned = false;
27188         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27189         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
27190         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27191         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27192         CVec_u8Z_free(ret_var);
27193         return ret_arr;
27194 }
27195
27196 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
27197         LDKu8slice ser_ref;
27198         ser_ref.datalen = *((uint32_t*)ser);
27199         ser_ref.data = (int8_t*)(ser + 4);
27200         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
27201         *ret_conv = AcceptChannel_read(ser_ref);
27202         return (uint64_t)ret_conv;
27203 }
27204
27205 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
27206         LDKAnnouncementSignatures obj_conv;
27207         obj_conv.inner = (void*)(obj & (~1));
27208         obj_conv.is_owned = false;
27209         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27210         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
27211         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27212         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27213         CVec_u8Z_free(ret_var);
27214         return ret_arr;
27215 }
27216
27217 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
27218         LDKu8slice ser_ref;
27219         ser_ref.datalen = *((uint32_t*)ser);
27220         ser_ref.data = (int8_t*)(ser + 4);
27221         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
27222         *ret_conv = AnnouncementSignatures_read(ser_ref);
27223         return (uint64_t)ret_conv;
27224 }
27225
27226 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
27227         LDKChannelReestablish obj_conv;
27228         obj_conv.inner = (void*)(obj & (~1));
27229         obj_conv.is_owned = false;
27230         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27231         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
27232         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27233         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27234         CVec_u8Z_free(ret_var);
27235         return ret_arr;
27236 }
27237
27238 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
27239         LDKu8slice ser_ref;
27240         ser_ref.datalen = *((uint32_t*)ser);
27241         ser_ref.data = (int8_t*)(ser + 4);
27242         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
27243         *ret_conv = ChannelReestablish_read(ser_ref);
27244         return (uint64_t)ret_conv;
27245 }
27246
27247 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
27248         LDKClosingSigned obj_conv;
27249         obj_conv.inner = (void*)(obj & (~1));
27250         obj_conv.is_owned = false;
27251         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27252         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
27253         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27254         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27255         CVec_u8Z_free(ret_var);
27256         return ret_arr;
27257 }
27258
27259 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
27260         LDKu8slice ser_ref;
27261         ser_ref.datalen = *((uint32_t*)ser);
27262         ser_ref.data = (int8_t*)(ser + 4);
27263         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
27264         *ret_conv = ClosingSigned_read(ser_ref);
27265         return (uint64_t)ret_conv;
27266 }
27267
27268 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
27269         LDKClosingSignedFeeRange obj_conv;
27270         obj_conv.inner = (void*)(obj & (~1));
27271         obj_conv.is_owned = false;
27272         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27273         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
27274         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27275         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27276         CVec_u8Z_free(ret_var);
27277         return ret_arr;
27278 }
27279
27280 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
27281         LDKu8slice ser_ref;
27282         ser_ref.datalen = *((uint32_t*)ser);
27283         ser_ref.data = (int8_t*)(ser + 4);
27284         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
27285         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
27286         return (uint64_t)ret_conv;
27287 }
27288
27289 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
27290         LDKCommitmentSigned obj_conv;
27291         obj_conv.inner = (void*)(obj & (~1));
27292         obj_conv.is_owned = false;
27293         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27294         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
27295         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27296         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27297         CVec_u8Z_free(ret_var);
27298         return ret_arr;
27299 }
27300
27301 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
27302         LDKu8slice ser_ref;
27303         ser_ref.datalen = *((uint32_t*)ser);
27304         ser_ref.data = (int8_t*)(ser + 4);
27305         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
27306         *ret_conv = CommitmentSigned_read(ser_ref);
27307         return (uint64_t)ret_conv;
27308 }
27309
27310 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
27311         LDKFundingCreated obj_conv;
27312         obj_conv.inner = (void*)(obj & (~1));
27313         obj_conv.is_owned = false;
27314         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27315         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
27316         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27317         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27318         CVec_u8Z_free(ret_var);
27319         return ret_arr;
27320 }
27321
27322 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
27323         LDKu8slice ser_ref;
27324         ser_ref.datalen = *((uint32_t*)ser);
27325         ser_ref.data = (int8_t*)(ser + 4);
27326         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
27327         *ret_conv = FundingCreated_read(ser_ref);
27328         return (uint64_t)ret_conv;
27329 }
27330
27331 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
27332         LDKFundingSigned obj_conv;
27333         obj_conv.inner = (void*)(obj & (~1));
27334         obj_conv.is_owned = false;
27335         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27336         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
27337         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27338         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27339         CVec_u8Z_free(ret_var);
27340         return ret_arr;
27341 }
27342
27343 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
27344         LDKu8slice ser_ref;
27345         ser_ref.datalen = *((uint32_t*)ser);
27346         ser_ref.data = (int8_t*)(ser + 4);
27347         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
27348         *ret_conv = FundingSigned_read(ser_ref);
27349         return (uint64_t)ret_conv;
27350 }
27351
27352 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
27353         LDKFundingLocked obj_conv;
27354         obj_conv.inner = (void*)(obj & (~1));
27355         obj_conv.is_owned = false;
27356         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27357         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
27358         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27359         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27360         CVec_u8Z_free(ret_var);
27361         return ret_arr;
27362 }
27363
27364 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
27365         LDKu8slice ser_ref;
27366         ser_ref.datalen = *((uint32_t*)ser);
27367         ser_ref.data = (int8_t*)(ser + 4);
27368         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
27369         *ret_conv = FundingLocked_read(ser_ref);
27370         return (uint64_t)ret_conv;
27371 }
27372
27373 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
27374         LDKInit obj_conv;
27375         obj_conv.inner = (void*)(obj & (~1));
27376         obj_conv.is_owned = false;
27377         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27378         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
27379         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27380         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27381         CVec_u8Z_free(ret_var);
27382         return ret_arr;
27383 }
27384
27385 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
27386         LDKu8slice ser_ref;
27387         ser_ref.datalen = *((uint32_t*)ser);
27388         ser_ref.data = (int8_t*)(ser + 4);
27389         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
27390         *ret_conv = Init_read(ser_ref);
27391         return (uint64_t)ret_conv;
27392 }
27393
27394 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
27395         LDKOpenChannel obj_conv;
27396         obj_conv.inner = (void*)(obj & (~1));
27397         obj_conv.is_owned = false;
27398         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27399         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
27400         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27401         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27402         CVec_u8Z_free(ret_var);
27403         return ret_arr;
27404 }
27405
27406 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
27407         LDKu8slice ser_ref;
27408         ser_ref.datalen = *((uint32_t*)ser);
27409         ser_ref.data = (int8_t*)(ser + 4);
27410         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
27411         *ret_conv = OpenChannel_read(ser_ref);
27412         return (uint64_t)ret_conv;
27413 }
27414
27415 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
27416         LDKRevokeAndACK obj_conv;
27417         obj_conv.inner = (void*)(obj & (~1));
27418         obj_conv.is_owned = false;
27419         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27420         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
27421         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27422         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27423         CVec_u8Z_free(ret_var);
27424         return ret_arr;
27425 }
27426
27427 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
27428         LDKu8slice ser_ref;
27429         ser_ref.datalen = *((uint32_t*)ser);
27430         ser_ref.data = (int8_t*)(ser + 4);
27431         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
27432         *ret_conv = RevokeAndACK_read(ser_ref);
27433         return (uint64_t)ret_conv;
27434 }
27435
27436 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
27437         LDKShutdown obj_conv;
27438         obj_conv.inner = (void*)(obj & (~1));
27439         obj_conv.is_owned = false;
27440         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27441         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
27442         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27443         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27444         CVec_u8Z_free(ret_var);
27445         return ret_arr;
27446 }
27447
27448 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
27449         LDKu8slice ser_ref;
27450         ser_ref.datalen = *((uint32_t*)ser);
27451         ser_ref.data = (int8_t*)(ser + 4);
27452         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
27453         *ret_conv = Shutdown_read(ser_ref);
27454         return (uint64_t)ret_conv;
27455 }
27456
27457 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
27458         LDKUpdateFailHTLC obj_conv;
27459         obj_conv.inner = (void*)(obj & (~1));
27460         obj_conv.is_owned = false;
27461         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27462         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
27463         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27464         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27465         CVec_u8Z_free(ret_var);
27466         return ret_arr;
27467 }
27468
27469 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
27470         LDKu8slice ser_ref;
27471         ser_ref.datalen = *((uint32_t*)ser);
27472         ser_ref.data = (int8_t*)(ser + 4);
27473         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
27474         *ret_conv = UpdateFailHTLC_read(ser_ref);
27475         return (uint64_t)ret_conv;
27476 }
27477
27478 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
27479         LDKUpdateFailMalformedHTLC obj_conv;
27480         obj_conv.inner = (void*)(obj & (~1));
27481         obj_conv.is_owned = false;
27482         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27483         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
27484         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27485         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27486         CVec_u8Z_free(ret_var);
27487         return ret_arr;
27488 }
27489
27490 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
27491         LDKu8slice ser_ref;
27492         ser_ref.datalen = *((uint32_t*)ser);
27493         ser_ref.data = (int8_t*)(ser + 4);
27494         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
27495         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
27496         return (uint64_t)ret_conv;
27497 }
27498
27499 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
27500         LDKUpdateFee obj_conv;
27501         obj_conv.inner = (void*)(obj & (~1));
27502         obj_conv.is_owned = false;
27503         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27504         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
27505         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27506         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27507         CVec_u8Z_free(ret_var);
27508         return ret_arr;
27509 }
27510
27511 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
27512         LDKu8slice ser_ref;
27513         ser_ref.datalen = *((uint32_t*)ser);
27514         ser_ref.data = (int8_t*)(ser + 4);
27515         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
27516         *ret_conv = UpdateFee_read(ser_ref);
27517         return (uint64_t)ret_conv;
27518 }
27519
27520 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
27521         LDKUpdateFulfillHTLC obj_conv;
27522         obj_conv.inner = (void*)(obj & (~1));
27523         obj_conv.is_owned = false;
27524         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27525         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
27526         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27527         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27528         CVec_u8Z_free(ret_var);
27529         return ret_arr;
27530 }
27531
27532 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
27533         LDKu8slice ser_ref;
27534         ser_ref.datalen = *((uint32_t*)ser);
27535         ser_ref.data = (int8_t*)(ser + 4);
27536         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
27537         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
27538         return (uint64_t)ret_conv;
27539 }
27540
27541 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
27542         LDKUpdateAddHTLC obj_conv;
27543         obj_conv.inner = (void*)(obj & (~1));
27544         obj_conv.is_owned = false;
27545         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27546         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
27547         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27548         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27549         CVec_u8Z_free(ret_var);
27550         return ret_arr;
27551 }
27552
27553 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
27554         LDKu8slice ser_ref;
27555         ser_ref.datalen = *((uint32_t*)ser);
27556         ser_ref.data = (int8_t*)(ser + 4);
27557         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
27558         *ret_conv = UpdateAddHTLC_read(ser_ref);
27559         return (uint64_t)ret_conv;
27560 }
27561
27562 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
27563         LDKPing obj_conv;
27564         obj_conv.inner = (void*)(obj & (~1));
27565         obj_conv.is_owned = false;
27566         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27567         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
27568         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27569         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27570         CVec_u8Z_free(ret_var);
27571         return ret_arr;
27572 }
27573
27574 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
27575         LDKu8slice ser_ref;
27576         ser_ref.datalen = *((uint32_t*)ser);
27577         ser_ref.data = (int8_t*)(ser + 4);
27578         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
27579         *ret_conv = Ping_read(ser_ref);
27580         return (uint64_t)ret_conv;
27581 }
27582
27583 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
27584         LDKPong obj_conv;
27585         obj_conv.inner = (void*)(obj & (~1));
27586         obj_conv.is_owned = false;
27587         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27588         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
27589         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27590         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27591         CVec_u8Z_free(ret_var);
27592         return ret_arr;
27593 }
27594
27595 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
27596         LDKu8slice ser_ref;
27597         ser_ref.datalen = *((uint32_t*)ser);
27598         ser_ref.data = (int8_t*)(ser + 4);
27599         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
27600         *ret_conv = Pong_read(ser_ref);
27601         return (uint64_t)ret_conv;
27602 }
27603
27604 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
27605         LDKUnsignedChannelAnnouncement obj_conv;
27606         obj_conv.inner = (void*)(obj & (~1));
27607         obj_conv.is_owned = false;
27608         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27609         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
27610         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27611         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27612         CVec_u8Z_free(ret_var);
27613         return ret_arr;
27614 }
27615
27616 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
27617         LDKu8slice ser_ref;
27618         ser_ref.datalen = *((uint32_t*)ser);
27619         ser_ref.data = (int8_t*)(ser + 4);
27620         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
27621         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
27622         return (uint64_t)ret_conv;
27623 }
27624
27625 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
27626         LDKChannelAnnouncement obj_conv;
27627         obj_conv.inner = (void*)(obj & (~1));
27628         obj_conv.is_owned = false;
27629         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27630         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
27631         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27632         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27633         CVec_u8Z_free(ret_var);
27634         return ret_arr;
27635 }
27636
27637 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
27638         LDKu8slice ser_ref;
27639         ser_ref.datalen = *((uint32_t*)ser);
27640         ser_ref.data = (int8_t*)(ser + 4);
27641         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
27642         *ret_conv = ChannelAnnouncement_read(ser_ref);
27643         return (uint64_t)ret_conv;
27644 }
27645
27646 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
27647         LDKUnsignedChannelUpdate obj_conv;
27648         obj_conv.inner = (void*)(obj & (~1));
27649         obj_conv.is_owned = false;
27650         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27651         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
27652         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27653         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27654         CVec_u8Z_free(ret_var);
27655         return ret_arr;
27656 }
27657
27658 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
27659         LDKu8slice ser_ref;
27660         ser_ref.datalen = *((uint32_t*)ser);
27661         ser_ref.data = (int8_t*)(ser + 4);
27662         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
27663         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
27664         return (uint64_t)ret_conv;
27665 }
27666
27667 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
27668         LDKChannelUpdate obj_conv;
27669         obj_conv.inner = (void*)(obj & (~1));
27670         obj_conv.is_owned = false;
27671         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27672         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
27673         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27674         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27675         CVec_u8Z_free(ret_var);
27676         return ret_arr;
27677 }
27678
27679 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
27680         LDKu8slice ser_ref;
27681         ser_ref.datalen = *((uint32_t*)ser);
27682         ser_ref.data = (int8_t*)(ser + 4);
27683         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
27684         *ret_conv = ChannelUpdate_read(ser_ref);
27685         return (uint64_t)ret_conv;
27686 }
27687
27688 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
27689         LDKErrorMessage obj_conv;
27690         obj_conv.inner = (void*)(obj & (~1));
27691         obj_conv.is_owned = false;
27692         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27693         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
27694         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27695         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27696         CVec_u8Z_free(ret_var);
27697         return ret_arr;
27698 }
27699
27700 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
27701         LDKu8slice ser_ref;
27702         ser_ref.datalen = *((uint32_t*)ser);
27703         ser_ref.data = (int8_t*)(ser + 4);
27704         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
27705         *ret_conv = ErrorMessage_read(ser_ref);
27706         return (uint64_t)ret_conv;
27707 }
27708
27709 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
27710         LDKUnsignedNodeAnnouncement obj_conv;
27711         obj_conv.inner = (void*)(obj & (~1));
27712         obj_conv.is_owned = false;
27713         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27714         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
27715         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27716         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27717         CVec_u8Z_free(ret_var);
27718         return ret_arr;
27719 }
27720
27721 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
27722         LDKu8slice ser_ref;
27723         ser_ref.datalen = *((uint32_t*)ser);
27724         ser_ref.data = (int8_t*)(ser + 4);
27725         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
27726         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
27727         return (uint64_t)ret_conv;
27728 }
27729
27730 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
27731         LDKNodeAnnouncement obj_conv;
27732         obj_conv.inner = (void*)(obj & (~1));
27733         obj_conv.is_owned = false;
27734         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27735         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
27736         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27737         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27738         CVec_u8Z_free(ret_var);
27739         return ret_arr;
27740 }
27741
27742 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
27743         LDKu8slice ser_ref;
27744         ser_ref.datalen = *((uint32_t*)ser);
27745         ser_ref.data = (int8_t*)(ser + 4);
27746         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
27747         *ret_conv = NodeAnnouncement_read(ser_ref);
27748         return (uint64_t)ret_conv;
27749 }
27750
27751 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
27752         LDKu8slice ser_ref;
27753         ser_ref.datalen = *((uint32_t*)ser);
27754         ser_ref.data = (int8_t*)(ser + 4);
27755         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
27756         *ret_conv = QueryShortChannelIds_read(ser_ref);
27757         return (uint64_t)ret_conv;
27758 }
27759
27760 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
27761         LDKQueryShortChannelIds obj_conv;
27762         obj_conv.inner = (void*)(obj & (~1));
27763         obj_conv.is_owned = false;
27764         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27765         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
27766         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27767         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27768         CVec_u8Z_free(ret_var);
27769         return ret_arr;
27770 }
27771
27772 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
27773         LDKReplyShortChannelIdsEnd obj_conv;
27774         obj_conv.inner = (void*)(obj & (~1));
27775         obj_conv.is_owned = false;
27776         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27777         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
27778         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27779         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27780         CVec_u8Z_free(ret_var);
27781         return ret_arr;
27782 }
27783
27784 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
27785         LDKu8slice ser_ref;
27786         ser_ref.datalen = *((uint32_t*)ser);
27787         ser_ref.data = (int8_t*)(ser + 4);
27788         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
27789         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
27790         return (uint64_t)ret_conv;
27791 }
27792
27793 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
27794         LDKQueryChannelRange this_arg_conv;
27795         this_arg_conv.inner = (void*)(this_arg & (~1));
27796         this_arg_conv.is_owned = false;
27797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27798         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
27799         return ret_val;
27800 }
27801
27802 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
27803         LDKQueryChannelRange obj_conv;
27804         obj_conv.inner = (void*)(obj & (~1));
27805         obj_conv.is_owned = false;
27806         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27807         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
27808         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27809         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27810         CVec_u8Z_free(ret_var);
27811         return ret_arr;
27812 }
27813
27814 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
27815         LDKu8slice ser_ref;
27816         ser_ref.datalen = *((uint32_t*)ser);
27817         ser_ref.data = (int8_t*)(ser + 4);
27818         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
27819         *ret_conv = QueryChannelRange_read(ser_ref);
27820         return (uint64_t)ret_conv;
27821 }
27822
27823 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
27824         LDKu8slice ser_ref;
27825         ser_ref.datalen = *((uint32_t*)ser);
27826         ser_ref.data = (int8_t*)(ser + 4);
27827         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
27828         *ret_conv = ReplyChannelRange_read(ser_ref);
27829         return (uint64_t)ret_conv;
27830 }
27831
27832 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
27833         LDKReplyChannelRange obj_conv;
27834         obj_conv.inner = (void*)(obj & (~1));
27835         obj_conv.is_owned = false;
27836         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27837         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
27838         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27839         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27840         CVec_u8Z_free(ret_var);
27841         return ret_arr;
27842 }
27843
27844 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
27845         LDKGossipTimestampFilter obj_conv;
27846         obj_conv.inner = (void*)(obj & (~1));
27847         obj_conv.is_owned = false;
27848         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27849         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
27850         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27851         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27852         CVec_u8Z_free(ret_var);
27853         return ret_arr;
27854 }
27855
27856 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
27857         LDKu8slice ser_ref;
27858         ser_ref.datalen = *((uint32_t*)ser);
27859         ser_ref.data = (int8_t*)(ser + 4);
27860         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
27861         *ret_conv = GossipTimestampFilter_read(ser_ref);
27862         return (uint64_t)ret_conv;
27863 }
27864
27865 void  __attribute__((visibility("default"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
27866         if ((this_ptr & 1) != 0) return;
27867         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
27868         CHECK_ACCESS(this_ptr_ptr);
27869         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
27870         FREE((void*)this_ptr);
27871         CustomMessageHandler_free(this_ptr_conv);
27872 }
27873
27874 void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
27875         LDKIgnoringMessageHandler this_obj_conv;
27876         this_obj_conv.inner = (void*)(this_obj & (~1));
27877         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27879         IgnoringMessageHandler_free(this_obj_conv);
27880 }
27881
27882 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
27883         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
27884         uint64_t ret_ref = 0;
27885         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27886         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27888         ret_ref = (uint64_t)ret_var.inner;
27889         if (ret_var.is_owned) {
27890                 ret_ref |= 1;
27891         }
27892         return ret_ref;
27893 }
27894
27895 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
27896         LDKIgnoringMessageHandler this_arg_conv;
27897         this_arg_conv.inner = (void*)(this_arg & (~1));
27898         this_arg_conv.is_owned = false;
27899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27900         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
27901         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
27902         return (uint64_t)ret_ret;
27903 }
27904
27905 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
27906         LDKIgnoringMessageHandler this_arg_conv;
27907         this_arg_conv.inner = (void*)(this_arg & (~1));
27908         this_arg_conv.is_owned = false;
27909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27910         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
27911         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
27912         return (uint64_t)ret_ret;
27913 }
27914
27915 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
27916         LDKIgnoringMessageHandler this_arg_conv;
27917         this_arg_conv.inner = (void*)(this_arg & (~1));
27918         this_arg_conv.is_owned = false;
27919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27920         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
27921         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
27922         return (uint64_t)ret_ret;
27923 }
27924
27925 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
27926         LDKIgnoringMessageHandler this_arg_conv;
27927         this_arg_conv.inner = (void*)(this_arg & (~1));
27928         this_arg_conv.is_owned = false;
27929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27930         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
27931         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
27932         return (uint64_t)ret_ret;
27933 }
27934
27935 void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
27936         LDKErroringMessageHandler this_obj_conv;
27937         this_obj_conv.inner = (void*)(this_obj & (~1));
27938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27940         ErroringMessageHandler_free(this_obj_conv);
27941 }
27942
27943 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
27944         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
27945         uint64_t ret_ref = 0;
27946         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27947         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27949         ret_ref = (uint64_t)ret_var.inner;
27950         if (ret_var.is_owned) {
27951                 ret_ref |= 1;
27952         }
27953         return ret_ref;
27954 }
27955
27956 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
27957         LDKErroringMessageHandler this_arg_conv;
27958         this_arg_conv.inner = (void*)(this_arg & (~1));
27959         this_arg_conv.is_owned = false;
27960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27961         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
27962         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
27963         return (uint64_t)ret_ret;
27964 }
27965
27966 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
27967         LDKErroringMessageHandler this_arg_conv;
27968         this_arg_conv.inner = (void*)(this_arg & (~1));
27969         this_arg_conv.is_owned = false;
27970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27971         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
27972         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
27973         return (uint64_t)ret_ret;
27974 }
27975
27976 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) {
27977         LDKMessageHandler this_obj_conv;
27978         this_obj_conv.inner = (void*)(this_obj & (~1));
27979         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27981         MessageHandler_free(this_obj_conv);
27982 }
27983
27984 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
27985         LDKMessageHandler this_ptr_conv;
27986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27987         this_ptr_conv.is_owned = false;
27988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27989         // WARNING: This object doesn't live past this scope, needs clone!
27990         uint64_t ret_ret = ((uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
27991         return ret_ret;
27992 }
27993
27994 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
27995         LDKMessageHandler this_ptr_conv;
27996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27997         this_ptr_conv.is_owned = false;
27998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27999         void* val_ptr = (void*)(((uint64_t)val) & ~1);
28000         CHECK_ACCESS(val_ptr);
28001         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
28002         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
28003 }
28004
28005 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
28006         LDKMessageHandler this_ptr_conv;
28007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28008         this_ptr_conv.is_owned = false;
28009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28010         // WARNING: This object doesn't live past this scope, needs clone!
28011         uint64_t ret_ret = ((uint64_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
28012         return ret_ret;
28013 }
28014
28015 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
28016         LDKMessageHandler this_ptr_conv;
28017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28018         this_ptr_conv.is_owned = false;
28019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28020         void* val_ptr = (void*)(((uint64_t)val) & ~1);
28021         CHECK_ACCESS(val_ptr);
28022         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
28023         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
28024 }
28025
28026 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
28027         void* chan_handler_arg_ptr = (void*)(((uint64_t)chan_handler_arg) & ~1);
28028         CHECK_ACCESS(chan_handler_arg_ptr);
28029         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
28030         void* route_handler_arg_ptr = (void*)(((uint64_t)route_handler_arg) & ~1);
28031         CHECK_ACCESS(route_handler_arg_ptr);
28032         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
28033         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
28034         uint64_t ret_ref = 0;
28035         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28036         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28038         ret_ref = (uint64_t)ret_var.inner;
28039         if (ret_var.is_owned) {
28040                 ret_ref |= 1;
28041         }
28042         return ret_ref;
28043 }
28044
28045 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
28046         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
28047         *ret_ret = SocketDescriptor_clone(arg);
28048         return (uint64_t)ret_ret;
28049 }
28050 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
28051         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
28052         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
28053         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
28054         int64_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
28055         return ret_val;
28056 }
28057
28058 uint32_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
28059         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
28060         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
28061         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
28062         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
28063         *ret_ret = SocketDescriptor_clone(orig_conv);
28064         return (uint64_t)ret_ret;
28065 }
28066
28067 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
28068         if ((this_ptr & 1) != 0) return;
28069         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
28070         CHECK_ACCESS(this_ptr_ptr);
28071         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
28072         FREE((void*)this_ptr);
28073         SocketDescriptor_free(this_ptr_conv);
28074 }
28075
28076 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_obj) {
28077         LDKPeerHandleError this_obj_conv;
28078         this_obj_conv.inner = (void*)(this_obj & (~1));
28079         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28081         PeerHandleError_free(this_obj_conv);
28082 }
28083
28084 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
28085         LDKPeerHandleError this_ptr_conv;
28086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28087         this_ptr_conv.is_owned = false;
28088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28089         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
28090         return ret_val;
28091 }
28092
28093 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
28094         LDKPeerHandleError this_ptr_conv;
28095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28096         this_ptr_conv.is_owned = false;
28097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28098         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
28099 }
28100
28101 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
28102         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
28103         uint64_t ret_ref = 0;
28104         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28105         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28107         ret_ref = (uint64_t)ret_var.inner;
28108         if (ret_var.is_owned) {
28109                 ret_ref |= 1;
28110         }
28111         return ret_ref;
28112 }
28113
28114 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
28115         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
28116 uint64_t ret_ref = 0;
28117 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28118 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28119 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28120 ret_ref = (uint64_t)ret_var.inner;
28121 if (ret_var.is_owned) {
28122         ret_ref |= 1;
28123 }
28124         return ret_ref;
28125 }
28126 int64_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
28127         LDKPeerHandleError arg_conv;
28128         arg_conv.inner = (void*)(arg & (~1));
28129         arg_conv.is_owned = false;
28130         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28131         int64_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
28132         return ret_val;
28133 }
28134
28135 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32_t orig) {
28136         LDKPeerHandleError orig_conv;
28137         orig_conv.inner = (void*)(orig & (~1));
28138         orig_conv.is_owned = false;
28139         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28140         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
28141         uint64_t ret_ref = 0;
28142         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28143         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28145         ret_ref = (uint64_t)ret_var.inner;
28146         if (ret_var.is_owned) {
28147                 ret_ref |= 1;
28148         }
28149         return ret_ref;
28150 }
28151
28152 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_obj) {
28153         LDKPeerManager this_obj_conv;
28154         this_obj_conv.inner = (void*)(this_obj & (~1));
28155         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28157         PeerManager_free(this_obj_conv);
28158 }
28159
28160 uint32_t  __attribute__((visibility("default"))) 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) {
28161         LDKMessageHandler message_handler_conv;
28162         message_handler_conv.inner = (void*)(message_handler & (~1));
28163         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
28164         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
28165         // Warning: we need a move here but no clone is available for LDKMessageHandler
28166         LDKSecretKey our_node_secret_ref;
28167         CHECK(*((uint32_t*)our_node_secret) == 32);
28168         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
28169         unsigned char ephemeral_random_data_arr[32];
28170         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
28171         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
28172         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
28173         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
28174         CHECK_ACCESS(logger_ptr);
28175         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28176         void* custom_message_handler_ptr = (void*)(((uint64_t)custom_message_handler) & ~1);
28177         CHECK_ACCESS(custom_message_handler_ptr);
28178         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
28179         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
28180         uint64_t ret_ref = 0;
28181         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28182         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28184         ret_ref = (uint64_t)ret_var.inner;
28185         if (ret_var.is_owned) {
28186                 ret_ref |= 1;
28187         }
28188         return ret_ref;
28189 }
28190
28191 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
28192         LDKPeerManager this_arg_conv;
28193         this_arg_conv.inner = (void*)(this_arg & (~1));
28194         this_arg_conv.is_owned = false;
28195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28196         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
28197         ptrArray ret_arr = NULL;
28198         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
28199         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
28200         for (size_t m = 0; m < ret_var.datalen; m++) {
28201                 int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
28202                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
28203                 ret_arr_ptr[m] = ret_conv_12_arr;
28204         }
28205         
28206         FREE(ret_var.data);
28207         return ret_arr;
28208 }
28209
28210 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
28211         LDKPeerManager this_arg_conv;
28212         this_arg_conv.inner = (void*)(this_arg & (~1));
28213         this_arg_conv.is_owned = false;
28214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28215         LDKPublicKey their_node_id_ref;
28216         CHECK(*((uint32_t*)their_node_id) == 33);
28217         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
28218         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
28219         CHECK_ACCESS(descriptor_ptr);
28220         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
28221         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
28222         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
28223         return (uint64_t)ret_conv;
28224 }
28225
28226 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
28227         LDKPeerManager this_arg_conv;
28228         this_arg_conv.inner = (void*)(this_arg & (~1));
28229         this_arg_conv.is_owned = false;
28230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28231         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
28232         CHECK_ACCESS(descriptor_ptr);
28233         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
28234         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
28235         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
28236         return (uint64_t)ret_conv;
28237 }
28238
28239 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
28240         LDKPeerManager this_arg_conv;
28241         this_arg_conv.inner = (void*)(this_arg & (~1));
28242         this_arg_conv.is_owned = false;
28243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28244         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
28245         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
28246         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
28247         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
28248         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
28249         return (uint64_t)ret_conv;
28250 }
28251
28252 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
28253         LDKPeerManager this_arg_conv;
28254         this_arg_conv.inner = (void*)(this_arg & (~1));
28255         this_arg_conv.is_owned = false;
28256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28257         void* peer_descriptor_ptr = (void*)(((uint64_t)peer_descriptor) & ~1);
28258         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
28259         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
28260         LDKu8slice data_ref;
28261         data_ref.datalen = *((uint32_t*)data);
28262         data_ref.data = (int8_t*)(data + 4);
28263         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
28264         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
28265         return (uint64_t)ret_conv;
28266 }
28267
28268 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
28269         LDKPeerManager this_arg_conv;
28270         this_arg_conv.inner = (void*)(this_arg & (~1));
28271         this_arg_conv.is_owned = false;
28272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28273         PeerManager_process_events(&this_arg_conv);
28274 }
28275
28276 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
28277         LDKPeerManager this_arg_conv;
28278         this_arg_conv.inner = (void*)(this_arg & (~1));
28279         this_arg_conv.is_owned = false;
28280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28281         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
28282         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
28283         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
28284         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
28285 }
28286
28287 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
28288         LDKPeerManager this_arg_conv;
28289         this_arg_conv.inner = (void*)(this_arg & (~1));
28290         this_arg_conv.is_owned = false;
28291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28292         LDKPublicKey node_id_ref;
28293         CHECK(*((uint32_t*)node_id) == 33);
28294         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
28295         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
28296 }
28297
28298 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
28299         LDKPeerManager this_arg_conv;
28300         this_arg_conv.inner = (void*)(this_arg & (~1));
28301         this_arg_conv.is_owned = false;
28302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28303         PeerManager_disconnect_all_peers(&this_arg_conv);
28304 }
28305
28306 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
28307         LDKPeerManager this_arg_conv;
28308         this_arg_conv.inner = (void*)(this_arg & (~1));
28309         this_arg_conv.is_owned = false;
28310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28311         PeerManager_timer_tick_occurred(&this_arg_conv);
28312 }
28313
28314 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
28315         unsigned char commitment_seed_arr[32];
28316         CHECK(*((uint32_t*)commitment_seed) == 32);
28317         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
28318         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
28319         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
28320         memcpy((uint8_t*)(ret_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
28321         return ret_arr;
28322 }
28323
28324 int8_tArray  __attribute__((visibility("default"))) 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) {
28325         LDKCVec_u8Z to_holder_script_ref;
28326         to_holder_script_ref.datalen = *((uint32_t*)to_holder_script);
28327         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
28328         memcpy(to_holder_script_ref.data, (uint8_t*)(to_holder_script + 4), to_holder_script_ref.datalen);
28329         LDKCVec_u8Z to_counterparty_script_ref;
28330         to_counterparty_script_ref.datalen = *((uint32_t*)to_counterparty_script);
28331         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
28332         memcpy(to_counterparty_script_ref.data, (uint8_t*)(to_counterparty_script + 4), to_counterparty_script_ref.datalen);
28333         LDKOutPoint funding_outpoint_conv;
28334         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
28335         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
28336         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
28337         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
28338         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);
28339         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28340         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28341         Transaction_free(ret_var);
28342         return ret_arr;
28343 }
28344
28345 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
28346         LDKPublicKey per_commitment_point_ref;
28347         CHECK(*((uint32_t*)per_commitment_point) == 33);
28348         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
28349         unsigned char base_secret_arr[32];
28350         CHECK(*((uint32_t*)base_secret) == 32);
28351         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
28352         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
28353         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
28354         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
28355         return (uint64_t)ret_conv;
28356 }
28357
28358 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
28359         LDKPublicKey per_commitment_point_ref;
28360         CHECK(*((uint32_t*)per_commitment_point) == 33);
28361         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
28362         LDKPublicKey base_point_ref;
28363         CHECK(*((uint32_t*)base_point) == 33);
28364         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
28365         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
28366         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
28367         return (uint64_t)ret_conv;
28368 }
28369
28370 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
28371         unsigned char per_commitment_secret_arr[32];
28372         CHECK(*((uint32_t*)per_commitment_secret) == 32);
28373         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
28374         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
28375         unsigned char countersignatory_revocation_base_secret_arr[32];
28376         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
28377         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
28378         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
28379         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
28380         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
28381         return (uint64_t)ret_conv;
28382 }
28383
28384 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
28385         LDKPublicKey per_commitment_point_ref;
28386         CHECK(*((uint32_t*)per_commitment_point) == 33);
28387         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
28388         LDKPublicKey countersignatory_revocation_base_point_ref;
28389         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
28390         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
28391         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
28392         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
28393         return (uint64_t)ret_conv;
28394 }
28395
28396 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_obj) {
28397         LDKTxCreationKeys this_obj_conv;
28398         this_obj_conv.inner = (void*)(this_obj & (~1));
28399         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28401         TxCreationKeys_free(this_obj_conv);
28402 }
28403
28404 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
28405         LDKTxCreationKeys this_ptr_conv;
28406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28407         this_ptr_conv.is_owned = false;
28408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28409         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
28410         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28411         return ret_arr;
28412 }
28413
28414 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
28415         LDKTxCreationKeys this_ptr_conv;
28416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28417         this_ptr_conv.is_owned = false;
28418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28419         LDKPublicKey val_ref;
28420         CHECK(*((uint32_t*)val) == 33);
28421         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
28422         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
28423 }
28424
28425 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
28426         LDKTxCreationKeys this_ptr_conv;
28427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28428         this_ptr_conv.is_owned = false;
28429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28430         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
28431         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
28432         return ret_arr;
28433 }
28434
28435 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
28436         LDKTxCreationKeys this_ptr_conv;
28437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28438         this_ptr_conv.is_owned = false;
28439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28440         LDKPublicKey val_ref;
28441         CHECK(*((uint32_t*)val) == 33);
28442         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
28443         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
28444 }
28445
28446 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
28447         LDKTxCreationKeys this_ptr_conv;
28448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28449         this_ptr_conv.is_owned = false;
28450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28451         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
28452         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
28453         return ret_arr;
28454 }
28455
28456 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
28457         LDKTxCreationKeys this_ptr_conv;
28458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28459         this_ptr_conv.is_owned = false;
28460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28461         LDKPublicKey val_ref;
28462         CHECK(*((uint32_t*)val) == 33);
28463         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
28464         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
28465 }
28466
28467 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
28468         LDKTxCreationKeys this_ptr_conv;
28469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28470         this_ptr_conv.is_owned = false;
28471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28472         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
28473         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
28474         return ret_arr;
28475 }
28476
28477 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
28478         LDKTxCreationKeys this_ptr_conv;
28479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28480         this_ptr_conv.is_owned = false;
28481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28482         LDKPublicKey val_ref;
28483         CHECK(*((uint32_t*)val) == 33);
28484         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
28485         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
28486 }
28487
28488 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
28489         LDKTxCreationKeys this_ptr_conv;
28490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28491         this_ptr_conv.is_owned = false;
28492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28493         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
28494         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
28495         return ret_arr;
28496 }
28497
28498 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
28499         LDKTxCreationKeys this_ptr_conv;
28500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28501         this_ptr_conv.is_owned = false;
28502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28503         LDKPublicKey val_ref;
28504         CHECK(*((uint32_t*)val) == 33);
28505         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
28506         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
28507 }
28508
28509 uint32_t  __attribute__((visibility("default"))) 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) {
28510         LDKPublicKey per_commitment_point_arg_ref;
28511         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
28512         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
28513         LDKPublicKey revocation_key_arg_ref;
28514         CHECK(*((uint32_t*)revocation_key_arg) == 33);
28515         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
28516         LDKPublicKey broadcaster_htlc_key_arg_ref;
28517         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
28518         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
28519         LDKPublicKey countersignatory_htlc_key_arg_ref;
28520         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
28521         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
28522         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
28523         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
28524         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
28525         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);
28526         uint64_t ret_ref = 0;
28527         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28528         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28530         ret_ref = (uint64_t)ret_var.inner;
28531         if (ret_var.is_owned) {
28532                 ret_ref |= 1;
28533         }
28534         return ret_ref;
28535 }
28536
28537 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
28538         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
28539 uint64_t ret_ref = 0;
28540 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28541 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28542 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28543 ret_ref = (uint64_t)ret_var.inner;
28544 if (ret_var.is_owned) {
28545         ret_ref |= 1;
28546 }
28547         return ret_ref;
28548 }
28549 int64_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
28550         LDKTxCreationKeys arg_conv;
28551         arg_conv.inner = (void*)(arg & (~1));
28552         arg_conv.is_owned = false;
28553         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28554         int64_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
28555         return ret_val;
28556 }
28557
28558 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
28559         LDKTxCreationKeys orig_conv;
28560         orig_conv.inner = (void*)(orig & (~1));
28561         orig_conv.is_owned = false;
28562         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28563         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
28564         uint64_t ret_ref = 0;
28565         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28566         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28568         ret_ref = (uint64_t)ret_var.inner;
28569         if (ret_var.is_owned) {
28570                 ret_ref |= 1;
28571         }
28572         return ret_ref;
28573 }
28574
28575 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
28576         LDKTxCreationKeys obj_conv;
28577         obj_conv.inner = (void*)(obj & (~1));
28578         obj_conv.is_owned = false;
28579         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28580         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
28581         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28582         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28583         CVec_u8Z_free(ret_var);
28584         return ret_arr;
28585 }
28586
28587 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
28588         LDKu8slice ser_ref;
28589         ser_ref.datalen = *((uint32_t*)ser);
28590         ser_ref.data = (int8_t*)(ser + 4);
28591         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
28592         *ret_conv = TxCreationKeys_read(ser_ref);
28593         return (uint64_t)ret_conv;
28594 }
28595
28596 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
28597         LDKChannelPublicKeys this_obj_conv;
28598         this_obj_conv.inner = (void*)(this_obj & (~1));
28599         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28601         ChannelPublicKeys_free(this_obj_conv);
28602 }
28603
28604 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
28605         LDKChannelPublicKeys this_ptr_conv;
28606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28607         this_ptr_conv.is_owned = false;
28608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28609         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
28610         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
28611         return ret_arr;
28612 }
28613
28614 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
28615         LDKChannelPublicKeys this_ptr_conv;
28616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28617         this_ptr_conv.is_owned = false;
28618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28619         LDKPublicKey val_ref;
28620         CHECK(*((uint32_t*)val) == 33);
28621         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
28622         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
28623 }
28624
28625 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
28626         LDKChannelPublicKeys this_ptr_conv;
28627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28628         this_ptr_conv.is_owned = false;
28629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28630         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
28631         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
28632         return ret_arr;
28633 }
28634
28635 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
28636         LDKChannelPublicKeys this_ptr_conv;
28637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28638         this_ptr_conv.is_owned = false;
28639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28640         LDKPublicKey val_ref;
28641         CHECK(*((uint32_t*)val) == 33);
28642         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
28643         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
28644 }
28645
28646 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
28647         LDKChannelPublicKeys this_ptr_conv;
28648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28649         this_ptr_conv.is_owned = false;
28650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28651         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
28652         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
28653         return ret_arr;
28654 }
28655
28656 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
28657         LDKChannelPublicKeys this_ptr_conv;
28658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28659         this_ptr_conv.is_owned = false;
28660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28661         LDKPublicKey val_ref;
28662         CHECK(*((uint32_t*)val) == 33);
28663         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
28664         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
28665 }
28666
28667 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
28668         LDKChannelPublicKeys this_ptr_conv;
28669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28670         this_ptr_conv.is_owned = false;
28671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28672         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
28673         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
28674         return ret_arr;
28675 }
28676
28677 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
28678         LDKChannelPublicKeys this_ptr_conv;
28679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28680         this_ptr_conv.is_owned = false;
28681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28682         LDKPublicKey val_ref;
28683         CHECK(*((uint32_t*)val) == 33);
28684         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
28685         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
28686 }
28687
28688 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
28689         LDKChannelPublicKeys this_ptr_conv;
28690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28691         this_ptr_conv.is_owned = false;
28692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28693         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
28694         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
28695         return ret_arr;
28696 }
28697
28698 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
28699         LDKChannelPublicKeys this_ptr_conv;
28700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28701         this_ptr_conv.is_owned = false;
28702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28703         LDKPublicKey val_ref;
28704         CHECK(*((uint32_t*)val) == 33);
28705         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
28706         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
28707 }
28708
28709 uint32_t  __attribute__((visibility("default"))) 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) {
28710         LDKPublicKey funding_pubkey_arg_ref;
28711         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
28712         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
28713         LDKPublicKey revocation_basepoint_arg_ref;
28714         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
28715         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
28716         LDKPublicKey payment_point_arg_ref;
28717         CHECK(*((uint32_t*)payment_point_arg) == 33);
28718         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
28719         LDKPublicKey delayed_payment_basepoint_arg_ref;
28720         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
28721         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
28722         LDKPublicKey htlc_basepoint_arg_ref;
28723         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
28724         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
28725         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);
28726         uint64_t ret_ref = 0;
28727         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28728         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28730         ret_ref = (uint64_t)ret_var.inner;
28731         if (ret_var.is_owned) {
28732                 ret_ref |= 1;
28733         }
28734         return ret_ref;
28735 }
28736
28737 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
28738         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
28739 uint64_t ret_ref = 0;
28740 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28741 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28742 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28743 ret_ref = (uint64_t)ret_var.inner;
28744 if (ret_var.is_owned) {
28745         ret_ref |= 1;
28746 }
28747         return ret_ref;
28748 }
28749 int64_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
28750         LDKChannelPublicKeys arg_conv;
28751         arg_conv.inner = (void*)(arg & (~1));
28752         arg_conv.is_owned = false;
28753         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28754         int64_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
28755         return ret_val;
28756 }
28757
28758 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
28759         LDKChannelPublicKeys orig_conv;
28760         orig_conv.inner = (void*)(orig & (~1));
28761         orig_conv.is_owned = false;
28762         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28763         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
28764         uint64_t ret_ref = 0;
28765         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28766         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28768         ret_ref = (uint64_t)ret_var.inner;
28769         if (ret_var.is_owned) {
28770                 ret_ref |= 1;
28771         }
28772         return ret_ref;
28773 }
28774
28775 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
28776         LDKChannelPublicKeys obj_conv;
28777         obj_conv.inner = (void*)(obj & (~1));
28778         obj_conv.is_owned = false;
28779         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28780         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
28781         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28782         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28783         CVec_u8Z_free(ret_var);
28784         return ret_arr;
28785 }
28786
28787 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
28788         LDKu8slice ser_ref;
28789         ser_ref.datalen = *((uint32_t*)ser);
28790         ser_ref.data = (int8_t*)(ser + 4);
28791         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
28792         *ret_conv = ChannelPublicKeys_read(ser_ref);
28793         return (uint64_t)ret_conv;
28794 }
28795
28796 uint32_t  __attribute__((visibility("default"))) 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) {
28797         LDKPublicKey per_commitment_point_ref;
28798         CHECK(*((uint32_t*)per_commitment_point) == 33);
28799         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
28800         LDKPublicKey broadcaster_delayed_payment_base_ref;
28801         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
28802         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
28803         LDKPublicKey broadcaster_htlc_base_ref;
28804         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
28805         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
28806         LDKPublicKey countersignatory_revocation_base_ref;
28807         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
28808         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
28809         LDKPublicKey countersignatory_htlc_base_ref;
28810         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
28811         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
28812         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
28813         *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);
28814         return (uint64_t)ret_conv;
28815 }
28816
28817 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
28818         LDKPublicKey per_commitment_point_ref;
28819         CHECK(*((uint32_t*)per_commitment_point) == 33);
28820         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
28821         LDKChannelPublicKeys broadcaster_keys_conv;
28822         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
28823         broadcaster_keys_conv.is_owned = false;
28824         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
28825         LDKChannelPublicKeys countersignatory_keys_conv;
28826         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
28827         countersignatory_keys_conv.is_owned = false;
28828         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
28829         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
28830         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
28831         return (uint64_t)ret_conv;
28832 }
28833
28834 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
28835         LDKPublicKey revocation_key_ref;
28836         CHECK(*((uint32_t*)revocation_key) == 33);
28837         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
28838         LDKPublicKey broadcaster_delayed_payment_key_ref;
28839         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
28840         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
28841         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
28842         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28843         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28844         CVec_u8Z_free(ret_var);
28845         return ret_arr;
28846 }
28847
28848 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
28849         LDKHTLCOutputInCommitment this_obj_conv;
28850         this_obj_conv.inner = (void*)(this_obj & (~1));
28851         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28853         HTLCOutputInCommitment_free(this_obj_conv);
28854 }
28855
28856 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
28857         LDKHTLCOutputInCommitment 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         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
28862         return ret_val;
28863 }
28864
28865 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
28866         LDKHTLCOutputInCommitment this_ptr_conv;
28867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28868         this_ptr_conv.is_owned = false;
28869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28870         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
28871 }
28872
28873 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
28874         LDKHTLCOutputInCommitment this_ptr_conv;
28875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28876         this_ptr_conv.is_owned = false;
28877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28878         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
28879         return ret_val;
28880 }
28881
28882 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
28883         LDKHTLCOutputInCommitment this_ptr_conv;
28884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28885         this_ptr_conv.is_owned = false;
28886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28887         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
28888 }
28889
28890 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
28891         LDKHTLCOutputInCommitment this_ptr_conv;
28892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28893         this_ptr_conv.is_owned = false;
28894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28895         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
28896         return ret_val;
28897 }
28898
28899 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
28900         LDKHTLCOutputInCommitment this_ptr_conv;
28901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28902         this_ptr_conv.is_owned = false;
28903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28904         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
28905 }
28906
28907 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
28908         LDKHTLCOutputInCommitment this_ptr_conv;
28909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28910         this_ptr_conv.is_owned = false;
28911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28912         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
28913         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
28914         return ret_arr;
28915 }
28916
28917 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
28918         LDKHTLCOutputInCommitment this_ptr_conv;
28919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28920         this_ptr_conv.is_owned = false;
28921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28922         LDKThirtyTwoBytes val_ref;
28923         CHECK(*((uint32_t*)val) == 32);
28924         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
28925         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
28926 }
28927
28928 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
28929         LDKHTLCOutputInCommitment this_ptr_conv;
28930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28931         this_ptr_conv.is_owned = false;
28932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28933         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
28934         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
28935         uint64_t ret_ref = (uint64_t)ret_copy;
28936         return ret_ref;
28937 }
28938
28939 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
28940         LDKHTLCOutputInCommitment this_ptr_conv;
28941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28942         this_ptr_conv.is_owned = false;
28943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28944         void* val_ptr = (void*)(((uint64_t)val) & ~1);
28945         CHECK_ACCESS(val_ptr);
28946         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
28947         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
28948         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
28949 }
28950
28951 uint32_t  __attribute__((visibility("default"))) 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) {
28952         LDKThirtyTwoBytes payment_hash_arg_ref;
28953         CHECK(*((uint32_t*)payment_hash_arg) == 32);
28954         memcpy(payment_hash_arg_ref.data, (uint8_t*)(payment_hash_arg + 4), 32);
28955         void* transaction_output_index_arg_ptr = (void*)(((uint64_t)transaction_output_index_arg) & ~1);
28956         CHECK_ACCESS(transaction_output_index_arg_ptr);
28957         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
28958         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1));
28959         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
28960         uint64_t ret_ref = 0;
28961         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28962         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28964         ret_ref = (uint64_t)ret_var.inner;
28965         if (ret_var.is_owned) {
28966                 ret_ref |= 1;
28967         }
28968         return ret_ref;
28969 }
28970
28971 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
28972         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
28973 uint64_t ret_ref = 0;
28974 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28975 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28976 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28977 ret_ref = (uint64_t)ret_var.inner;
28978 if (ret_var.is_owned) {
28979         ret_ref |= 1;
28980 }
28981         return ret_ref;
28982 }
28983 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
28984         LDKHTLCOutputInCommitment arg_conv;
28985         arg_conv.inner = (void*)(arg & (~1));
28986         arg_conv.is_owned = false;
28987         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28988         int64_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
28989         return ret_val;
28990 }
28991
28992 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
28993         LDKHTLCOutputInCommitment orig_conv;
28994         orig_conv.inner = (void*)(orig & (~1));
28995         orig_conv.is_owned = false;
28996         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28997         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
28998         uint64_t ret_ref = 0;
28999         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29000         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29002         ret_ref = (uint64_t)ret_var.inner;
29003         if (ret_var.is_owned) {
29004                 ret_ref |= 1;
29005         }
29006         return ret_ref;
29007 }
29008
29009 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
29010         LDKHTLCOutputInCommitment obj_conv;
29011         obj_conv.inner = (void*)(obj & (~1));
29012         obj_conv.is_owned = false;
29013         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29014         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
29015         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29016         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29017         CVec_u8Z_free(ret_var);
29018         return ret_arr;
29019 }
29020
29021 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
29022         LDKu8slice ser_ref;
29023         ser_ref.datalen = *((uint32_t*)ser);
29024         ser_ref.data = (int8_t*)(ser + 4);
29025         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
29026         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
29027         return (uint64_t)ret_conv;
29028 }
29029
29030 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
29031         LDKHTLCOutputInCommitment htlc_conv;
29032         htlc_conv.inner = (void*)(htlc & (~1));
29033         htlc_conv.is_owned = false;
29034         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
29035         LDKTxCreationKeys keys_conv;
29036         keys_conv.inner = (void*)(keys & (~1));
29037         keys_conv.is_owned = false;
29038         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
29039         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
29040         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29041         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29042         CVec_u8Z_free(ret_var);
29043         return ret_arr;
29044 }
29045
29046 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
29047         LDKPublicKey broadcaster_ref;
29048         CHECK(*((uint32_t*)broadcaster) == 33);
29049         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
29050         LDKPublicKey countersignatory_ref;
29051         CHECK(*((uint32_t*)countersignatory) == 33);
29052         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
29053         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
29054         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29055         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29056         CVec_u8Z_free(ret_var);
29057         return ret_arr;
29058 }
29059
29060 int8_tArray  __attribute__((visibility("default"))) TS_build_htlc_transaction(int8_tArray commitment_txid, int32_t feerate_per_kw, int16_t contest_delay, uint32_t htlc, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
29061         unsigned char commitment_txid_arr[32];
29062         CHECK(*((uint32_t*)commitment_txid) == 32);
29063         memcpy(commitment_txid_arr, (uint8_t*)(commitment_txid + 4), 32);
29064         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
29065         LDKHTLCOutputInCommitment htlc_conv;
29066         htlc_conv.inner = (void*)(htlc & (~1));
29067         htlc_conv.is_owned = false;
29068         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
29069         LDKPublicKey broadcaster_delayed_payment_key_ref;
29070         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
29071         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
29072         LDKPublicKey revocation_key_ref;
29073         CHECK(*((uint32_t*)revocation_key) == 33);
29074         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
29075         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
29076         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29077         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29078         Transaction_free(ret_var);
29079         return ret_arr;
29080 }
29081
29082 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
29083         LDKChannelTransactionParameters this_obj_conv;
29084         this_obj_conv.inner = (void*)(this_obj & (~1));
29085         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29087         ChannelTransactionParameters_free(this_obj_conv);
29088 }
29089
29090 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
29091         LDKChannelTransactionParameters this_ptr_conv;
29092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29093         this_ptr_conv.is_owned = false;
29094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29095         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
29096         uint64_t ret_ref = 0;
29097         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29098         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29100         ret_ref = (uint64_t)ret_var.inner;
29101         if (ret_var.is_owned) {
29102                 ret_ref |= 1;
29103         }
29104         return ret_ref;
29105 }
29106
29107 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
29108         LDKChannelTransactionParameters this_ptr_conv;
29109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29110         this_ptr_conv.is_owned = false;
29111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29112         LDKChannelPublicKeys val_conv;
29113         val_conv.inner = (void*)(val & (~1));
29114         val_conv.is_owned = (val & 1) || (val == 0);
29115         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29116         val_conv = ChannelPublicKeys_clone(&val_conv);
29117         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
29118 }
29119
29120 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
29121         LDKChannelTransactionParameters this_ptr_conv;
29122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29123         this_ptr_conv.is_owned = false;
29124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29125         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
29126         return ret_val;
29127 }
29128
29129 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
29130         LDKChannelTransactionParameters this_ptr_conv;
29131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29132         this_ptr_conv.is_owned = false;
29133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29134         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
29135 }
29136
29137 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
29138         LDKChannelTransactionParameters this_ptr_conv;
29139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29140         this_ptr_conv.is_owned = false;
29141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29142         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
29143         return ret_val;
29144 }
29145
29146 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
29147         LDKChannelTransactionParameters this_ptr_conv;
29148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29149         this_ptr_conv.is_owned = false;
29150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29151         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
29152 }
29153
29154 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
29155         LDKChannelTransactionParameters this_ptr_conv;
29156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29157         this_ptr_conv.is_owned = false;
29158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29159         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
29160         uint64_t ret_ref = 0;
29161         if ((uint64_t)ret_var.inner > 4096) {
29162                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29163                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29165                 ret_ref = (uint64_t)ret_var.inner;
29166                 if (ret_var.is_owned) {
29167                         ret_ref |= 1;
29168                 }
29169         }
29170         return ret_ref;
29171 }
29172
29173 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
29174         LDKChannelTransactionParameters this_ptr_conv;
29175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29176         this_ptr_conv.is_owned = false;
29177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29178         LDKCounterpartyChannelTransactionParameters val_conv;
29179         val_conv.inner = (void*)(val & (~1));
29180         val_conv.is_owned = (val & 1) || (val == 0);
29181         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29182         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
29183         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
29184 }
29185
29186 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
29187         LDKChannelTransactionParameters this_ptr_conv;
29188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29189         this_ptr_conv.is_owned = false;
29190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29191         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
29192         uint64_t ret_ref = 0;
29193         if ((uint64_t)ret_var.inner > 4096) {
29194                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29195                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29197                 ret_ref = (uint64_t)ret_var.inner;
29198                 if (ret_var.is_owned) {
29199                         ret_ref |= 1;
29200                 }
29201         }
29202         return ret_ref;
29203 }
29204
29205 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
29206         LDKChannelTransactionParameters this_ptr_conv;
29207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29208         this_ptr_conv.is_owned = false;
29209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29210         LDKOutPoint val_conv;
29211         val_conv.inner = (void*)(val & (~1));
29212         val_conv.is_owned = (val & 1) || (val == 0);
29213         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29214         val_conv = OutPoint_clone(&val_conv);
29215         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
29216 }
29217
29218 uint32_t  __attribute__((visibility("default"))) 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) {
29219         LDKChannelPublicKeys holder_pubkeys_arg_conv;
29220         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
29221         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
29222         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
29223         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
29224         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
29225         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
29226         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
29227         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
29228         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
29229         LDKOutPoint funding_outpoint_arg_conv;
29230         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
29231         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
29232         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
29233         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
29234         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);
29235         uint64_t ret_ref = 0;
29236         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29237         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29239         ret_ref = (uint64_t)ret_var.inner;
29240         if (ret_var.is_owned) {
29241                 ret_ref |= 1;
29242         }
29243         return ret_ref;
29244 }
29245
29246 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
29247         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
29248 uint64_t ret_ref = 0;
29249 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29250 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29251 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29252 ret_ref = (uint64_t)ret_var.inner;
29253 if (ret_var.is_owned) {
29254         ret_ref |= 1;
29255 }
29256         return ret_ref;
29257 }
29258 int64_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
29259         LDKChannelTransactionParameters arg_conv;
29260         arg_conv.inner = (void*)(arg & (~1));
29261         arg_conv.is_owned = false;
29262         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29263         int64_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
29264         return ret_val;
29265 }
29266
29267 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
29268         LDKChannelTransactionParameters orig_conv;
29269         orig_conv.inner = (void*)(orig & (~1));
29270         orig_conv.is_owned = false;
29271         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29272         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
29273         uint64_t ret_ref = 0;
29274         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29275         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29277         ret_ref = (uint64_t)ret_var.inner;
29278         if (ret_var.is_owned) {
29279                 ret_ref |= 1;
29280         }
29281         return ret_ref;
29282 }
29283
29284 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
29285         LDKCounterpartyChannelTransactionParameters this_obj_conv;
29286         this_obj_conv.inner = (void*)(this_obj & (~1));
29287         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29289         CounterpartyChannelTransactionParameters_free(this_obj_conv);
29290 }
29291
29292 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
29293         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29295         this_ptr_conv.is_owned = false;
29296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29297         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
29298         uint64_t ret_ref = 0;
29299         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29300         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29302         ret_ref = (uint64_t)ret_var.inner;
29303         if (ret_var.is_owned) {
29304                 ret_ref |= 1;
29305         }
29306         return ret_ref;
29307 }
29308
29309 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
29310         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29312         this_ptr_conv.is_owned = false;
29313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29314         LDKChannelPublicKeys val_conv;
29315         val_conv.inner = (void*)(val & (~1));
29316         val_conv.is_owned = (val & 1) || (val == 0);
29317         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29318         val_conv = ChannelPublicKeys_clone(&val_conv);
29319         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
29320 }
29321
29322 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
29323         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29325         this_ptr_conv.is_owned = false;
29326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29327         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
29328         return ret_val;
29329 }
29330
29331 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
29332         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29334         this_ptr_conv.is_owned = false;
29335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29336         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
29337 }
29338
29339 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
29340         LDKChannelPublicKeys pubkeys_arg_conv;
29341         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
29342         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
29343         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
29344         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
29345         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
29346         uint64_t ret_ref = 0;
29347         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29348         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29350         ret_ref = (uint64_t)ret_var.inner;
29351         if (ret_var.is_owned) {
29352                 ret_ref |= 1;
29353         }
29354         return ret_ref;
29355 }
29356
29357 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
29358         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
29359 uint64_t ret_ref = 0;
29360 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29361 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29362 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29363 ret_ref = (uint64_t)ret_var.inner;
29364 if (ret_var.is_owned) {
29365         ret_ref |= 1;
29366 }
29367         return ret_ref;
29368 }
29369 int64_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
29370         LDKCounterpartyChannelTransactionParameters arg_conv;
29371         arg_conv.inner = (void*)(arg & (~1));
29372         arg_conv.is_owned = false;
29373         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29374         int64_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
29375         return ret_val;
29376 }
29377
29378 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
29379         LDKCounterpartyChannelTransactionParameters orig_conv;
29380         orig_conv.inner = (void*)(orig & (~1));
29381         orig_conv.is_owned = false;
29382         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29383         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
29384         uint64_t ret_ref = 0;
29385         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29386         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29388         ret_ref = (uint64_t)ret_var.inner;
29389         if (ret_var.is_owned) {
29390                 ret_ref |= 1;
29391         }
29392         return ret_ref;
29393 }
29394
29395 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
29396         LDKChannelTransactionParameters this_arg_conv;
29397         this_arg_conv.inner = (void*)(this_arg & (~1));
29398         this_arg_conv.is_owned = false;
29399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29400         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
29401         return ret_val;
29402 }
29403
29404 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
29405         LDKChannelTransactionParameters this_arg_conv;
29406         this_arg_conv.inner = (void*)(this_arg & (~1));
29407         this_arg_conv.is_owned = false;
29408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29409         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
29410         uint64_t ret_ref = 0;
29411         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29412         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29414         ret_ref = (uint64_t)ret_var.inner;
29415         if (ret_var.is_owned) {
29416                 ret_ref |= 1;
29417         }
29418         return ret_ref;
29419 }
29420
29421 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
29422         LDKChannelTransactionParameters this_arg_conv;
29423         this_arg_conv.inner = (void*)(this_arg & (~1));
29424         this_arg_conv.is_owned = false;
29425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29426         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
29427         uint64_t ret_ref = 0;
29428         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29429         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29431         ret_ref = (uint64_t)ret_var.inner;
29432         if (ret_var.is_owned) {
29433                 ret_ref |= 1;
29434         }
29435         return ret_ref;
29436 }
29437
29438 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
29439         LDKCounterpartyChannelTransactionParameters obj_conv;
29440         obj_conv.inner = (void*)(obj & (~1));
29441         obj_conv.is_owned = false;
29442         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29443         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
29444         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29445         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29446         CVec_u8Z_free(ret_var);
29447         return ret_arr;
29448 }
29449
29450 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
29451         LDKu8slice ser_ref;
29452         ser_ref.datalen = *((uint32_t*)ser);
29453         ser_ref.data = (int8_t*)(ser + 4);
29454         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
29455         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
29456         return (uint64_t)ret_conv;
29457 }
29458
29459 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
29460         LDKChannelTransactionParameters obj_conv;
29461         obj_conv.inner = (void*)(obj & (~1));
29462         obj_conv.is_owned = false;
29463         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29464         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
29465         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29466         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29467         CVec_u8Z_free(ret_var);
29468         return ret_arr;
29469 }
29470
29471 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
29472         LDKu8slice ser_ref;
29473         ser_ref.datalen = *((uint32_t*)ser);
29474         ser_ref.data = (int8_t*)(ser + 4);
29475         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
29476         *ret_conv = ChannelTransactionParameters_read(ser_ref);
29477         return (uint64_t)ret_conv;
29478 }
29479
29480 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
29481         LDKDirectedChannelTransactionParameters this_obj_conv;
29482         this_obj_conv.inner = (void*)(this_obj & (~1));
29483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29485         DirectedChannelTransactionParameters_free(this_obj_conv);
29486 }
29487
29488 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
29489         LDKDirectedChannelTransactionParameters this_arg_conv;
29490         this_arg_conv.inner = (void*)(this_arg & (~1));
29491         this_arg_conv.is_owned = false;
29492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29493         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
29494         uint64_t ret_ref = 0;
29495         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29496         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29498         ret_ref = (uint64_t)ret_var.inner;
29499         if (ret_var.is_owned) {
29500                 ret_ref |= 1;
29501         }
29502         return ret_ref;
29503 }
29504
29505 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
29506         LDKDirectedChannelTransactionParameters this_arg_conv;
29507         this_arg_conv.inner = (void*)(this_arg & (~1));
29508         this_arg_conv.is_owned = false;
29509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29510         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
29511         uint64_t ret_ref = 0;
29512         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29513         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29515         ret_ref = (uint64_t)ret_var.inner;
29516         if (ret_var.is_owned) {
29517                 ret_ref |= 1;
29518         }
29519         return ret_ref;
29520 }
29521
29522 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
29523         LDKDirectedChannelTransactionParameters this_arg_conv;
29524         this_arg_conv.inner = (void*)(this_arg & (~1));
29525         this_arg_conv.is_owned = false;
29526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29527         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
29528         return ret_val;
29529 }
29530
29531 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
29532         LDKDirectedChannelTransactionParameters this_arg_conv;
29533         this_arg_conv.inner = (void*)(this_arg & (~1));
29534         this_arg_conv.is_owned = false;
29535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29536         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
29537         return ret_val;
29538 }
29539
29540 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
29541         LDKDirectedChannelTransactionParameters this_arg_conv;
29542         this_arg_conv.inner = (void*)(this_arg & (~1));
29543         this_arg_conv.is_owned = false;
29544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29545         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
29546         uint64_t ret_ref = 0;
29547         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29548         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29550         ret_ref = (uint64_t)ret_var.inner;
29551         if (ret_var.is_owned) {
29552                 ret_ref |= 1;
29553         }
29554         return ret_ref;
29555 }
29556
29557 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
29558         LDKHolderCommitmentTransaction this_obj_conv;
29559         this_obj_conv.inner = (void*)(this_obj & (~1));
29560         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29562         HolderCommitmentTransaction_free(this_obj_conv);
29563 }
29564
29565 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
29566         LDKHolderCommitmentTransaction this_ptr_conv;
29567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29568         this_ptr_conv.is_owned = false;
29569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29570         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
29571         memcpy((uint8_t*)(ret_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
29572         return ret_arr;
29573 }
29574
29575 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
29576         LDKHolderCommitmentTransaction this_ptr_conv;
29577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29578         this_ptr_conv.is_owned = false;
29579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29580         LDKSignature val_ref;
29581         CHECK(*((uint32_t*)val) == 64);
29582         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
29583         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
29584 }
29585
29586 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
29587         LDKHolderCommitmentTransaction this_ptr_conv;
29588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29589         this_ptr_conv.is_owned = false;
29590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29591         LDKCVec_SignatureZ val_constr;
29592         val_constr.datalen = *((uint32_t*)val);
29593         if (val_constr.datalen > 0)
29594                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
29595         else
29596                 val_constr.data = NULL;
29597         int8_tArray* val_vals = (int8_tArray*)(val + 4);
29598         for (size_t m = 0; m < val_constr.datalen; m++) {
29599                 int8_tArray val_conv_12 = val_vals[m];
29600                 LDKSignature val_conv_12_ref;
29601                 CHECK(*((uint32_t*)val_conv_12) == 64);
29602                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
29603                 val_constr.data[m] = val_conv_12_ref;
29604         }
29605         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
29606 }
29607
29608 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
29609         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
29610 uint64_t ret_ref = 0;
29611 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29612 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29613 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29614 ret_ref = (uint64_t)ret_var.inner;
29615 if (ret_var.is_owned) {
29616         ret_ref |= 1;
29617 }
29618         return ret_ref;
29619 }
29620 int64_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
29621         LDKHolderCommitmentTransaction arg_conv;
29622         arg_conv.inner = (void*)(arg & (~1));
29623         arg_conv.is_owned = false;
29624         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29625         int64_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
29626         return ret_val;
29627 }
29628
29629 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
29630         LDKHolderCommitmentTransaction orig_conv;
29631         orig_conv.inner = (void*)(orig & (~1));
29632         orig_conv.is_owned = false;
29633         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29634         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
29635         uint64_t ret_ref = 0;
29636         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29637         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29639         ret_ref = (uint64_t)ret_var.inner;
29640         if (ret_var.is_owned) {
29641                 ret_ref |= 1;
29642         }
29643         return ret_ref;
29644 }
29645
29646 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
29647         LDKHolderCommitmentTransaction obj_conv;
29648         obj_conv.inner = (void*)(obj & (~1));
29649         obj_conv.is_owned = false;
29650         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29651         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
29652         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29653         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29654         CVec_u8Z_free(ret_var);
29655         return ret_arr;
29656 }
29657
29658 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
29659         LDKu8slice ser_ref;
29660         ser_ref.datalen = *((uint32_t*)ser);
29661         ser_ref.data = (int8_t*)(ser + 4);
29662         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
29663         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
29664         return (uint64_t)ret_conv;
29665 }
29666
29667 uint32_t  __attribute__((visibility("default"))) 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) {
29668         LDKCommitmentTransaction commitment_tx_conv;
29669         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
29670         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
29671         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
29672         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
29673         LDKSignature counterparty_sig_ref;
29674         CHECK(*((uint32_t*)counterparty_sig) == 64);
29675         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
29676         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
29677         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
29678         if (counterparty_htlc_sigs_constr.datalen > 0)
29679                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
29680         else
29681                 counterparty_htlc_sigs_constr.data = NULL;
29682         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
29683         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
29684                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
29685                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
29686                 CHECK(*((uint32_t*)counterparty_htlc_sigs_conv_12) == 64);
29687                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, (uint8_t*)(counterparty_htlc_sigs_conv_12 + 4), 64);
29688                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
29689         }
29690         LDKPublicKey holder_funding_key_ref;
29691         CHECK(*((uint32_t*)holder_funding_key) == 33);
29692         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
29693         LDKPublicKey counterparty_funding_key_ref;
29694         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
29695         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
29696         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
29697         uint64_t ret_ref = 0;
29698         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29699         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29700         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29701         ret_ref = (uint64_t)ret_var.inner;
29702         if (ret_var.is_owned) {
29703                 ret_ref |= 1;
29704         }
29705         return ret_ref;
29706 }
29707
29708 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
29709         LDKBuiltCommitmentTransaction this_obj_conv;
29710         this_obj_conv.inner = (void*)(this_obj & (~1));
29711         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29713         BuiltCommitmentTransaction_free(this_obj_conv);
29714 }
29715
29716 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
29717         LDKBuiltCommitmentTransaction this_ptr_conv;
29718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29719         this_ptr_conv.is_owned = false;
29720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29721         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
29722         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29723         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29724         Transaction_free(ret_var);
29725         return ret_arr;
29726 }
29727
29728 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
29729         LDKBuiltCommitmentTransaction this_ptr_conv;
29730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29731         this_ptr_conv.is_owned = false;
29732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29733         LDKTransaction val_ref;
29734         val_ref.datalen = *((uint32_t*)val);
29735         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
29736         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
29737         val_ref.data_is_owned = true;
29738         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
29739 }
29740
29741 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
29742         LDKBuiltCommitmentTransaction this_ptr_conv;
29743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29744         this_ptr_conv.is_owned = false;
29745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29746         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
29747         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
29748         return ret_arr;
29749 }
29750
29751 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
29752         LDKBuiltCommitmentTransaction this_ptr_conv;
29753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29754         this_ptr_conv.is_owned = false;
29755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29756         LDKThirtyTwoBytes val_ref;
29757         CHECK(*((uint32_t*)val) == 32);
29758         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
29759         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
29760 }
29761
29762 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
29763         LDKTransaction transaction_arg_ref;
29764         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
29765         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
29766         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
29767         transaction_arg_ref.data_is_owned = true;
29768         LDKThirtyTwoBytes txid_arg_ref;
29769         CHECK(*((uint32_t*)txid_arg) == 32);
29770         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
29771         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
29772         uint64_t ret_ref = 0;
29773         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29774         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29776         ret_ref = (uint64_t)ret_var.inner;
29777         if (ret_var.is_owned) {
29778                 ret_ref |= 1;
29779         }
29780         return ret_ref;
29781 }
29782
29783 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
29784         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
29785 uint64_t ret_ref = 0;
29786 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29787 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29788 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29789 ret_ref = (uint64_t)ret_var.inner;
29790 if (ret_var.is_owned) {
29791         ret_ref |= 1;
29792 }
29793         return ret_ref;
29794 }
29795 int64_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
29796         LDKBuiltCommitmentTransaction arg_conv;
29797         arg_conv.inner = (void*)(arg & (~1));
29798         arg_conv.is_owned = false;
29799         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29800         int64_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
29801         return ret_val;
29802 }
29803
29804 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
29805         LDKBuiltCommitmentTransaction orig_conv;
29806         orig_conv.inner = (void*)(orig & (~1));
29807         orig_conv.is_owned = false;
29808         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29809         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
29810         uint64_t ret_ref = 0;
29811         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29812         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29814         ret_ref = (uint64_t)ret_var.inner;
29815         if (ret_var.is_owned) {
29816                 ret_ref |= 1;
29817         }
29818         return ret_ref;
29819 }
29820
29821 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
29822         LDKBuiltCommitmentTransaction obj_conv;
29823         obj_conv.inner = (void*)(obj & (~1));
29824         obj_conv.is_owned = false;
29825         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29826         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
29827         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29828         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29829         CVec_u8Z_free(ret_var);
29830         return ret_arr;
29831 }
29832
29833 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
29834         LDKu8slice ser_ref;
29835         ser_ref.datalen = *((uint32_t*)ser);
29836         ser_ref.data = (int8_t*)(ser + 4);
29837         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
29838         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
29839         return (uint64_t)ret_conv;
29840 }
29841
29842 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
29843         LDKBuiltCommitmentTransaction this_arg_conv;
29844         this_arg_conv.inner = (void*)(this_arg & (~1));
29845         this_arg_conv.is_owned = false;
29846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29847         LDKu8slice funding_redeemscript_ref;
29848         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
29849         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
29850         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
29851         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
29852         return ret_arr;
29853 }
29854
29855 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_sign(uint32_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
29856         LDKBuiltCommitmentTransaction this_arg_conv;
29857         this_arg_conv.inner = (void*)(this_arg & (~1));
29858         this_arg_conv.is_owned = false;
29859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29860         unsigned char funding_key_arr[32];
29861         CHECK(*((uint32_t*)funding_key) == 32);
29862         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
29863         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
29864         LDKu8slice funding_redeemscript_ref;
29865         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
29866         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
29867         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
29868         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
29869         return ret_arr;
29870 }
29871
29872 void  __attribute__((visibility("default"))) TS_ClosingTransaction_free(uint32_t this_obj) {
29873         LDKClosingTransaction this_obj_conv;
29874         this_obj_conv.inner = (void*)(this_obj & (~1));
29875         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29877         ClosingTransaction_free(this_obj_conv);
29878 }
29879
29880 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
29881         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
29882 uint64_t ret_ref = 0;
29883 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29884 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29885 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29886 ret_ref = (uint64_t)ret_var.inner;
29887 if (ret_var.is_owned) {
29888         ret_ref |= 1;
29889 }
29890         return ret_ref;
29891 }
29892 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
29893         LDKClosingTransaction arg_conv;
29894         arg_conv.inner = (void*)(arg & (~1));
29895         arg_conv.is_owned = false;
29896         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29897         int64_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
29898         return ret_val;
29899 }
29900
29901 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_clone(uint32_t orig) {
29902         LDKClosingTransaction orig_conv;
29903         orig_conv.inner = (void*)(orig & (~1));
29904         orig_conv.is_owned = false;
29905         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29906         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
29907         uint64_t ret_ref = 0;
29908         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29909         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29911         ret_ref = (uint64_t)ret_var.inner;
29912         if (ret_var.is_owned) {
29913                 ret_ref |= 1;
29914         }
29915         return ret_ref;
29916 }
29917
29918 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_hash(uint32_t o) {
29919         LDKClosingTransaction o_conv;
29920         o_conv.inner = (void*)(o & (~1));
29921         o_conv.is_owned = false;
29922         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29923         int64_t ret_val = ClosingTransaction_hash(&o_conv);
29924         return ret_val;
29925 }
29926
29927 uint32_t  __attribute__((visibility("default"))) 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) {
29928         LDKCVec_u8Z to_holder_script_ref;
29929         to_holder_script_ref.datalen = *((uint32_t*)to_holder_script);
29930         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
29931         memcpy(to_holder_script_ref.data, (uint8_t*)(to_holder_script + 4), to_holder_script_ref.datalen);
29932         LDKCVec_u8Z to_counterparty_script_ref;
29933         to_counterparty_script_ref.datalen = *((uint32_t*)to_counterparty_script);
29934         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
29935         memcpy(to_counterparty_script_ref.data, (uint8_t*)(to_counterparty_script + 4), to_counterparty_script_ref.datalen);
29936         LDKOutPoint funding_outpoint_conv;
29937         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
29938         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
29939         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
29940         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
29941         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
29942         uint64_t ret_ref = 0;
29943         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29944         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29946         ret_ref = (uint64_t)ret_var.inner;
29947         if (ret_var.is_owned) {
29948                 ret_ref |= 1;
29949         }
29950         return ret_ref;
29951 }
29952
29953 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
29954         LDKClosingTransaction this_arg_conv;
29955         this_arg_conv.inner = (void*)(this_arg & (~1));
29956         this_arg_conv.is_owned = false;
29957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29958         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
29959         uint64_t ret_ref = 0;
29960         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29961         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29963         ret_ref = (uint64_t)ret_var.inner;
29964         if (ret_var.is_owned) {
29965                 ret_ref |= 1;
29966         }
29967         return ret_ref;
29968 }
29969
29970 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
29971         LDKClosingTransaction this_arg_conv;
29972         this_arg_conv.inner = (void*)(this_arg & (~1));
29973         this_arg_conv.is_owned = false;
29974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29975         LDKOutPoint funding_outpoint_conv;
29976         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
29977         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
29978         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
29979         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
29980         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
29981         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
29982         return (uint64_t)ret_conv;
29983 }
29984
29985 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
29986         LDKClosingTransaction this_arg_conv;
29987         this_arg_conv.inner = (void*)(this_arg & (~1));
29988         this_arg_conv.is_owned = false;
29989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29990         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
29991         return ret_val;
29992 }
29993
29994 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
29995         LDKClosingTransaction this_arg_conv;
29996         this_arg_conv.inner = (void*)(this_arg & (~1));
29997         this_arg_conv.is_owned = false;
29998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29999         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
30000         return ret_val;
30001 }
30002
30003 int8_tArray  __attribute__((visibility("default"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
30004         LDKClosingTransaction this_arg_conv;
30005         this_arg_conv.inner = (void*)(this_arg & (~1));
30006         this_arg_conv.is_owned = false;
30007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30008         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
30009         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30010         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30011         return ret_arr;
30012 }
30013
30014 int8_tArray  __attribute__((visibility("default"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
30015         LDKClosingTransaction this_arg_conv;
30016         this_arg_conv.inner = (void*)(this_arg & (~1));
30017         this_arg_conv.is_owned = false;
30018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30019         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
30020         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30021         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30022         return ret_arr;
30023 }
30024
30025 void  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
30026         LDKTrustedClosingTransaction this_obj_conv;
30027         this_obj_conv.inner = (void*)(this_obj & (~1));
30028         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30030         TrustedClosingTransaction_free(this_obj_conv);
30031 }
30032
30033 int8_tArray  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
30034         LDKTrustedClosingTransaction this_arg_conv;
30035         this_arg_conv.inner = (void*)(this_arg & (~1));
30036         this_arg_conv.is_owned = false;
30037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30038         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
30039         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30040         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30041         Transaction_free(ret_var);
30042         return ret_arr;
30043 }
30044
30045 int8_tArray  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
30046         LDKTrustedClosingTransaction this_arg_conv;
30047         this_arg_conv.inner = (void*)(this_arg & (~1));
30048         this_arg_conv.is_owned = false;
30049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30050         LDKu8slice funding_redeemscript_ref;
30051         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
30052         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
30053         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
30054         memcpy((uint8_t*)(ret_arr + 4), TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
30055         return ret_arr;
30056 }
30057
30058 int8_tArray  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_sign(uint32_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
30059         LDKTrustedClosingTransaction this_arg_conv;
30060         this_arg_conv.inner = (void*)(this_arg & (~1));
30061         this_arg_conv.is_owned = false;
30062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30063         unsigned char funding_key_arr[32];
30064         CHECK(*((uint32_t*)funding_key) == 32);
30065         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
30066         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
30067         LDKu8slice funding_redeemscript_ref;
30068         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
30069         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
30070         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
30071         memcpy((uint8_t*)(ret_arr + 4), TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
30072         return ret_arr;
30073 }
30074
30075 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
30076         LDKCommitmentTransaction this_obj_conv;
30077         this_obj_conv.inner = (void*)(this_obj & (~1));
30078         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30080         CommitmentTransaction_free(this_obj_conv);
30081 }
30082
30083 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
30084         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
30085 uint64_t ret_ref = 0;
30086 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30087 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30088 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30089 ret_ref = (uint64_t)ret_var.inner;
30090 if (ret_var.is_owned) {
30091         ret_ref |= 1;
30092 }
30093         return ret_ref;
30094 }
30095 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
30096         LDKCommitmentTransaction arg_conv;
30097         arg_conv.inner = (void*)(arg & (~1));
30098         arg_conv.is_owned = false;
30099         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30100         int64_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
30101         return ret_val;
30102 }
30103
30104 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
30105         LDKCommitmentTransaction orig_conv;
30106         orig_conv.inner = (void*)(orig & (~1));
30107         orig_conv.is_owned = false;
30108         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30109         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
30110         uint64_t ret_ref = 0;
30111         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30112         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30114         ret_ref = (uint64_t)ret_var.inner;
30115         if (ret_var.is_owned) {
30116                 ret_ref |= 1;
30117         }
30118         return ret_ref;
30119 }
30120
30121 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
30122         LDKCommitmentTransaction obj_conv;
30123         obj_conv.inner = (void*)(obj & (~1));
30124         obj_conv.is_owned = false;
30125         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30126         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
30127         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30128         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30129         CVec_u8Z_free(ret_var);
30130         return ret_arr;
30131 }
30132
30133 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
30134         LDKu8slice ser_ref;
30135         ser_ref.datalen = *((uint32_t*)ser);
30136         ser_ref.data = (int8_t*)(ser + 4);
30137         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
30138         *ret_conv = CommitmentTransaction_read(ser_ref);
30139         return (uint64_t)ret_conv;
30140 }
30141
30142 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
30143         LDKCommitmentTransaction this_arg_conv;
30144         this_arg_conv.inner = (void*)(this_arg & (~1));
30145         this_arg_conv.is_owned = false;
30146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30147         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
30148         return ret_val;
30149 }
30150
30151 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
30152         LDKCommitmentTransaction this_arg_conv;
30153         this_arg_conv.inner = (void*)(this_arg & (~1));
30154         this_arg_conv.is_owned = false;
30155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30156         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
30157         return ret_val;
30158 }
30159
30160 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
30161         LDKCommitmentTransaction this_arg_conv;
30162         this_arg_conv.inner = (void*)(this_arg & (~1));
30163         this_arg_conv.is_owned = false;
30164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30165         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
30166         return ret_val;
30167 }
30168
30169 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
30170         LDKCommitmentTransaction this_arg_conv;
30171         this_arg_conv.inner = (void*)(this_arg & (~1));
30172         this_arg_conv.is_owned = false;
30173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30174         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
30175         return ret_val;
30176 }
30177
30178 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
30179         LDKCommitmentTransaction this_arg_conv;
30180         this_arg_conv.inner = (void*)(this_arg & (~1));
30181         this_arg_conv.is_owned = false;
30182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30183         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
30184         uint64_t ret_ref = 0;
30185         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30186         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30188         ret_ref = (uint64_t)ret_var.inner;
30189         if (ret_var.is_owned) {
30190                 ret_ref |= 1;
30191         }
30192         return ret_ref;
30193 }
30194
30195 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
30196         LDKCommitmentTransaction this_arg_conv;
30197         this_arg_conv.inner = (void*)(this_arg & (~1));
30198         this_arg_conv.is_owned = false;
30199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30200         LDKDirectedChannelTransactionParameters channel_parameters_conv;
30201         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
30202         channel_parameters_conv.is_owned = false;
30203         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
30204         LDKChannelPublicKeys broadcaster_keys_conv;
30205         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
30206         broadcaster_keys_conv.is_owned = false;
30207         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
30208         LDKChannelPublicKeys countersignatory_keys_conv;
30209         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
30210         countersignatory_keys_conv.is_owned = false;
30211         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
30212         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
30213         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
30214         return (uint64_t)ret_conv;
30215 }
30216
30217 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
30218         LDKTrustedCommitmentTransaction this_obj_conv;
30219         this_obj_conv.inner = (void*)(this_obj & (~1));
30220         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30222         TrustedCommitmentTransaction_free(this_obj_conv);
30223 }
30224
30225 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
30226         LDKTrustedCommitmentTransaction this_arg_conv;
30227         this_arg_conv.inner = (void*)(this_arg & (~1));
30228         this_arg_conv.is_owned = false;
30229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30230         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
30231         memcpy((uint8_t*)(ret_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
30232         return ret_arr;
30233 }
30234
30235 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
30236         LDKTrustedCommitmentTransaction this_arg_conv;
30237         this_arg_conv.inner = (void*)(this_arg & (~1));
30238         this_arg_conv.is_owned = false;
30239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30240         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
30241         uint64_t ret_ref = 0;
30242         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30243         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30245         ret_ref = (uint64_t)ret_var.inner;
30246         if (ret_var.is_owned) {
30247                 ret_ref |= 1;
30248         }
30249         return ret_ref;
30250 }
30251
30252 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
30253         LDKTrustedCommitmentTransaction this_arg_conv;
30254         this_arg_conv.inner = (void*)(this_arg & (~1));
30255         this_arg_conv.is_owned = false;
30256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30257         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
30258         uint64_t ret_ref = 0;
30259         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30260         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30262         ret_ref = (uint64_t)ret_var.inner;
30263         if (ret_var.is_owned) {
30264                 ret_ref |= 1;
30265         }
30266         return ret_ref;
30267 }
30268
30269 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
30270         LDKTrustedCommitmentTransaction this_arg_conv;
30271         this_arg_conv.inner = (void*)(this_arg & (~1));
30272         this_arg_conv.is_owned = false;
30273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30274         unsigned char htlc_base_key_arr[32];
30275         CHECK(*((uint32_t*)htlc_base_key) == 32);
30276         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
30277         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
30278         LDKDirectedChannelTransactionParameters channel_parameters_conv;
30279         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
30280         channel_parameters_conv.is_owned = false;
30281         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
30282         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
30283         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
30284         return (uint64_t)ret_conv;
30285 }
30286
30287 int64_t  __attribute__((visibility("default"))) TS_get_commitment_transaction_number_obscure_factor(int8_tArray broadcaster_payment_basepoint, int8_tArray countersignatory_payment_basepoint, jboolean outbound_from_broadcaster) {
30288         LDKPublicKey broadcaster_payment_basepoint_ref;
30289         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
30290         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
30291         LDKPublicKey countersignatory_payment_basepoint_ref;
30292         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
30293         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
30294         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
30295         return ret_val;
30296 }
30297
30298 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
30299         LDKInitFeatures a_conv;
30300         a_conv.inner = (void*)(a & (~1));
30301         a_conv.is_owned = false;
30302         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30303         LDKInitFeatures b_conv;
30304         b_conv.inner = (void*)(b & (~1));
30305         b_conv.is_owned = false;
30306         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30307         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
30308         return ret_val;
30309 }
30310
30311 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
30312         LDKNodeFeatures a_conv;
30313         a_conv.inner = (void*)(a & (~1));
30314         a_conv.is_owned = false;
30315         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30316         LDKNodeFeatures b_conv;
30317         b_conv.inner = (void*)(b & (~1));
30318         b_conv.is_owned = false;
30319         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30320         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
30321         return ret_val;
30322 }
30323
30324 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
30325         LDKChannelFeatures a_conv;
30326         a_conv.inner = (void*)(a & (~1));
30327         a_conv.is_owned = false;
30328         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30329         LDKChannelFeatures b_conv;
30330         b_conv.inner = (void*)(b & (~1));
30331         b_conv.is_owned = false;
30332         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30333         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
30334         return ret_val;
30335 }
30336
30337 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
30338         LDKInvoiceFeatures a_conv;
30339         a_conv.inner = (void*)(a & (~1));
30340         a_conv.is_owned = false;
30341         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30342         LDKInvoiceFeatures b_conv;
30343         b_conv.inner = (void*)(b & (~1));
30344         b_conv.is_owned = false;
30345         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30346         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
30347         return ret_val;
30348 }
30349
30350 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
30351         LDKInitFeatures ret_var = InitFeatures_clone(arg);
30352 uint64_t ret_ref = 0;
30353 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30354 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30355 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30356 ret_ref = (uint64_t)ret_var.inner;
30357 if (ret_var.is_owned) {
30358         ret_ref |= 1;
30359 }
30360         return ret_ref;
30361 }
30362 int64_t  __attribute__((visibility("default"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
30363         LDKInitFeatures arg_conv;
30364         arg_conv.inner = (void*)(arg & (~1));
30365         arg_conv.is_owned = false;
30366         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30367         int64_t ret_val = InitFeatures_clone_ptr(&arg_conv);
30368         return ret_val;
30369 }
30370
30371 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t orig) {
30372         LDKInitFeatures orig_conv;
30373         orig_conv.inner = (void*)(orig & (~1));
30374         orig_conv.is_owned = false;
30375         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30376         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
30377         uint64_t ret_ref = 0;
30378         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30379         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30381         ret_ref = (uint64_t)ret_var.inner;
30382         if (ret_var.is_owned) {
30383                 ret_ref |= 1;
30384         }
30385         return ret_ref;
30386 }
30387
30388 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
30389         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
30390 uint64_t ret_ref = 0;
30391 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30392 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30393 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30394 ret_ref = (uint64_t)ret_var.inner;
30395 if (ret_var.is_owned) {
30396         ret_ref |= 1;
30397 }
30398         return ret_ref;
30399 }
30400 int64_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
30401         LDKNodeFeatures arg_conv;
30402         arg_conv.inner = (void*)(arg & (~1));
30403         arg_conv.is_owned = false;
30404         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30405         int64_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
30406         return ret_val;
30407 }
30408
30409 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t orig) {
30410         LDKNodeFeatures orig_conv;
30411         orig_conv.inner = (void*)(orig & (~1));
30412         orig_conv.is_owned = false;
30413         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30414         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
30415         uint64_t ret_ref = 0;
30416         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30417         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30419         ret_ref = (uint64_t)ret_var.inner;
30420         if (ret_var.is_owned) {
30421                 ret_ref |= 1;
30422         }
30423         return ret_ref;
30424 }
30425
30426 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
30427         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
30428 uint64_t ret_ref = 0;
30429 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30430 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30431 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30432 ret_ref = (uint64_t)ret_var.inner;
30433 if (ret_var.is_owned) {
30434         ret_ref |= 1;
30435 }
30436         return ret_ref;
30437 }
30438 int64_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
30439         LDKChannelFeatures arg_conv;
30440         arg_conv.inner = (void*)(arg & (~1));
30441         arg_conv.is_owned = false;
30442         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30443         int64_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
30444         return ret_val;
30445 }
30446
30447 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32_t orig) {
30448         LDKChannelFeatures orig_conv;
30449         orig_conv.inner = (void*)(orig & (~1));
30450         orig_conv.is_owned = false;
30451         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30452         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
30453         uint64_t ret_ref = 0;
30454         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30455         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30456         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30457         ret_ref = (uint64_t)ret_var.inner;
30458         if (ret_var.is_owned) {
30459                 ret_ref |= 1;
30460         }
30461         return ret_ref;
30462 }
30463
30464 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
30465         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
30466 uint64_t ret_ref = 0;
30467 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30468 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30469 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30470 ret_ref = (uint64_t)ret_var.inner;
30471 if (ret_var.is_owned) {
30472         ret_ref |= 1;
30473 }
30474         return ret_ref;
30475 }
30476 int64_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
30477         LDKInvoiceFeatures arg_conv;
30478         arg_conv.inner = (void*)(arg & (~1));
30479         arg_conv.is_owned = false;
30480         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30481         int64_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
30482         return ret_val;
30483 }
30484
30485 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32_t orig) {
30486         LDKInvoiceFeatures orig_conv;
30487         orig_conv.inner = (void*)(orig & (~1));
30488         orig_conv.is_owned = false;
30489         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30490         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
30491         uint64_t ret_ref = 0;
30492         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30493         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30495         ret_ref = (uint64_t)ret_var.inner;
30496         if (ret_var.is_owned) {
30497                 ret_ref |= 1;
30498         }
30499         return ret_ref;
30500 }
30501
30502 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_obj) {
30503         LDKInitFeatures this_obj_conv;
30504         this_obj_conv.inner = (void*)(this_obj & (~1));
30505         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30507         InitFeatures_free(this_obj_conv);
30508 }
30509
30510 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_obj) {
30511         LDKNodeFeatures this_obj_conv;
30512         this_obj_conv.inner = (void*)(this_obj & (~1));
30513         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30515         NodeFeatures_free(this_obj_conv);
30516 }
30517
30518 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_obj) {
30519         LDKChannelFeatures this_obj_conv;
30520         this_obj_conv.inner = (void*)(this_obj & (~1));
30521         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30523         ChannelFeatures_free(this_obj_conv);
30524 }
30525
30526 void  __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
30527         LDKInvoiceFeatures this_obj_conv;
30528         this_obj_conv.inner = (void*)(this_obj & (~1));
30529         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30531         InvoiceFeatures_free(this_obj_conv);
30532 }
30533
30534 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
30535         LDKInitFeatures ret_var = InitFeatures_empty();
30536         uint64_t ret_ref = 0;
30537         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30538         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30540         ret_ref = (uint64_t)ret_var.inner;
30541         if (ret_var.is_owned) {
30542                 ret_ref |= 1;
30543         }
30544         return ret_ref;
30545 }
30546
30547 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
30548         LDKInitFeatures ret_var = InitFeatures_known();
30549         uint64_t ret_ref = 0;
30550         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30551         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30553         ret_ref = (uint64_t)ret_var.inner;
30554         if (ret_var.is_owned) {
30555                 ret_ref |= 1;
30556         }
30557         return ret_ref;
30558 }
30559
30560 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
30561         LDKInitFeatures this_arg_conv;
30562         this_arg_conv.inner = (void*)(this_arg & (~1));
30563         this_arg_conv.is_owned = false;
30564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30565         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
30566         return ret_val;
30567 }
30568
30569 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
30570         LDKNodeFeatures ret_var = NodeFeatures_empty();
30571         uint64_t ret_ref = 0;
30572         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30573         CHECK((((uint64_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 = (uint64_t)ret_var.inner;
30576         if (ret_var.is_owned) {
30577                 ret_ref |= 1;
30578         }
30579         return ret_ref;
30580 }
30581
30582 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
30583         LDKNodeFeatures ret_var = NodeFeatures_known();
30584         uint64_t ret_ref = 0;
30585         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30586         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30588         ret_ref = (uint64_t)ret_var.inner;
30589         if (ret_var.is_owned) {
30590                 ret_ref |= 1;
30591         }
30592         return ret_ref;
30593 }
30594
30595 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
30596         LDKNodeFeatures this_arg_conv;
30597         this_arg_conv.inner = (void*)(this_arg & (~1));
30598         this_arg_conv.is_owned = false;
30599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30600         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
30601         return ret_val;
30602 }
30603
30604 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
30605         LDKChannelFeatures ret_var = ChannelFeatures_empty();
30606         uint64_t ret_ref = 0;
30607         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30608         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30610         ret_ref = (uint64_t)ret_var.inner;
30611         if (ret_var.is_owned) {
30612                 ret_ref |= 1;
30613         }
30614         return ret_ref;
30615 }
30616
30617 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
30618         LDKChannelFeatures ret_var = ChannelFeatures_known();
30619         uint64_t ret_ref = 0;
30620         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30621         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30623         ret_ref = (uint64_t)ret_var.inner;
30624         if (ret_var.is_owned) {
30625                 ret_ref |= 1;
30626         }
30627         return ret_ref;
30628 }
30629
30630 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
30631         LDKChannelFeatures this_arg_conv;
30632         this_arg_conv.inner = (void*)(this_arg & (~1));
30633         this_arg_conv.is_owned = false;
30634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30635         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
30636         return ret_val;
30637 }
30638
30639 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
30640         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
30641         uint64_t ret_ref = 0;
30642         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30643         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30645         ret_ref = (uint64_t)ret_var.inner;
30646         if (ret_var.is_owned) {
30647                 ret_ref |= 1;
30648         }
30649         return ret_ref;
30650 }
30651
30652 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_known() {
30653         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
30654         uint64_t ret_ref = 0;
30655         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30656         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30658         ret_ref = (uint64_t)ret_var.inner;
30659         if (ret_var.is_owned) {
30660                 ret_ref |= 1;
30661         }
30662         return ret_ref;
30663 }
30664
30665 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
30666         LDKInvoiceFeatures this_arg_conv;
30667         this_arg_conv.inner = (void*)(this_arg & (~1));
30668         this_arg_conv.is_owned = false;
30669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30670         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
30671         return ret_val;
30672 }
30673
30674 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) {
30675         LDKInitFeatures this_arg_conv;
30676         this_arg_conv.inner = (void*)(this_arg & (~1));
30677         this_arg_conv.is_owned = false;
30678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30679         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
30680         return ret_val;
30681 }
30682
30683 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_supports_payment_secret(uint32_t this_arg) {
30684         LDKNodeFeatures this_arg_conv;
30685         this_arg_conv.inner = (void*)(this_arg & (~1));
30686         this_arg_conv.is_owned = false;
30687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30688         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
30689         return ret_val;
30690 }
30691
30692 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_supports_payment_secret(uint32_t this_arg) {
30693         LDKInvoiceFeatures this_arg_conv;
30694         this_arg_conv.inner = (void*)(this_arg & (~1));
30695         this_arg_conv.is_owned = false;
30696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30697         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
30698         return ret_val;
30699 }
30700
30701 int8_tArray  __attribute__((visibility("default"))) TS_InitFeatures_write(uint32_t obj) {
30702         LDKInitFeatures obj_conv;
30703         obj_conv.inner = (void*)(obj & (~1));
30704         obj_conv.is_owned = false;
30705         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30706         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
30707         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30708         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30709         CVec_u8Z_free(ret_var);
30710         return ret_arr;
30711 }
30712
30713 int8_tArray  __attribute__((visibility("default"))) TS_NodeFeatures_write(uint32_t obj) {
30714         LDKNodeFeatures obj_conv;
30715         obj_conv.inner = (void*)(obj & (~1));
30716         obj_conv.is_owned = false;
30717         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30718         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
30719         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30720         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30721         CVec_u8Z_free(ret_var);
30722         return ret_arr;
30723 }
30724
30725 int8_tArray  __attribute__((visibility("default"))) TS_ChannelFeatures_write(uint32_t obj) {
30726         LDKChannelFeatures obj_conv;
30727         obj_conv.inner = (void*)(obj & (~1));
30728         obj_conv.is_owned = false;
30729         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30730         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
30731         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30732         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30733         CVec_u8Z_free(ret_var);
30734         return ret_arr;
30735 }
30736
30737 int8_tArray  __attribute__((visibility("default"))) TS_InvoiceFeatures_write(uint32_t obj) {
30738         LDKInvoiceFeatures obj_conv;
30739         obj_conv.inner = (void*)(obj & (~1));
30740         obj_conv.is_owned = false;
30741         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30742         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
30743         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30744         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30745         CVec_u8Z_free(ret_var);
30746         return ret_arr;
30747 }
30748
30749 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_read(int8_tArray ser) {
30750         LDKu8slice ser_ref;
30751         ser_ref.datalen = *((uint32_t*)ser);
30752         ser_ref.data = (int8_t*)(ser + 4);
30753         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
30754         *ret_conv = InitFeatures_read(ser_ref);
30755         return (uint64_t)ret_conv;
30756 }
30757
30758 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_read(int8_tArray ser) {
30759         LDKu8slice ser_ref;
30760         ser_ref.datalen = *((uint32_t*)ser);
30761         ser_ref.data = (int8_t*)(ser + 4);
30762         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
30763         *ret_conv = NodeFeatures_read(ser_ref);
30764         return (uint64_t)ret_conv;
30765 }
30766
30767 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_read(int8_tArray ser) {
30768         LDKu8slice ser_ref;
30769         ser_ref.datalen = *((uint32_t*)ser);
30770         ser_ref.data = (int8_t*)(ser + 4);
30771         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
30772         *ret_conv = ChannelFeatures_read(ser_ref);
30773         return (uint64_t)ret_conv;
30774 }
30775
30776 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_read(int8_tArray ser) {
30777         LDKu8slice ser_ref;
30778         ser_ref.datalen = *((uint32_t*)ser);
30779         ser_ref.data = (int8_t*)(ser + 4);
30780         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
30781         *ret_conv = InvoiceFeatures_read(ser_ref);
30782         return (uint64_t)ret_conv;
30783 }
30784
30785 void  __attribute__((visibility("default"))) TS_ShutdownScript_free(uint32_t this_obj) {
30786         LDKShutdownScript this_obj_conv;
30787         this_obj_conv.inner = (void*)(this_obj & (~1));
30788         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30790         ShutdownScript_free(this_obj_conv);
30791 }
30792
30793 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
30794         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
30795 uint64_t ret_ref = 0;
30796 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30797 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30798 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30799 ret_ref = (uint64_t)ret_var.inner;
30800 if (ret_var.is_owned) {
30801         ret_ref |= 1;
30802 }
30803         return ret_ref;
30804 }
30805 int64_t  __attribute__((visibility("default"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
30806         LDKShutdownScript arg_conv;
30807         arg_conv.inner = (void*)(arg & (~1));
30808         arg_conv.is_owned = false;
30809         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30810         int64_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
30811         return ret_val;
30812 }
30813
30814 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_clone(uint32_t orig) {
30815         LDKShutdownScript orig_conv;
30816         orig_conv.inner = (void*)(orig & (~1));
30817         orig_conv.is_owned = false;
30818         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30819         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
30820         uint64_t ret_ref = 0;
30821         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30822         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30824         ret_ref = (uint64_t)ret_var.inner;
30825         if (ret_var.is_owned) {
30826                 ret_ref |= 1;
30827         }
30828         return ret_ref;
30829 }
30830
30831 void  __attribute__((visibility("default"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
30832         LDKInvalidShutdownScript this_obj_conv;
30833         this_obj_conv.inner = (void*)(this_obj & (~1));
30834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30836         InvalidShutdownScript_free(this_obj_conv);
30837 }
30838
30839 int8_tArray  __attribute__((visibility("default"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
30840         LDKInvalidShutdownScript this_ptr_conv;
30841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30842         this_ptr_conv.is_owned = false;
30843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30844         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
30845         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30846         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30847         return ret_arr;
30848 }
30849
30850 void  __attribute__((visibility("default"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
30851         LDKInvalidShutdownScript this_ptr_conv;
30852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30853         this_ptr_conv.is_owned = false;
30854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30855         LDKCVec_u8Z val_ref;
30856         val_ref.datalen = *((uint32_t*)val);
30857         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
30858         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
30859         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
30860 }
30861
30862 uint32_t  __attribute__((visibility("default"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
30863         LDKCVec_u8Z script_arg_ref;
30864         script_arg_ref.datalen = *((uint32_t*)script_arg);
30865         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
30866         memcpy(script_arg_ref.data, (uint8_t*)(script_arg + 4), script_arg_ref.datalen);
30867         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
30868         uint64_t ret_ref = 0;
30869         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30870         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30871         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30872         ret_ref = (uint64_t)ret_var.inner;
30873         if (ret_var.is_owned) {
30874                 ret_ref |= 1;
30875         }
30876         return ret_ref;
30877 }
30878
30879 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
30880         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
30881 uint64_t ret_ref = 0;
30882 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30883 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30884 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30885 ret_ref = (uint64_t)ret_var.inner;
30886 if (ret_var.is_owned) {
30887         ret_ref |= 1;
30888 }
30889         return ret_ref;
30890 }
30891 int64_t  __attribute__((visibility("default"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
30892         LDKInvalidShutdownScript arg_conv;
30893         arg_conv.inner = (void*)(arg & (~1));
30894         arg_conv.is_owned = false;
30895         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30896         int64_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
30897         return ret_val;
30898 }
30899
30900 uint32_t  __attribute__((visibility("default"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
30901         LDKInvalidShutdownScript orig_conv;
30902         orig_conv.inner = (void*)(orig & (~1));
30903         orig_conv.is_owned = false;
30904         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30905         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
30906         uint64_t ret_ref = 0;
30907         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30908         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30909         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30910         ret_ref = (uint64_t)ret_var.inner;
30911         if (ret_var.is_owned) {
30912                 ret_ref |= 1;
30913         }
30914         return ret_ref;
30915 }
30916
30917 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_write(uint32_t obj) {
30918         LDKShutdownScript obj_conv;
30919         obj_conv.inner = (void*)(obj & (~1));
30920         obj_conv.is_owned = false;
30921         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30922         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
30923         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30924         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30925         CVec_u8Z_free(ret_var);
30926         return ret_arr;
30927 }
30928
30929 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_read(int8_tArray ser) {
30930         LDKu8slice ser_ref;
30931         ser_ref.datalen = *((uint32_t*)ser);
30932         ser_ref.data = (int8_t*)(ser + 4);
30933         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
30934         *ret_conv = ShutdownScript_read(ser_ref);
30935         return (uint64_t)ret_conv;
30936 }
30937
30938 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
30939         unsigned char pubkey_hash_arr[20];
30940         CHECK(*((uint32_t*)pubkey_hash) == 20);
30941         memcpy(pubkey_hash_arr, (uint8_t*)(pubkey_hash + 4), 20);
30942         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
30943         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
30944         uint64_t ret_ref = 0;
30945         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30946         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30948         ret_ref = (uint64_t)ret_var.inner;
30949         if (ret_var.is_owned) {
30950                 ret_ref |= 1;
30951         }
30952         return ret_ref;
30953 }
30954
30955 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
30956         unsigned char script_hash_arr[32];
30957         CHECK(*((uint32_t*)script_hash) == 32);
30958         memcpy(script_hash_arr, (uint8_t*)(script_hash + 4), 32);
30959         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
30960         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
30961         uint64_t ret_ref = 0;
30962         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30963         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30965         ret_ref = (uint64_t)ret_var.inner;
30966         if (ret_var.is_owned) {
30967                 ret_ref |= 1;
30968         }
30969         return ret_ref;
30970 }
30971
30972 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
30973         LDKu8slice program_ref;
30974         program_ref.datalen = *((uint32_t*)program);
30975         program_ref.data = (int8_t*)(program + 4);
30976         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
30977         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
30978         return (uint64_t)ret_conv;
30979 }
30980
30981 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
30982         LDKShutdownScript this_arg_conv;
30983         this_arg_conv.inner = (void*)(this_arg & (~1));
30984         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
30985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30986         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
30987         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
30988         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30989         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30990         CVec_u8Z_free(ret_var);
30991         return ret_arr;
30992 }
30993
30994 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
30995         LDKShutdownScript this_arg_conv;
30996         this_arg_conv.inner = (void*)(this_arg & (~1));
30997         this_arg_conv.is_owned = false;
30998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30999         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
31000         memcpy((uint8_t*)(ret_arr + 4), ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
31001         return ret_arr;
31002 }
31003
31004 jboolean  __attribute__((visibility("default"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
31005         LDKShutdownScript this_arg_conv;
31006         this_arg_conv.inner = (void*)(this_arg & (~1));
31007         this_arg_conv.is_owned = false;
31008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31009         LDKInitFeatures features_conv;
31010         features_conv.inner = (void*)(features & (~1));
31011         features_conv.is_owned = false;
31012         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
31013         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
31014         return ret_val;
31015 }
31016
31017 void  __attribute__((visibility("default"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
31018         if ((this_ptr & 1) != 0) return;
31019         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31020         CHECK_ACCESS(this_ptr_ptr);
31021         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
31022         FREE((void*)this_ptr);
31023         CustomMessageReader_free(this_ptr_conv);
31024 }
31025
31026 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
31027         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
31028         *ret_ret = Type_clone(arg);
31029         return (uint64_t)ret_ret;
31030 }
31031 int64_t  __attribute__((visibility("default"))) TS_Type_clone_ptr(uint32_t arg) {
31032         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
31033         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
31034         LDKType* arg_conv = (LDKType*)arg_ptr;
31035         int64_t ret_val = Type_clone_ptr(arg_conv);
31036         return ret_val;
31037 }
31038
31039 uint32_t  __attribute__((visibility("default"))) TS_Type_clone(uint32_t orig) {
31040         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
31041         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
31042         LDKType* orig_conv = (LDKType*)orig_ptr;
31043         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
31044         *ret_ret = Type_clone(orig_conv);
31045         return (uint64_t)ret_ret;
31046 }
31047
31048 void  __attribute__((visibility("default"))) TS_Type_free(uint32_t this_ptr) {
31049         if ((this_ptr & 1) != 0) return;
31050         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31051         CHECK_ACCESS(this_ptr_ptr);
31052         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
31053         FREE((void*)this_ptr);
31054         Type_free(this_ptr_conv);
31055 }
31056
31057 void  __attribute__((visibility("default"))) TS_Score_free(uint32_t this_ptr) {
31058         if ((this_ptr & 1) != 0) return;
31059         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31060         CHECK_ACCESS(this_ptr_ptr);
31061         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
31062         FREE((void*)this_ptr);
31063         Score_free(this_ptr_conv);
31064 }
31065
31066 void  __attribute__((visibility("default"))) TS_LockableScore_free(uint32_t this_obj) {
31067         LDKLockableScore this_obj_conv;
31068         this_obj_conv.inner = (void*)(this_obj & (~1));
31069         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31071         LockableScore_free(this_obj_conv);
31072 }
31073
31074 uint32_t  __attribute__((visibility("default"))) TS_LockableScore_new(uint32_t score) {
31075         void* score_ptr = (void*)(((uint64_t)score) & ~1);
31076         CHECK_ACCESS(score_ptr);
31077         LDKScore score_conv = *(LDKScore*)(score_ptr);
31078         LDKLockableScore ret_var = LockableScore_new(score_conv);
31079         uint64_t ret_ref = 0;
31080         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31081         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31083         ret_ref = (uint64_t)ret_var.inner;
31084         if (ret_var.is_owned) {
31085                 ret_ref |= 1;
31086         }
31087         return ret_ref;
31088 }
31089
31090 int8_tArray  __attribute__((visibility("default"))) TS_LockableScore_write(uint32_t obj) {
31091         LDKLockableScore obj_conv;
31092         obj_conv.inner = (void*)(obj & (~1));
31093         obj_conv.is_owned = false;
31094         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31095         LDKCVec_u8Z ret_var = LockableScore_write(&obj_conv);
31096         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
31097         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
31098         CVec_u8Z_free(ret_var);
31099         return ret_arr;
31100 }
31101
31102 void  __attribute__((visibility("default"))) TS_NodeId_free(uint32_t this_obj) {
31103         LDKNodeId this_obj_conv;
31104         this_obj_conv.inner = (void*)(this_obj & (~1));
31105         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31107         NodeId_free(this_obj_conv);
31108 }
31109
31110 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
31111         LDKNodeId ret_var = NodeId_clone(arg);
31112 uint64_t ret_ref = 0;
31113 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31114 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31115 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31116 ret_ref = (uint64_t)ret_var.inner;
31117 if (ret_var.is_owned) {
31118         ret_ref |= 1;
31119 }
31120         return ret_ref;
31121 }
31122 int64_t  __attribute__((visibility("default"))) TS_NodeId_clone_ptr(uint32_t arg) {
31123         LDKNodeId arg_conv;
31124         arg_conv.inner = (void*)(arg & (~1));
31125         arg_conv.is_owned = false;
31126         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31127         int64_t ret_val = NodeId_clone_ptr(&arg_conv);
31128         return ret_val;
31129 }
31130
31131 uint32_t  __attribute__((visibility("default"))) TS_NodeId_clone(uint32_t orig) {
31132         LDKNodeId orig_conv;
31133         orig_conv.inner = (void*)(orig & (~1));
31134         orig_conv.is_owned = false;
31135         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31136         LDKNodeId ret_var = NodeId_clone(&orig_conv);
31137         uint64_t ret_ref = 0;
31138         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31139         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31141         ret_ref = (uint64_t)ret_var.inner;
31142         if (ret_var.is_owned) {
31143                 ret_ref |= 1;
31144         }
31145         return ret_ref;
31146 }
31147
31148 uint32_t  __attribute__((visibility("default"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
31149         LDKPublicKey pubkey_ref;
31150         CHECK(*((uint32_t*)pubkey) == 33);
31151         memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
31152         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
31153         uint64_t ret_ref = 0;
31154         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31155         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31157         ret_ref = (uint64_t)ret_var.inner;
31158         if (ret_var.is_owned) {
31159                 ret_ref |= 1;
31160         }
31161         return ret_ref;
31162 }
31163
31164 int8_tArray  __attribute__((visibility("default"))) TS_NodeId_as_slice(uint32_t this_arg) {
31165         LDKNodeId this_arg_conv;
31166         this_arg_conv.inner = (void*)(this_arg & (~1));
31167         this_arg_conv.is_owned = false;
31168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31169         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
31170         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
31171         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
31172         return ret_arr;
31173 }
31174
31175 int64_t  __attribute__((visibility("default"))) TS_NodeId_hash(uint32_t o) {
31176         LDKNodeId o_conv;
31177         o_conv.inner = (void*)(o & (~1));
31178         o_conv.is_owned = false;
31179         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
31180         int64_t ret_val = NodeId_hash(&o_conv);
31181         return ret_val;
31182 }
31183
31184 int8_tArray  __attribute__((visibility("default"))) TS_NodeId_write(uint32_t obj) {
31185         LDKNodeId obj_conv;
31186         obj_conv.inner = (void*)(obj & (~1));
31187         obj_conv.is_owned = false;
31188         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31189         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
31190         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
31191         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
31192         CVec_u8Z_free(ret_var);
31193         return ret_arr;
31194 }
31195
31196 uint32_t  __attribute__((visibility("default"))) TS_NodeId_read(int8_tArray ser) {
31197         LDKu8slice ser_ref;
31198         ser_ref.datalen = *((uint32_t*)ser);
31199         ser_ref.data = (int8_t*)(ser + 4);
31200         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
31201         *ret_conv = NodeId_read(ser_ref);
31202         return (uint64_t)ret_conv;
31203 }
31204
31205 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_obj) {
31206         LDKNetworkGraph this_obj_conv;
31207         this_obj_conv.inner = (void*)(this_obj & (~1));
31208         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31210         NetworkGraph_free(this_obj_conv);
31211 }
31212
31213 static inline uint64_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
31214         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
31215 uint64_t ret_ref = 0;
31216 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31217 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31218 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31219 ret_ref = (uint64_t)ret_var.inner;
31220 if (ret_var.is_owned) {
31221         ret_ref |= 1;
31222 }
31223         return ret_ref;
31224 }
31225 int64_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone_ptr(uint32_t arg) {
31226         LDKNetworkGraph arg_conv;
31227         arg_conv.inner = (void*)(arg & (~1));
31228         arg_conv.is_owned = false;
31229         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31230         int64_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
31231         return ret_val;
31232 }
31233
31234 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t orig) {
31235         LDKNetworkGraph orig_conv;
31236         orig_conv.inner = (void*)(orig & (~1));
31237         orig_conv.is_owned = false;
31238         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31239         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
31240         uint64_t ret_ref = 0;
31241         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31242         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31244         ret_ref = (uint64_t)ret_var.inner;
31245         if (ret_var.is_owned) {
31246                 ret_ref |= 1;
31247         }
31248         return ret_ref;
31249 }
31250
31251 void  __attribute__((visibility("default"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
31252         LDKReadOnlyNetworkGraph this_obj_conv;
31253         this_obj_conv.inner = (void*)(this_obj & (~1));
31254         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31256         ReadOnlyNetworkGraph_free(this_obj_conv);
31257 }
31258
31259 void  __attribute__((visibility("default"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
31260         if ((this_ptr & 1) != 0) return;
31261         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31262         CHECK_ACCESS(this_ptr_ptr);
31263         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
31264         FREE((void*)this_ptr);
31265         NetworkUpdate_free(this_ptr_conv);
31266 }
31267
31268 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
31269         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31270         *ret_copy = NetworkUpdate_clone(arg);
31271 uint64_t ret_ref = (uint64_t)ret_copy;
31272         return ret_ref;
31273 }
31274 int64_t  __attribute__((visibility("default"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
31275         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
31276         int64_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
31277         return ret_val;
31278 }
31279
31280 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_clone(uint32_t orig) {
31281         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
31282         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31283         *ret_copy = NetworkUpdate_clone(orig_conv);
31284         uint64_t ret_ref = (uint64_t)ret_copy;
31285         return ret_ref;
31286 }
31287
31288 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
31289         LDKChannelUpdate msg_conv;
31290         msg_conv.inner = (void*)(msg & (~1));
31291         msg_conv.is_owned = (msg & 1) || (msg == 0);
31292         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31293         msg_conv = ChannelUpdate_clone(&msg_conv);
31294         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31295         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
31296         uint64_t ret_ref = (uint64_t)ret_copy;
31297         return ret_ref;
31298 }
31299
31300 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
31301         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31302         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
31303         uint64_t ret_ref = (uint64_t)ret_copy;
31304         return ret_ref;
31305 }
31306
31307 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
31308         LDKPublicKey node_id_ref;
31309         CHECK(*((uint32_t*)node_id) == 33);
31310         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
31311         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31312         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
31313         uint64_t ret_ref = (uint64_t)ret_copy;
31314         return ret_ref;
31315 }
31316
31317 int8_tArray  __attribute__((visibility("default"))) TS_NetworkUpdate_write(uint32_t obj) {
31318         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
31319         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
31320         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
31321         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
31322         CVec_u8Z_free(ret_var);
31323         return ret_arr;
31324 }
31325
31326 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_read(int8_tArray ser) {
31327         LDKu8slice ser_ref;
31328         ser_ref.datalen = *((uint32_t*)ser);
31329         ser_ref.data = (int8_t*)(ser + 4);
31330         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
31331         *ret_conv = NetworkUpdate_read(ser_ref);
31332         return (uint64_t)ret_conv;
31333 }
31334
31335 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) {
31336         LDKNetGraphMsgHandler this_arg_conv;
31337         this_arg_conv.inner = (void*)(this_arg & (~1));
31338         this_arg_conv.is_owned = false;
31339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31340         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
31341         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
31342         return (uint64_t)ret_ret;
31343 }
31344
31345 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
31346         LDKNetGraphMsgHandler this_obj_conv;
31347         this_obj_conv.inner = (void*)(this_obj & (~1));
31348         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31350         NetGraphMsgHandler_free(this_obj_conv);
31351 }
31352
31353 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
31354         LDKNetworkGraph network_graph_conv;
31355         network_graph_conv.inner = (void*)(network_graph & (~1));
31356         network_graph_conv.is_owned = false;
31357         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
31358         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
31359         CHECK_ACCESS(chain_access_ptr);
31360         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
31361         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
31362         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
31363                 // Manually implement clone for Java trait instances
31364         }
31365         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
31366         CHECK_ACCESS(logger_ptr);
31367         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
31368         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
31369         uint64_t ret_ref = 0;
31370         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31371         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31373         ret_ref = (uint64_t)ret_var.inner;
31374         if (ret_var.is_owned) {
31375                 ret_ref |= 1;
31376         }
31377         return ret_ref;
31378 }
31379
31380 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
31381         LDKNetGraphMsgHandler this_arg_conv;
31382         this_arg_conv.inner = (void*)(this_arg & (~1));
31383         this_arg_conv.is_owned = false;
31384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31385         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
31386         CHECK_ACCESS(chain_access_ptr);
31387         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
31388         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
31389         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
31390                 // Manually implement clone for Java trait instances
31391         }
31392         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
31393 }
31394
31395 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
31396         LDKNetGraphMsgHandler this_arg_conv;
31397         this_arg_conv.inner = (void*)(this_arg & (~1));
31398         this_arg_conv.is_owned = false;
31399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31400         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
31401         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
31402         return (uint64_t)ret_ret;
31403 }
31404
31405 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
31406         LDKNetGraphMsgHandler this_arg_conv;
31407         this_arg_conv.inner = (void*)(this_arg & (~1));
31408         this_arg_conv.is_owned = false;
31409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31410         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
31411         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
31412         return (uint64_t)ret_ret;
31413 }
31414
31415 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
31416         LDKDirectionalChannelInfo this_obj_conv;
31417         this_obj_conv.inner = (void*)(this_obj & (~1));
31418         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31420         DirectionalChannelInfo_free(this_obj_conv);
31421 }
31422
31423 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
31424         LDKDirectionalChannelInfo 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         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
31429         return ret_val;
31430 }
31431
31432 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
31433         LDKDirectionalChannelInfo this_ptr_conv;
31434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31435         this_ptr_conv.is_owned = false;
31436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31437         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
31438 }
31439
31440 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
31441         LDKDirectionalChannelInfo this_ptr_conv;
31442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31443         this_ptr_conv.is_owned = false;
31444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31445         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
31446         return ret_val;
31447 }
31448
31449 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
31450         LDKDirectionalChannelInfo this_ptr_conv;
31451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31452         this_ptr_conv.is_owned = false;
31453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31454         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
31455 }
31456
31457 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
31458         LDKDirectionalChannelInfo this_ptr_conv;
31459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31460         this_ptr_conv.is_owned = false;
31461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31462         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
31463         return ret_val;
31464 }
31465
31466 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
31467         LDKDirectionalChannelInfo this_ptr_conv;
31468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31469         this_ptr_conv.is_owned = false;
31470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31471         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
31472 }
31473
31474 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
31475         LDKDirectionalChannelInfo this_ptr_conv;
31476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31477         this_ptr_conv.is_owned = false;
31478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31479         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
31480         return ret_val;
31481 }
31482
31483 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
31484         LDKDirectionalChannelInfo this_ptr_conv;
31485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31486         this_ptr_conv.is_owned = false;
31487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31488         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
31489 }
31490
31491 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
31492         LDKDirectionalChannelInfo this_ptr_conv;
31493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31494         this_ptr_conv.is_owned = false;
31495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31496         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31497         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
31498         uint64_t ret_ref = (uint64_t)ret_copy;
31499         return ret_ref;
31500 }
31501
31502 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
31503         LDKDirectionalChannelInfo this_ptr_conv;
31504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31505         this_ptr_conv.is_owned = false;
31506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31507         void* val_ptr = (void*)(((uint64_t)val) & ~1);
31508         CHECK_ACCESS(val_ptr);
31509         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31510         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
31511         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
31512 }
31513
31514 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
31515         LDKDirectionalChannelInfo this_ptr_conv;
31516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31517         this_ptr_conv.is_owned = false;
31518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31519         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
31520         uint64_t ret_ref = 0;
31521         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31522         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31524         ret_ref = (uint64_t)ret_var.inner;
31525         if (ret_var.is_owned) {
31526                 ret_ref |= 1;
31527         }
31528         return ret_ref;
31529 }
31530
31531 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
31532         LDKDirectionalChannelInfo this_ptr_conv;
31533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31534         this_ptr_conv.is_owned = false;
31535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31536         LDKRoutingFees val_conv;
31537         val_conv.inner = (void*)(val & (~1));
31538         val_conv.is_owned = (val & 1) || (val == 0);
31539         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31540         val_conv = RoutingFees_clone(&val_conv);
31541         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
31542 }
31543
31544 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
31545         LDKDirectionalChannelInfo this_ptr_conv;
31546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31547         this_ptr_conv.is_owned = false;
31548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31549         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
31550         uint64_t ret_ref = 0;
31551         if ((uint64_t)ret_var.inner > 4096) {
31552                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31553                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31555                 ret_ref = (uint64_t)ret_var.inner;
31556                 if (ret_var.is_owned) {
31557                         ret_ref |= 1;
31558                 }
31559         }
31560         return ret_ref;
31561 }
31562
31563 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
31564         LDKDirectionalChannelInfo this_ptr_conv;
31565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31566         this_ptr_conv.is_owned = false;
31567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31568         LDKChannelUpdate val_conv;
31569         val_conv.inner = (void*)(val & (~1));
31570         val_conv.is_owned = (val & 1) || (val == 0);
31571         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31572         val_conv = ChannelUpdate_clone(&val_conv);
31573         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
31574 }
31575
31576 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_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) {
31577         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
31578         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
31579         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
31580         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
31581         LDKRoutingFees fees_arg_conv;
31582         fees_arg_conv.inner = (void*)(fees_arg & (~1));
31583         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
31584         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
31585         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
31586         LDKChannelUpdate last_update_message_arg_conv;
31587         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
31588         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
31589         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
31590         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
31591         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_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);
31592         uint64_t ret_ref = 0;
31593         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31594         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31596         ret_ref = (uint64_t)ret_var.inner;
31597         if (ret_var.is_owned) {
31598                 ret_ref |= 1;
31599         }
31600         return ret_ref;
31601 }
31602
31603 static inline uint64_t DirectionalChannelInfo_clone_ptr(LDKDirectionalChannelInfo *NONNULL_PTR arg) {
31604         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(arg);
31605 uint64_t ret_ref = 0;
31606 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31607 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31608 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31609 ret_ref = (uint64_t)ret_var.inner;
31610 if (ret_var.is_owned) {
31611         ret_ref |= 1;
31612 }
31613         return ret_ref;
31614 }
31615 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone_ptr(uint32_t arg) {
31616         LDKDirectionalChannelInfo arg_conv;
31617         arg_conv.inner = (void*)(arg & (~1));
31618         arg_conv.is_owned = false;
31619         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31620         int64_t ret_val = DirectionalChannelInfo_clone_ptr(&arg_conv);
31621         return ret_val;
31622 }
31623
31624 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
31625         LDKDirectionalChannelInfo orig_conv;
31626         orig_conv.inner = (void*)(orig & (~1));
31627         orig_conv.is_owned = false;
31628         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31629         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
31630         uint64_t ret_ref = 0;
31631         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31632         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31634         ret_ref = (uint64_t)ret_var.inner;
31635         if (ret_var.is_owned) {
31636                 ret_ref |= 1;
31637         }
31638         return ret_ref;
31639 }
31640
31641 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
31642         LDKDirectionalChannelInfo obj_conv;
31643         obj_conv.inner = (void*)(obj & (~1));
31644         obj_conv.is_owned = false;
31645         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31646         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
31647         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
31648         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
31649         CVec_u8Z_free(ret_var);
31650         return ret_arr;
31651 }
31652
31653 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
31654         LDKu8slice ser_ref;
31655         ser_ref.datalen = *((uint32_t*)ser);
31656         ser_ref.data = (int8_t*)(ser + 4);
31657         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
31658         *ret_conv = DirectionalChannelInfo_read(ser_ref);
31659         return (uint64_t)ret_conv;
31660 }
31661
31662 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_obj) {
31663         LDKChannelInfo this_obj_conv;
31664         this_obj_conv.inner = (void*)(this_obj & (~1));
31665         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31667         ChannelInfo_free(this_obj_conv);
31668 }
31669
31670 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
31671         LDKChannelInfo this_ptr_conv;
31672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31673         this_ptr_conv.is_owned = false;
31674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31675         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
31676         uint64_t ret_ref = 0;
31677         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31678         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31680         ret_ref = (uint64_t)ret_var.inner;
31681         if (ret_var.is_owned) {
31682                 ret_ref |= 1;
31683         }
31684         return ret_ref;
31685 }
31686
31687 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
31688         LDKChannelInfo this_ptr_conv;
31689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31690         this_ptr_conv.is_owned = false;
31691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31692         LDKChannelFeatures val_conv;
31693         val_conv.inner = (void*)(val & (~1));
31694         val_conv.is_owned = (val & 1) || (val == 0);
31695         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31696         val_conv = ChannelFeatures_clone(&val_conv);
31697         ChannelInfo_set_features(&this_ptr_conv, val_conv);
31698 }
31699
31700 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
31701         LDKChannelInfo this_ptr_conv;
31702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31703         this_ptr_conv.is_owned = false;
31704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31705         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
31706         uint64_t ret_ref = 0;
31707         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31708         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31710         ret_ref = (uint64_t)ret_var.inner;
31711         if (ret_var.is_owned) {
31712                 ret_ref |= 1;
31713         }
31714         return ret_ref;
31715 }
31716
31717 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
31718         LDKChannelInfo this_ptr_conv;
31719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31720         this_ptr_conv.is_owned = false;
31721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31722         LDKNodeId val_conv;
31723         val_conv.inner = (void*)(val & (~1));
31724         val_conv.is_owned = (val & 1) || (val == 0);
31725         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31726         val_conv = NodeId_clone(&val_conv);
31727         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
31728 }
31729
31730 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
31731         LDKChannelInfo this_ptr_conv;
31732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31733         this_ptr_conv.is_owned = false;
31734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31735         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
31736         uint64_t ret_ref = 0;
31737         if ((uint64_t)ret_var.inner > 4096) {
31738                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31739                 CHECK((((uint64_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 = (uint64_t)ret_var.inner;
31742                 if (ret_var.is_owned) {
31743                         ret_ref |= 1;
31744                 }
31745         }
31746         return ret_ref;
31747 }
31748
31749 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
31750         LDKChannelInfo this_ptr_conv;
31751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31752         this_ptr_conv.is_owned = false;
31753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31754         LDKDirectionalChannelInfo val_conv;
31755         val_conv.inner = (void*)(val & (~1));
31756         val_conv.is_owned = (val & 1) || (val == 0);
31757         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31758         val_conv = DirectionalChannelInfo_clone(&val_conv);
31759         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
31760 }
31761
31762 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
31763         LDKChannelInfo this_ptr_conv;
31764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31765         this_ptr_conv.is_owned = false;
31766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31767         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
31768         uint64_t ret_ref = 0;
31769         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31770         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31772         ret_ref = (uint64_t)ret_var.inner;
31773         if (ret_var.is_owned) {
31774                 ret_ref |= 1;
31775         }
31776         return ret_ref;
31777 }
31778
31779 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
31780         LDKChannelInfo this_ptr_conv;
31781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31782         this_ptr_conv.is_owned = false;
31783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31784         LDKNodeId val_conv;
31785         val_conv.inner = (void*)(val & (~1));
31786         val_conv.is_owned = (val & 1) || (val == 0);
31787         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31788         val_conv = NodeId_clone(&val_conv);
31789         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
31790 }
31791
31792 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
31793         LDKChannelInfo this_ptr_conv;
31794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31795         this_ptr_conv.is_owned = false;
31796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31797         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
31798         uint64_t ret_ref = 0;
31799         if ((uint64_t)ret_var.inner > 4096) {
31800                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31801                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31803                 ret_ref = (uint64_t)ret_var.inner;
31804                 if (ret_var.is_owned) {
31805                         ret_ref |= 1;
31806                 }
31807         }
31808         return ret_ref;
31809 }
31810
31811 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
31812         LDKChannelInfo this_ptr_conv;
31813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31814         this_ptr_conv.is_owned = false;
31815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31816         LDKDirectionalChannelInfo val_conv;
31817         val_conv.inner = (void*)(val & (~1));
31818         val_conv.is_owned = (val & 1) || (val == 0);
31819         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31820         val_conv = DirectionalChannelInfo_clone(&val_conv);
31821         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
31822 }
31823
31824 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
31825         LDKChannelInfo this_ptr_conv;
31826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31827         this_ptr_conv.is_owned = false;
31828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31829         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31830         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
31831         uint64_t ret_ref = (uint64_t)ret_copy;
31832         return ret_ref;
31833 }
31834
31835 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
31836         LDKChannelInfo this_ptr_conv;
31837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31838         this_ptr_conv.is_owned = false;
31839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31840         void* val_ptr = (void*)(((uint64_t)val) & ~1);
31841         CHECK_ACCESS(val_ptr);
31842         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31843         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
31844         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
31845 }
31846
31847 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
31848         LDKChannelInfo this_ptr_conv;
31849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31850         this_ptr_conv.is_owned = false;
31851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31852         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
31853         uint64_t ret_ref = 0;
31854         if ((uint64_t)ret_var.inner > 4096) {
31855                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31856                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31858                 ret_ref = (uint64_t)ret_var.inner;
31859                 if (ret_var.is_owned) {
31860                         ret_ref |= 1;
31861                 }
31862         }
31863         return ret_ref;
31864 }
31865
31866 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
31867         LDKChannelInfo 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         LDKChannelAnnouncement val_conv;
31872         val_conv.inner = (void*)(val & (~1));
31873         val_conv.is_owned = (val & 1) || (val == 0);
31874         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31875         val_conv = ChannelAnnouncement_clone(&val_conv);
31876         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
31877 }
31878
31879 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_new(uint32_t features_arg, uint32_t node_one_arg, uint32_t one_to_two_arg, uint32_t node_two_arg, uint32_t two_to_one_arg, uint32_t capacity_sats_arg, uint32_t announcement_message_arg) {
31880         LDKChannelFeatures features_arg_conv;
31881         features_arg_conv.inner = (void*)(features_arg & (~1));
31882         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
31883         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
31884         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
31885         LDKNodeId node_one_arg_conv;
31886         node_one_arg_conv.inner = (void*)(node_one_arg & (~1));
31887         node_one_arg_conv.is_owned = (node_one_arg & 1) || (node_one_arg == 0);
31888         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_one_arg_conv);
31889         node_one_arg_conv = NodeId_clone(&node_one_arg_conv);
31890         LDKDirectionalChannelInfo one_to_two_arg_conv;
31891         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
31892         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
31893         CHECK_INNER_FIELD_ACCESS_OR_NULL(one_to_two_arg_conv);
31894         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
31895         LDKNodeId node_two_arg_conv;
31896         node_two_arg_conv.inner = (void*)(node_two_arg & (~1));
31897         node_two_arg_conv.is_owned = (node_two_arg & 1) || (node_two_arg == 0);
31898         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_two_arg_conv);
31899         node_two_arg_conv = NodeId_clone(&node_two_arg_conv);
31900         LDKDirectionalChannelInfo two_to_one_arg_conv;
31901         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
31902         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
31903         CHECK_INNER_FIELD_ACCESS_OR_NULL(two_to_one_arg_conv);
31904         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
31905         void* capacity_sats_arg_ptr = (void*)(((uint64_t)capacity_sats_arg) & ~1);
31906         CHECK_ACCESS(capacity_sats_arg_ptr);
31907         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(capacity_sats_arg_ptr);
31908         capacity_sats_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1));
31909         LDKChannelAnnouncement announcement_message_arg_conv;
31910         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
31911         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
31912         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
31913         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
31914         LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_conv, one_to_two_arg_conv, node_two_arg_conv, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
31915         uint64_t ret_ref = 0;
31916         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31917         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31919         ret_ref = (uint64_t)ret_var.inner;
31920         if (ret_var.is_owned) {
31921                 ret_ref |= 1;
31922         }
31923         return ret_ref;
31924 }
31925
31926 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
31927         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
31928 uint64_t ret_ref = 0;
31929 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31930 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31931 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31932 ret_ref = (uint64_t)ret_var.inner;
31933 if (ret_var.is_owned) {
31934         ret_ref |= 1;
31935 }
31936         return ret_ref;
31937 }
31938 int64_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
31939         LDKChannelInfo arg_conv;
31940         arg_conv.inner = (void*)(arg & (~1));
31941         arg_conv.is_owned = false;
31942         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31943         int64_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
31944         return ret_val;
31945 }
31946
31947 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t orig) {
31948         LDKChannelInfo orig_conv;
31949         orig_conv.inner = (void*)(orig & (~1));
31950         orig_conv.is_owned = false;
31951         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31952         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
31953         uint64_t ret_ref = 0;
31954         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31955         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31957         ret_ref = (uint64_t)ret_var.inner;
31958         if (ret_var.is_owned) {
31959                 ret_ref |= 1;
31960         }
31961         return ret_ref;
31962 }
31963
31964 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
31965         LDKChannelInfo obj_conv;
31966         obj_conv.inner = (void*)(obj & (~1));
31967         obj_conv.is_owned = false;
31968         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31969         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
31970         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
31971         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
31972         CVec_u8Z_free(ret_var);
31973         return ret_arr;
31974 }
31975
31976 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
31977         LDKu8slice ser_ref;
31978         ser_ref.datalen = *((uint32_t*)ser);
31979         ser_ref.data = (int8_t*)(ser + 4);
31980         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
31981         *ret_conv = ChannelInfo_read(ser_ref);
31982         return (uint64_t)ret_conv;
31983 }
31984
31985 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_obj) {
31986         LDKRoutingFees this_obj_conv;
31987         this_obj_conv.inner = (void*)(this_obj & (~1));
31988         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31990         RoutingFees_free(this_obj_conv);
31991 }
31992
31993 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
31994         LDKRoutingFees this_ptr_conv;
31995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31996         this_ptr_conv.is_owned = false;
31997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31998         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
31999         return ret_val;
32000 }
32001
32002 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
32003         LDKRoutingFees this_ptr_conv;
32004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32005         this_ptr_conv.is_owned = false;
32006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32007         RoutingFees_set_base_msat(&this_ptr_conv, val);
32008 }
32009
32010 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
32011         LDKRoutingFees this_ptr_conv;
32012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32013         this_ptr_conv.is_owned = false;
32014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32015         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
32016         return ret_val;
32017 }
32018
32019 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
32020         LDKRoutingFees this_ptr_conv;
32021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32022         this_ptr_conv.is_owned = false;
32023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32024         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
32025 }
32026
32027 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
32028         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
32029         uint64_t ret_ref = 0;
32030         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32031         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32032         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32033         ret_ref = (uint64_t)ret_var.inner;
32034         if (ret_var.is_owned) {
32035                 ret_ref |= 1;
32036         }
32037         return ret_ref;
32038 }
32039
32040 jboolean  __attribute__((visibility("default"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
32041         LDKRoutingFees a_conv;
32042         a_conv.inner = (void*)(a & (~1));
32043         a_conv.is_owned = false;
32044         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32045         LDKRoutingFees b_conv;
32046         b_conv.inner = (void*)(b & (~1));
32047         b_conv.is_owned = false;
32048         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
32049         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
32050         return ret_val;
32051 }
32052
32053 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
32054         LDKRoutingFees ret_var = RoutingFees_clone(arg);
32055 uint64_t ret_ref = 0;
32056 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32057 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32058 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32059 ret_ref = (uint64_t)ret_var.inner;
32060 if (ret_var.is_owned) {
32061         ret_ref |= 1;
32062 }
32063         return ret_ref;
32064 }
32065 int64_t  __attribute__((visibility("default"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
32066         LDKRoutingFees arg_conv;
32067         arg_conv.inner = (void*)(arg & (~1));
32068         arg_conv.is_owned = false;
32069         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32070         int64_t ret_val = RoutingFees_clone_ptr(&arg_conv);
32071         return ret_val;
32072 }
32073
32074 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
32075         LDKRoutingFees orig_conv;
32076         orig_conv.inner = (void*)(orig & (~1));
32077         orig_conv.is_owned = false;
32078         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32079         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
32080         uint64_t ret_ref = 0;
32081         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32082         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32084         ret_ref = (uint64_t)ret_var.inner;
32085         if (ret_var.is_owned) {
32086                 ret_ref |= 1;
32087         }
32088         return ret_ref;
32089 }
32090
32091 int64_t  __attribute__((visibility("default"))) TS_RoutingFees_hash(uint32_t o) {
32092         LDKRoutingFees o_conv;
32093         o_conv.inner = (void*)(o & (~1));
32094         o_conv.is_owned = false;
32095         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
32096         int64_t ret_val = RoutingFees_hash(&o_conv);
32097         return ret_val;
32098 }
32099
32100 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
32101         LDKRoutingFees obj_conv;
32102         obj_conv.inner = (void*)(obj & (~1));
32103         obj_conv.is_owned = false;
32104         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32105         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
32106         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
32107         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
32108         CVec_u8Z_free(ret_var);
32109         return ret_arr;
32110 }
32111
32112 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
32113         LDKu8slice ser_ref;
32114         ser_ref.datalen = *((uint32_t*)ser);
32115         ser_ref.data = (int8_t*)(ser + 4);
32116         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
32117         *ret_conv = RoutingFees_read(ser_ref);
32118         return (uint64_t)ret_conv;
32119 }
32120
32121 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
32122         LDKNodeAnnouncementInfo this_obj_conv;
32123         this_obj_conv.inner = (void*)(this_obj & (~1));
32124         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32126         NodeAnnouncementInfo_free(this_obj_conv);
32127 }
32128
32129 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
32130         LDKNodeAnnouncementInfo this_ptr_conv;
32131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32132         this_ptr_conv.is_owned = false;
32133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32134         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
32135         uint64_t ret_ref = 0;
32136         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32137         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32139         ret_ref = (uint64_t)ret_var.inner;
32140         if (ret_var.is_owned) {
32141                 ret_ref |= 1;
32142         }
32143         return ret_ref;
32144 }
32145
32146 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
32147         LDKNodeAnnouncementInfo this_ptr_conv;
32148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32149         this_ptr_conv.is_owned = false;
32150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32151         LDKNodeFeatures val_conv;
32152         val_conv.inner = (void*)(val & (~1));
32153         val_conv.is_owned = (val & 1) || (val == 0);
32154         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32155         val_conv = NodeFeatures_clone(&val_conv);
32156         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
32157 }
32158
32159 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
32160         LDKNodeAnnouncementInfo this_ptr_conv;
32161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32162         this_ptr_conv.is_owned = false;
32163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32164         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
32165         return ret_val;
32166 }
32167
32168 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
32169         LDKNodeAnnouncementInfo this_ptr_conv;
32170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32171         this_ptr_conv.is_owned = false;
32172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32173         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
32174 }
32175
32176 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
32177         LDKNodeAnnouncementInfo this_ptr_conv;
32178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32179         this_ptr_conv.is_owned = false;
32180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32181         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
32182         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
32183         return ret_arr;
32184 }
32185
32186 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
32187         LDKNodeAnnouncementInfo this_ptr_conv;
32188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32189         this_ptr_conv.is_owned = false;
32190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32191         LDKThreeBytes val_ref;
32192         CHECK(*((uint32_t*)val) == 3);
32193         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
32194         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
32195 }
32196
32197 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
32198         LDKNodeAnnouncementInfo this_ptr_conv;
32199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32200         this_ptr_conv.is_owned = false;
32201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32202         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
32203         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
32204         return ret_arr;
32205 }
32206
32207 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
32208         LDKNodeAnnouncementInfo this_ptr_conv;
32209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32210         this_ptr_conv.is_owned = false;
32211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32212         LDKThirtyTwoBytes val_ref;
32213         CHECK(*((uint32_t*)val) == 32);
32214         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
32215         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
32216 }
32217
32218 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
32219         LDKNodeAnnouncementInfo this_ptr_conv;
32220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32221         this_ptr_conv.is_owned = false;
32222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32223         LDKCVec_NetAddressZ val_constr;
32224         val_constr.datalen = *((uint32_t*)val);
32225         if (val_constr.datalen > 0)
32226                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
32227         else
32228                 val_constr.data = NULL;
32229         uint32_t* val_vals = (uint32_t*)(val + 4);
32230         for (size_t m = 0; m < val_constr.datalen; m++) {
32231                 uint32_t val_conv_12 = val_vals[m];
32232                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
32233                 CHECK_ACCESS(val_conv_12_ptr);
32234                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
32235                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
32236                 val_constr.data[m] = val_conv_12_conv;
32237         }
32238         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
32239 }
32240
32241 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
32242         LDKNodeAnnouncementInfo this_ptr_conv;
32243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32244         this_ptr_conv.is_owned = false;
32245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32246         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
32247         uint64_t ret_ref = 0;
32248         if ((uint64_t)ret_var.inner > 4096) {
32249                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32250                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32252                 ret_ref = (uint64_t)ret_var.inner;
32253                 if (ret_var.is_owned) {
32254                         ret_ref |= 1;
32255                 }
32256         }
32257         return ret_ref;
32258 }
32259
32260 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
32261         LDKNodeAnnouncementInfo this_ptr_conv;
32262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32263         this_ptr_conv.is_owned = false;
32264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32265         LDKNodeAnnouncement val_conv;
32266         val_conv.inner = (void*)(val & (~1));
32267         val_conv.is_owned = (val & 1) || (val == 0);
32268         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32269         val_conv = NodeAnnouncement_clone(&val_conv);
32270         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
32271 }
32272
32273 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_new(uint32_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int8_tArray alias_arg, uint32_tArray addresses_arg, uint32_t announcement_message_arg) {
32274         LDKNodeFeatures features_arg_conv;
32275         features_arg_conv.inner = (void*)(features_arg & (~1));
32276         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
32277         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
32278         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
32279         LDKThreeBytes rgb_arg_ref;
32280         CHECK(*((uint32_t*)rgb_arg) == 3);
32281         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
32282         LDKThirtyTwoBytes alias_arg_ref;
32283         CHECK(*((uint32_t*)alias_arg) == 32);
32284         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
32285         LDKCVec_NetAddressZ addresses_arg_constr;
32286         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
32287         if (addresses_arg_constr.datalen > 0)
32288                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
32289         else
32290                 addresses_arg_constr.data = NULL;
32291         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
32292         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
32293                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
32294                 void* addresses_arg_conv_12_ptr = (void*)(((uint64_t)addresses_arg_conv_12) & ~1);
32295                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
32296                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
32297                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
32298         }
32299         LDKNodeAnnouncement announcement_message_arg_conv;
32300         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
32301         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
32302         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
32303         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
32304         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
32305         uint64_t ret_ref = 0;
32306         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32307         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32308         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32309         ret_ref = (uint64_t)ret_var.inner;
32310         if (ret_var.is_owned) {
32311                 ret_ref |= 1;
32312         }
32313         return ret_ref;
32314 }
32315
32316 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
32317         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
32318 uint64_t ret_ref = 0;
32319 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32320 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32321 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32322 ret_ref = (uint64_t)ret_var.inner;
32323 if (ret_var.is_owned) {
32324         ret_ref |= 1;
32325 }
32326         return ret_ref;
32327 }
32328 int64_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
32329         LDKNodeAnnouncementInfo arg_conv;
32330         arg_conv.inner = (void*)(arg & (~1));
32331         arg_conv.is_owned = false;
32332         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32333         int64_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
32334         return ret_val;
32335 }
32336
32337 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
32338         LDKNodeAnnouncementInfo orig_conv;
32339         orig_conv.inner = (void*)(orig & (~1));
32340         orig_conv.is_owned = false;
32341         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32342         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
32343         uint64_t ret_ref = 0;
32344         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32345         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32347         ret_ref = (uint64_t)ret_var.inner;
32348         if (ret_var.is_owned) {
32349                 ret_ref |= 1;
32350         }
32351         return ret_ref;
32352 }
32353
32354 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
32355         LDKNodeAnnouncementInfo obj_conv;
32356         obj_conv.inner = (void*)(obj & (~1));
32357         obj_conv.is_owned = false;
32358         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32359         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
32360         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
32361         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
32362         CVec_u8Z_free(ret_var);
32363         return ret_arr;
32364 }
32365
32366 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
32367         LDKu8slice ser_ref;
32368         ser_ref.datalen = *((uint32_t*)ser);
32369         ser_ref.data = (int8_t*)(ser + 4);
32370         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
32371         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
32372         return (uint64_t)ret_conv;
32373 }
32374
32375 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_obj) {
32376         LDKNodeInfo this_obj_conv;
32377         this_obj_conv.inner = (void*)(this_obj & (~1));
32378         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32380         NodeInfo_free(this_obj_conv);
32381 }
32382
32383 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
32384         LDKNodeInfo this_ptr_conv;
32385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32386         this_ptr_conv.is_owned = false;
32387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32388         LDKCVec_u64Z val_constr;
32389         val_constr.datalen = *((uint32_t*)val);
32390         if (val_constr.datalen > 0)
32391                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32392         else
32393                 val_constr.data = NULL;
32394         int64_t* val_vals = (int64_t*)(val + 4);
32395         for (size_t i = 0; i < val_constr.datalen; i++) {
32396                 int64_t val_conv_8 = val_vals[i];
32397                 val_constr.data[i] = val_conv_8;
32398         }
32399         NodeInfo_set_channels(&this_ptr_conv, val_constr);
32400 }
32401
32402 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
32403         LDKNodeInfo this_ptr_conv;
32404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32405         this_ptr_conv.is_owned = false;
32406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32407         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
32408         uint64_t ret_ref = 0;
32409         if ((uint64_t)ret_var.inner > 4096) {
32410                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32411                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32413                 ret_ref = (uint64_t)ret_var.inner;
32414                 if (ret_var.is_owned) {
32415                         ret_ref |= 1;
32416                 }
32417         }
32418         return ret_ref;
32419 }
32420
32421 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
32422         LDKNodeInfo this_ptr_conv;
32423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32424         this_ptr_conv.is_owned = false;
32425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32426         LDKRoutingFees val_conv;
32427         val_conv.inner = (void*)(val & (~1));
32428         val_conv.is_owned = (val & 1) || (val == 0);
32429         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32430         val_conv = RoutingFees_clone(&val_conv);
32431         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
32432 }
32433
32434 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
32435         LDKNodeInfo this_ptr_conv;
32436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32437         this_ptr_conv.is_owned = false;
32438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32439         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
32440         uint64_t ret_ref = 0;
32441         if ((uint64_t)ret_var.inner > 4096) {
32442                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32443                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32445                 ret_ref = (uint64_t)ret_var.inner;
32446                 if (ret_var.is_owned) {
32447                         ret_ref |= 1;
32448                 }
32449         }
32450         return ret_ref;
32451 }
32452
32453 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
32454         LDKNodeInfo this_ptr_conv;
32455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32456         this_ptr_conv.is_owned = false;
32457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32458         LDKNodeAnnouncementInfo val_conv;
32459         val_conv.inner = (void*)(val & (~1));
32460         val_conv.is_owned = (val & 1) || (val == 0);
32461         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32462         val_conv = NodeAnnouncementInfo_clone(&val_conv);
32463         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
32464 }
32465
32466 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
32467         LDKCVec_u64Z channels_arg_constr;
32468         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
32469         if (channels_arg_constr.datalen > 0)
32470                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32471         else
32472                 channels_arg_constr.data = NULL;
32473         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
32474         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
32475                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
32476                 channels_arg_constr.data[i] = channels_arg_conv_8;
32477         }
32478         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
32479         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
32480         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
32481         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
32482         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
32483         LDKNodeAnnouncementInfo announcement_info_arg_conv;
32484         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
32485         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
32486         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
32487         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
32488         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
32489         uint64_t ret_ref = 0;
32490         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32491         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32493         ret_ref = (uint64_t)ret_var.inner;
32494         if (ret_var.is_owned) {
32495                 ret_ref |= 1;
32496         }
32497         return ret_ref;
32498 }
32499
32500 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
32501         LDKNodeInfo ret_var = NodeInfo_clone(arg);
32502 uint64_t ret_ref = 0;
32503 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32504 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32505 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32506 ret_ref = (uint64_t)ret_var.inner;
32507 if (ret_var.is_owned) {
32508         ret_ref |= 1;
32509 }
32510         return ret_ref;
32511 }
32512 int64_t  __attribute__((visibility("default"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
32513         LDKNodeInfo arg_conv;
32514         arg_conv.inner = (void*)(arg & (~1));
32515         arg_conv.is_owned = false;
32516         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32517         int64_t ret_val = NodeInfo_clone_ptr(&arg_conv);
32518         return ret_val;
32519 }
32520
32521 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig) {
32522         LDKNodeInfo orig_conv;
32523         orig_conv.inner = (void*)(orig & (~1));
32524         orig_conv.is_owned = false;
32525         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32526         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
32527         uint64_t ret_ref = 0;
32528         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32529         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32531         ret_ref = (uint64_t)ret_var.inner;
32532         if (ret_var.is_owned) {
32533                 ret_ref |= 1;
32534         }
32535         return ret_ref;
32536 }
32537
32538 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
32539         LDKNodeInfo obj_conv;
32540         obj_conv.inner = (void*)(obj & (~1));
32541         obj_conv.is_owned = false;
32542         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32543         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
32544         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
32545         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
32546         CVec_u8Z_free(ret_var);
32547         return ret_arr;
32548 }
32549
32550 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
32551         LDKu8slice ser_ref;
32552         ser_ref.datalen = *((uint32_t*)ser);
32553         ser_ref.data = (int8_t*)(ser + 4);
32554         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
32555         *ret_conv = NodeInfo_read(ser_ref);
32556         return (uint64_t)ret_conv;
32557 }
32558
32559 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
32560         LDKNetworkGraph obj_conv;
32561         obj_conv.inner = (void*)(obj & (~1));
32562         obj_conv.is_owned = false;
32563         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32564         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
32565         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
32566         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
32567         CVec_u8Z_free(ret_var);
32568         return ret_arr;
32569 }
32570
32571 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
32572         LDKu8slice ser_ref;
32573         ser_ref.datalen = *((uint32_t*)ser);
32574         ser_ref.data = (int8_t*)(ser + 4);
32575         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
32576         *ret_conv = NetworkGraph_read(ser_ref);
32577         return (uint64_t)ret_conv;
32578 }
32579
32580 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
32581         LDKThirtyTwoBytes genesis_hash_ref;
32582         CHECK(*((uint32_t*)genesis_hash) == 32);
32583         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
32584         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
32585         uint64_t ret_ref = 0;
32586         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32587         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32589         ret_ref = (uint64_t)ret_var.inner;
32590         if (ret_var.is_owned) {
32591                 ret_ref |= 1;
32592         }
32593         return ret_ref;
32594 }
32595
32596 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
32597         LDKNetworkGraph this_arg_conv;
32598         this_arg_conv.inner = (void*)(this_arg & (~1));
32599         this_arg_conv.is_owned = false;
32600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32601         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
32602         uint64_t ret_ref = 0;
32603         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32604         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32605         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32606         ret_ref = (uint64_t)ret_var.inner;
32607         if (ret_var.is_owned) {
32608                 ret_ref |= 1;
32609         }
32610         return ret_ref;
32611 }
32612
32613 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
32614         LDKNetworkGraph this_arg_conv;
32615         this_arg_conv.inner = (void*)(this_arg & (~1));
32616         this_arg_conv.is_owned = false;
32617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32618         LDKNodeAnnouncement msg_conv;
32619         msg_conv.inner = (void*)(msg & (~1));
32620         msg_conv.is_owned = false;
32621         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32622         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
32623         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
32624         return (uint64_t)ret_conv;
32625 }
32626
32627 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
32628         LDKNetworkGraph this_arg_conv;
32629         this_arg_conv.inner = (void*)(this_arg & (~1));
32630         this_arg_conv.is_owned = false;
32631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32632         LDKUnsignedNodeAnnouncement msg_conv;
32633         msg_conv.inner = (void*)(msg & (~1));
32634         msg_conv.is_owned = false;
32635         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32636         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
32637         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
32638         return (uint64_t)ret_conv;
32639 }
32640
32641 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
32642         LDKNetworkGraph this_arg_conv;
32643         this_arg_conv.inner = (void*)(this_arg & (~1));
32644         this_arg_conv.is_owned = false;
32645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32646         LDKChannelAnnouncement msg_conv;
32647         msg_conv.inner = (void*)(msg & (~1));
32648         msg_conv.is_owned = false;
32649         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32650         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
32651         CHECK_ACCESS(chain_access_ptr);
32652         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
32653         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
32654         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
32655                 // Manually implement clone for Java trait instances
32656         }
32657         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
32658         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
32659         return (uint64_t)ret_conv;
32660 }
32661
32662 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
32663         LDKNetworkGraph this_arg_conv;
32664         this_arg_conv.inner = (void*)(this_arg & (~1));
32665         this_arg_conv.is_owned = false;
32666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32667         LDKUnsignedChannelAnnouncement msg_conv;
32668         msg_conv.inner = (void*)(msg & (~1));
32669         msg_conv.is_owned = false;
32670         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32671         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
32672         CHECK_ACCESS(chain_access_ptr);
32673         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
32674         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
32675         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
32676                 // Manually implement clone for Java trait instances
32677         }
32678         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
32679         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
32680         return (uint64_t)ret_conv;
32681 }
32682
32683 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
32684         LDKNetworkGraph this_arg_conv;
32685         this_arg_conv.inner = (void*)(this_arg & (~1));
32686         this_arg_conv.is_owned = false;
32687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32688         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
32689 }
32690
32691 void  __attribute__((visibility("default"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
32692         LDKNetworkGraph this_arg_conv;
32693         this_arg_conv.inner = (void*)(this_arg & (~1));
32694         this_arg_conv.is_owned = false;
32695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32696         LDKPublicKey _node_id_ref;
32697         CHECK(*((uint32_t*)_node_id) == 33);
32698         memcpy(_node_id_ref.compressed_form, (uint8_t*)(_node_id + 4), 33);
32699         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
32700 }
32701
32702 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
32703         LDKNetworkGraph this_arg_conv;
32704         this_arg_conv.inner = (void*)(this_arg & (~1));
32705         this_arg_conv.is_owned = false;
32706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32707         LDKChannelUpdate msg_conv;
32708         msg_conv.inner = (void*)(msg & (~1));
32709         msg_conv.is_owned = false;
32710         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32711         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
32712         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
32713         return (uint64_t)ret_conv;
32714 }
32715
32716 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
32717         LDKNetworkGraph this_arg_conv;
32718         this_arg_conv.inner = (void*)(this_arg & (~1));
32719         this_arg_conv.is_owned = false;
32720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32721         LDKUnsignedChannelUpdate msg_conv;
32722         msg_conv.inner = (void*)(msg & (~1));
32723         msg_conv.is_owned = false;
32724         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32725         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
32726         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
32727         return (uint64_t)ret_conv;
32728 }
32729
32730 uint32_t  __attribute__((visibility("default"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
32731         LDKReadOnlyNetworkGraph this_arg_conv;
32732         this_arg_conv.inner = (void*)(this_arg & (~1));
32733         this_arg_conv.is_owned = false;
32734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32735         LDKPublicKey pubkey_ref;
32736         CHECK(*((uint32_t*)pubkey) == 33);
32737         memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
32738         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
32739         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
32740         uint64_t ret_ref = (uint64_t)ret_copy;
32741         return ret_ref;
32742 }
32743
32744 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) {
32745         LDKRouteHop this_obj_conv;
32746         this_obj_conv.inner = (void*)(this_obj & (~1));
32747         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32749         RouteHop_free(this_obj_conv);
32750 }
32751
32752 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
32753         LDKRouteHop this_ptr_conv;
32754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32755         this_ptr_conv.is_owned = false;
32756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32757         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
32758         memcpy((uint8_t*)(ret_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
32759         return ret_arr;
32760 }
32761
32762 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
32763         LDKRouteHop this_ptr_conv;
32764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32765         this_ptr_conv.is_owned = false;
32766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32767         LDKPublicKey val_ref;
32768         CHECK(*((uint32_t*)val) == 33);
32769         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
32770         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
32771 }
32772
32773 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
32774         LDKRouteHop this_ptr_conv;
32775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32776         this_ptr_conv.is_owned = false;
32777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32778         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
32779         uint64_t ret_ref = 0;
32780         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32781         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32783         ret_ref = (uint64_t)ret_var.inner;
32784         if (ret_var.is_owned) {
32785                 ret_ref |= 1;
32786         }
32787         return ret_ref;
32788 }
32789
32790 void  __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
32791         LDKRouteHop this_ptr_conv;
32792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32793         this_ptr_conv.is_owned = false;
32794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32795         LDKNodeFeatures val_conv;
32796         val_conv.inner = (void*)(val & (~1));
32797         val_conv.is_owned = (val & 1) || (val == 0);
32798         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32799         val_conv = NodeFeatures_clone(&val_conv);
32800         RouteHop_set_node_features(&this_ptr_conv, val_conv);
32801 }
32802
32803 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
32804         LDKRouteHop this_ptr_conv;
32805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32806         this_ptr_conv.is_owned = false;
32807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32808         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
32809         return ret_val;
32810 }
32811
32812 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
32813         LDKRouteHop this_ptr_conv;
32814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32815         this_ptr_conv.is_owned = false;
32816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32817         RouteHop_set_short_channel_id(&this_ptr_conv, val);
32818 }
32819
32820 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
32821         LDKRouteHop this_ptr_conv;
32822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32823         this_ptr_conv.is_owned = false;
32824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32825         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
32826         uint64_t ret_ref = 0;
32827         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32828         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32830         ret_ref = (uint64_t)ret_var.inner;
32831         if (ret_var.is_owned) {
32832                 ret_ref |= 1;
32833         }
32834         return ret_ref;
32835 }
32836
32837 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
32838         LDKRouteHop this_ptr_conv;
32839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32840         this_ptr_conv.is_owned = false;
32841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32842         LDKChannelFeatures val_conv;
32843         val_conv.inner = (void*)(val & (~1));
32844         val_conv.is_owned = (val & 1) || (val == 0);
32845         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32846         val_conv = ChannelFeatures_clone(&val_conv);
32847         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
32848 }
32849
32850 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
32851         LDKRouteHop this_ptr_conv;
32852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32853         this_ptr_conv.is_owned = false;
32854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32855         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
32856         return ret_val;
32857 }
32858
32859 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
32860         LDKRouteHop this_ptr_conv;
32861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32862         this_ptr_conv.is_owned = false;
32863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32864         RouteHop_set_fee_msat(&this_ptr_conv, val);
32865 }
32866
32867 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
32868         LDKRouteHop this_ptr_conv;
32869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32870         this_ptr_conv.is_owned = false;
32871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32872         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
32873         return ret_val;
32874 }
32875
32876 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
32877         LDKRouteHop this_ptr_conv;
32878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32879         this_ptr_conv.is_owned = false;
32880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32881         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
32882 }
32883
32884 uint32_t  __attribute__((visibility("default"))) 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) {
32885         LDKPublicKey pubkey_arg_ref;
32886         CHECK(*((uint32_t*)pubkey_arg) == 33);
32887         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
32888         LDKNodeFeatures node_features_arg_conv;
32889         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
32890         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
32891         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
32892         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
32893         LDKChannelFeatures channel_features_arg_conv;
32894         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
32895         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
32896         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
32897         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
32898         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);
32899         uint64_t ret_ref = 0;
32900         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32901         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32903         ret_ref = (uint64_t)ret_var.inner;
32904         if (ret_var.is_owned) {
32905                 ret_ref |= 1;
32906         }
32907         return ret_ref;
32908 }
32909
32910 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
32911         LDKRouteHop ret_var = RouteHop_clone(arg);
32912 uint64_t ret_ref = 0;
32913 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32914 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32915 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32916 ret_ref = (uint64_t)ret_var.inner;
32917 if (ret_var.is_owned) {
32918         ret_ref |= 1;
32919 }
32920         return ret_ref;
32921 }
32922 int64_t  __attribute__((visibility("default"))) TS_RouteHop_clone_ptr(uint32_t arg) {
32923         LDKRouteHop arg_conv;
32924         arg_conv.inner = (void*)(arg & (~1));
32925         arg_conv.is_owned = false;
32926         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32927         int64_t ret_val = RouteHop_clone_ptr(&arg_conv);
32928         return ret_val;
32929 }
32930
32931 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
32932         LDKRouteHop orig_conv;
32933         orig_conv.inner = (void*)(orig & (~1));
32934         orig_conv.is_owned = false;
32935         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32936         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
32937         uint64_t ret_ref = 0;
32938         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32939         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32941         ret_ref = (uint64_t)ret_var.inner;
32942         if (ret_var.is_owned) {
32943                 ret_ref |= 1;
32944         }
32945         return ret_ref;
32946 }
32947
32948 int64_t  __attribute__((visibility("default"))) TS_RouteHop_hash(uint32_t o) {
32949         LDKRouteHop o_conv;
32950         o_conv.inner = (void*)(o & (~1));
32951         o_conv.is_owned = false;
32952         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
32953         int64_t ret_val = RouteHop_hash(&o_conv);
32954         return ret_val;
32955 }
32956
32957 jboolean  __attribute__((visibility("default"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
32958         LDKRouteHop a_conv;
32959         a_conv.inner = (void*)(a & (~1));
32960         a_conv.is_owned = false;
32961         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32962         LDKRouteHop b_conv;
32963         b_conv.inner = (void*)(b & (~1));
32964         b_conv.is_owned = false;
32965         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
32966         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
32967         return ret_val;
32968 }
32969
32970 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_write(uint32_t obj) {
32971         LDKRouteHop obj_conv;
32972         obj_conv.inner = (void*)(obj & (~1));
32973         obj_conv.is_owned = false;
32974         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32975         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
32976         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
32977         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
32978         CVec_u8Z_free(ret_var);
32979         return ret_arr;
32980 }
32981
32982 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_read(int8_tArray ser) {
32983         LDKu8slice ser_ref;
32984         ser_ref.datalen = *((uint32_t*)ser);
32985         ser_ref.data = (int8_t*)(ser + 4);
32986         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
32987         *ret_conv = RouteHop_read(ser_ref);
32988         return (uint64_t)ret_conv;
32989 }
32990
32991 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) {
32992         LDKRoute this_obj_conv;
32993         this_obj_conv.inner = (void*)(this_obj & (~1));
32994         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32996         Route_free(this_obj_conv);
32997 }
32998
32999 ptrArray  __attribute__((visibility("default"))) TS_Route_get_paths(uint32_t this_ptr) {
33000         LDKRoute this_ptr_conv;
33001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33002         this_ptr_conv.is_owned = false;
33003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33004         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
33005         ptrArray ret_arr = NULL;
33006         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
33007         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(ret_arr + 4);
33008         for (size_t m = 0; m < ret_var.datalen; m++) {
33009                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
33010                 uint32_tArray ret_conv_12_arr = NULL;
33011                 ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
33012                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(ret_conv_12_arr + 4);
33013                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
33014                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
33015                         uint64_t ret_conv_12_conv_10_ref = 0;
33016                         CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33017                         CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33018                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
33019                         ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner;
33020                         if (ret_conv_12_conv_10_var.is_owned) {
33021                                 ret_conv_12_conv_10_ref |= 1;
33022                         }
33023                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
33024                 }
33025                 
33026                 FREE(ret_conv_12_var.data);
33027                 ret_arr_ptr[m] = ret_conv_12_arr;
33028         }
33029         
33030         FREE(ret_var.data);
33031         return ret_arr;
33032 }
33033
33034 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
33035         LDKRoute this_ptr_conv;
33036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33037         this_ptr_conv.is_owned = false;
33038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33039         LDKCVec_CVec_RouteHopZZ val_constr;
33040         val_constr.datalen = *((uint32_t*)val);
33041         if (val_constr.datalen > 0)
33042                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
33043         else
33044                 val_constr.data = NULL;
33045         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
33046         for (size_t m = 0; m < val_constr.datalen; m++) {
33047                 uint32_tArray val_conv_12 = val_vals[m];
33048                 LDKCVec_RouteHopZ val_conv_12_constr;
33049                 val_conv_12_constr.datalen = *((uint32_t*)val_conv_12);
33050                 if (val_conv_12_constr.datalen > 0)
33051                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
33052                 else
33053                         val_conv_12_constr.data = NULL;
33054                 uint32_t* val_conv_12_vals = (uint32_t*)(val_conv_12 + 4);
33055                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
33056                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
33057                         LDKRouteHop val_conv_12_conv_10_conv;
33058                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
33059                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
33060                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
33061                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
33062                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
33063                 }
33064                 val_constr.data[m] = val_conv_12_constr;
33065         }
33066         Route_set_paths(&this_ptr_conv, val_constr);
33067 }
33068
33069 uint32_t  __attribute__((visibility("default"))) TS_Route_get_payee(uint32_t this_ptr) {
33070         LDKRoute this_ptr_conv;
33071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33072         this_ptr_conv.is_owned = false;
33073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33074         LDKPayee ret_var = Route_get_payee(&this_ptr_conv);
33075         uint64_t ret_ref = 0;
33076         if ((uint64_t)ret_var.inner > 4096) {
33077                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33078                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33080                 ret_ref = (uint64_t)ret_var.inner;
33081                 if (ret_var.is_owned) {
33082                         ret_ref |= 1;
33083                 }
33084         }
33085         return ret_ref;
33086 }
33087
33088 void  __attribute__((visibility("default"))) TS_Route_set_payee(uint32_t this_ptr, uint32_t val) {
33089         LDKRoute this_ptr_conv;
33090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33091         this_ptr_conv.is_owned = false;
33092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33093         LDKPayee val_conv;
33094         val_conv.inner = (void*)(val & (~1));
33095         val_conv.is_owned = (val & 1) || (val == 0);
33096         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33097         val_conv = Payee_clone(&val_conv);
33098         Route_set_payee(&this_ptr_conv, val_conv);
33099 }
33100
33101 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg, uint32_t payee_arg) {
33102         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
33103         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
33104         if (paths_arg_constr.datalen > 0)
33105                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
33106         else
33107                 paths_arg_constr.data = NULL;
33108         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
33109         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
33110                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
33111                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
33112                 paths_arg_conv_12_constr.datalen = *((uint32_t*)paths_arg_conv_12);
33113                 if (paths_arg_conv_12_constr.datalen > 0)
33114                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
33115                 else
33116                         paths_arg_conv_12_constr.data = NULL;
33117                 uint32_t* paths_arg_conv_12_vals = (uint32_t*)(paths_arg_conv_12 + 4);
33118                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
33119                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
33120                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
33121                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
33122                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
33123                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
33124                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
33125                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
33126                 }
33127                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
33128         }
33129         LDKPayee payee_arg_conv;
33130         payee_arg_conv.inner = (void*)(payee_arg & (~1));
33131         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
33132         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
33133         payee_arg_conv = Payee_clone(&payee_arg_conv);
33134         LDKRoute ret_var = Route_new(paths_arg_constr, payee_arg_conv);
33135         uint64_t ret_ref = 0;
33136         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33137         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33139         ret_ref = (uint64_t)ret_var.inner;
33140         if (ret_var.is_owned) {
33141                 ret_ref |= 1;
33142         }
33143         return ret_ref;
33144 }
33145
33146 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
33147         LDKRoute ret_var = Route_clone(arg);
33148 uint64_t ret_ref = 0;
33149 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33150 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33151 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33152 ret_ref = (uint64_t)ret_var.inner;
33153 if (ret_var.is_owned) {
33154         ret_ref |= 1;
33155 }
33156         return ret_ref;
33157 }
33158 int64_t  __attribute__((visibility("default"))) TS_Route_clone_ptr(uint32_t arg) {
33159         LDKRoute arg_conv;
33160         arg_conv.inner = (void*)(arg & (~1));
33161         arg_conv.is_owned = false;
33162         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33163         int64_t ret_val = Route_clone_ptr(&arg_conv);
33164         return ret_val;
33165 }
33166
33167 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
33168         LDKRoute orig_conv;
33169         orig_conv.inner = (void*)(orig & (~1));
33170         orig_conv.is_owned = false;
33171         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33172         LDKRoute ret_var = Route_clone(&orig_conv);
33173         uint64_t ret_ref = 0;
33174         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33175         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33177         ret_ref = (uint64_t)ret_var.inner;
33178         if (ret_var.is_owned) {
33179                 ret_ref |= 1;
33180         }
33181         return ret_ref;
33182 }
33183
33184 int64_t  __attribute__((visibility("default"))) TS_Route_hash(uint32_t o) {
33185         LDKRoute o_conv;
33186         o_conv.inner = (void*)(o & (~1));
33187         o_conv.is_owned = false;
33188         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33189         int64_t ret_val = Route_hash(&o_conv);
33190         return ret_val;
33191 }
33192
33193 jboolean  __attribute__((visibility("default"))) TS_Route_eq(uint32_t a, uint32_t b) {
33194         LDKRoute a_conv;
33195         a_conv.inner = (void*)(a & (~1));
33196         a_conv.is_owned = false;
33197         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33198         LDKRoute b_conv;
33199         b_conv.inner = (void*)(b & (~1));
33200         b_conv.is_owned = false;
33201         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33202         jboolean ret_val = Route_eq(&a_conv, &b_conv);
33203         return ret_val;
33204 }
33205
33206 int64_t  __attribute__((visibility("default"))) TS_Route_get_total_fees(uint32_t this_arg) {
33207         LDKRoute this_arg_conv;
33208         this_arg_conv.inner = (void*)(this_arg & (~1));
33209         this_arg_conv.is_owned = false;
33210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33211         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
33212         return ret_val;
33213 }
33214
33215 int64_t  __attribute__((visibility("default"))) TS_Route_get_total_amount(uint32_t this_arg) {
33216         LDKRoute this_arg_conv;
33217         this_arg_conv.inner = (void*)(this_arg & (~1));
33218         this_arg_conv.is_owned = false;
33219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33220         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
33221         return ret_val;
33222 }
33223
33224 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
33225         LDKRoute obj_conv;
33226         obj_conv.inner = (void*)(obj & (~1));
33227         obj_conv.is_owned = false;
33228         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33229         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
33230         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
33231         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
33232         CVec_u8Z_free(ret_var);
33233         return ret_arr;
33234 }
33235
33236 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
33237         LDKu8slice ser_ref;
33238         ser_ref.datalen = *((uint32_t*)ser);
33239         ser_ref.data = (int8_t*)(ser + 4);
33240         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
33241         *ret_conv = Route_read(ser_ref);
33242         return (uint64_t)ret_conv;
33243 }
33244
33245 void  __attribute__((visibility("default"))) TS_RouteParameters_free(uint32_t this_obj) {
33246         LDKRouteParameters this_obj_conv;
33247         this_obj_conv.inner = (void*)(this_obj & (~1));
33248         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33250         RouteParameters_free(this_obj_conv);
33251 }
33252
33253 uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_get_payee(uint32_t this_ptr) {
33254         LDKRouteParameters this_ptr_conv;
33255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33256         this_ptr_conv.is_owned = false;
33257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33258         LDKPayee ret_var = RouteParameters_get_payee(&this_ptr_conv);
33259         uint64_t ret_ref = 0;
33260         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33261         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33263         ret_ref = (uint64_t)ret_var.inner;
33264         if (ret_var.is_owned) {
33265                 ret_ref |= 1;
33266         }
33267         return ret_ref;
33268 }
33269
33270 void  __attribute__((visibility("default"))) TS_RouteParameters_set_payee(uint32_t this_ptr, uint32_t val) {
33271         LDKRouteParameters this_ptr_conv;
33272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33273         this_ptr_conv.is_owned = false;
33274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33275         LDKPayee val_conv;
33276         val_conv.inner = (void*)(val & (~1));
33277         val_conv.is_owned = (val & 1) || (val == 0);
33278         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33279         val_conv = Payee_clone(&val_conv);
33280         RouteParameters_set_payee(&this_ptr_conv, val_conv);
33281 }
33282
33283 int64_t  __attribute__((visibility("default"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
33284         LDKRouteParameters this_ptr_conv;
33285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33286         this_ptr_conv.is_owned = false;
33287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33288         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
33289         return ret_val;
33290 }
33291
33292 void  __attribute__((visibility("default"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
33293         LDKRouteParameters this_ptr_conv;
33294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33295         this_ptr_conv.is_owned = false;
33296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33297         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
33298 }
33299
33300 int32_t  __attribute__((visibility("default"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
33301         LDKRouteParameters this_ptr_conv;
33302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33303         this_ptr_conv.is_owned = false;
33304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33305         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
33306         return ret_val;
33307 }
33308
33309 void  __attribute__((visibility("default"))) TS_RouteParameters_set_final_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
33310         LDKRouteParameters this_ptr_conv;
33311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33312         this_ptr_conv.is_owned = false;
33313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33314         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
33315 }
33316
33317 uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_new(uint32_t payee_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
33318         LDKPayee payee_arg_conv;
33319         payee_arg_conv.inner = (void*)(payee_arg & (~1));
33320         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
33321         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
33322         payee_arg_conv = Payee_clone(&payee_arg_conv);
33323         LDKRouteParameters ret_var = RouteParameters_new(payee_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
33324         uint64_t ret_ref = 0;
33325         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33326         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33328         ret_ref = (uint64_t)ret_var.inner;
33329         if (ret_var.is_owned) {
33330                 ret_ref |= 1;
33331         }
33332         return ret_ref;
33333 }
33334
33335 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
33336         LDKRouteParameters ret_var = RouteParameters_clone(arg);
33337 uint64_t ret_ref = 0;
33338 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33339 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33340 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33341 ret_ref = (uint64_t)ret_var.inner;
33342 if (ret_var.is_owned) {
33343         ret_ref |= 1;
33344 }
33345         return ret_ref;
33346 }
33347 int64_t  __attribute__((visibility("default"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
33348         LDKRouteParameters arg_conv;
33349         arg_conv.inner = (void*)(arg & (~1));
33350         arg_conv.is_owned = false;
33351         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33352         int64_t ret_val = RouteParameters_clone_ptr(&arg_conv);
33353         return ret_val;
33354 }
33355
33356 uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_clone(uint32_t orig) {
33357         LDKRouteParameters orig_conv;
33358         orig_conv.inner = (void*)(orig & (~1));
33359         orig_conv.is_owned = false;
33360         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33361         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
33362         uint64_t ret_ref = 0;
33363         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33364         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33366         ret_ref = (uint64_t)ret_var.inner;
33367         if (ret_var.is_owned) {
33368                 ret_ref |= 1;
33369         }
33370         return ret_ref;
33371 }
33372
33373 int8_tArray  __attribute__((visibility("default"))) TS_RouteParameters_write(uint32_t obj) {
33374         LDKRouteParameters obj_conv;
33375         obj_conv.inner = (void*)(obj & (~1));
33376         obj_conv.is_owned = false;
33377         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33378         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
33379         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
33380         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
33381         CVec_u8Z_free(ret_var);
33382         return ret_arr;
33383 }
33384
33385 uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_read(int8_tArray ser) {
33386         LDKu8slice ser_ref;
33387         ser_ref.datalen = *((uint32_t*)ser);
33388         ser_ref.data = (int8_t*)(ser + 4);
33389         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
33390         *ret_conv = RouteParameters_read(ser_ref);
33391         return (uint64_t)ret_conv;
33392 }
33393
33394 void  __attribute__((visibility("default"))) TS_Payee_free(uint32_t this_obj) {
33395         LDKPayee this_obj_conv;
33396         this_obj_conv.inner = (void*)(this_obj & (~1));
33397         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33399         Payee_free(this_obj_conv);
33400 }
33401
33402 int8_tArray  __attribute__((visibility("default"))) TS_Payee_get_pubkey(uint32_t this_ptr) {
33403         LDKPayee this_ptr_conv;
33404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33405         this_ptr_conv.is_owned = false;
33406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33407         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
33408         memcpy((uint8_t*)(ret_arr + 4), Payee_get_pubkey(&this_ptr_conv).compressed_form, 33);
33409         return ret_arr;
33410 }
33411
33412 void  __attribute__((visibility("default"))) TS_Payee_set_pubkey(uint32_t this_ptr, int8_tArray val) {
33413         LDKPayee this_ptr_conv;
33414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33415         this_ptr_conv.is_owned = false;
33416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33417         LDKPublicKey val_ref;
33418         CHECK(*((uint32_t*)val) == 33);
33419         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
33420         Payee_set_pubkey(&this_ptr_conv, val_ref);
33421 }
33422
33423 uint32_t  __attribute__((visibility("default"))) TS_Payee_get_features(uint32_t this_ptr) {
33424         LDKPayee this_ptr_conv;
33425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33426         this_ptr_conv.is_owned = false;
33427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33428         LDKInvoiceFeatures ret_var = Payee_get_features(&this_ptr_conv);
33429         uint64_t ret_ref = 0;
33430         if ((uint64_t)ret_var.inner > 4096) {
33431                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33432                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33434                 ret_ref = (uint64_t)ret_var.inner;
33435                 if (ret_var.is_owned) {
33436                         ret_ref |= 1;
33437                 }
33438         }
33439         return ret_ref;
33440 }
33441
33442 void  __attribute__((visibility("default"))) TS_Payee_set_features(uint32_t this_ptr, uint32_t val) {
33443         LDKPayee this_ptr_conv;
33444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33445         this_ptr_conv.is_owned = false;
33446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33447         LDKInvoiceFeatures val_conv;
33448         val_conv.inner = (void*)(val & (~1));
33449         val_conv.is_owned = (val & 1) || (val == 0);
33450         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33451         val_conv = InvoiceFeatures_clone(&val_conv);
33452         Payee_set_features(&this_ptr_conv, val_conv);
33453 }
33454
33455 uint32_tArray  __attribute__((visibility("default"))) TS_Payee_get_route_hints(uint32_t this_ptr) {
33456         LDKPayee this_ptr_conv;
33457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33458         this_ptr_conv.is_owned = false;
33459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33460         LDKCVec_RouteHintZ ret_var = Payee_get_route_hints(&this_ptr_conv);
33461         uint32_tArray ret_arr = NULL;
33462         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
33463         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
33464         for (size_t l = 0; l < ret_var.datalen; l++) {
33465                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
33466                 uint64_t ret_conv_11_ref = 0;
33467                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33468                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33469                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
33470                 ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
33471                 if (ret_conv_11_var.is_owned) {
33472                         ret_conv_11_ref |= 1;
33473                 }
33474                 ret_arr_ptr[l] = ret_conv_11_ref;
33475         }
33476         
33477         FREE(ret_var.data);
33478         return ret_arr;
33479 }
33480
33481 void  __attribute__((visibility("default"))) TS_Payee_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
33482         LDKPayee this_ptr_conv;
33483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33484         this_ptr_conv.is_owned = false;
33485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33486         LDKCVec_RouteHintZ val_constr;
33487         val_constr.datalen = *((uint32_t*)val);
33488         if (val_constr.datalen > 0)
33489                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
33490         else
33491                 val_constr.data = NULL;
33492         uint32_t* val_vals = (uint32_t*)(val + 4);
33493         for (size_t l = 0; l < val_constr.datalen; l++) {
33494                 uint32_t val_conv_11 = val_vals[l];
33495                 LDKRouteHint val_conv_11_conv;
33496                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
33497                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
33498                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
33499                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
33500                 val_constr.data[l] = val_conv_11_conv;
33501         }
33502         Payee_set_route_hints(&this_ptr_conv, val_constr);
33503 }
33504
33505 uint32_t  __attribute__((visibility("default"))) TS_Payee_get_expiry_time(uint32_t this_ptr) {
33506         LDKPayee this_ptr_conv;
33507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33508         this_ptr_conv.is_owned = false;
33509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33510         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
33511         *ret_copy = Payee_get_expiry_time(&this_ptr_conv);
33512         uint64_t ret_ref = (uint64_t)ret_copy;
33513         return ret_ref;
33514 }
33515
33516 void  __attribute__((visibility("default"))) TS_Payee_set_expiry_time(uint32_t this_ptr, uint32_t val) {
33517         LDKPayee this_ptr_conv;
33518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33519         this_ptr_conv.is_owned = false;
33520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33521         void* val_ptr = (void*)(((uint64_t)val) & ~1);
33522         CHECK_ACCESS(val_ptr);
33523         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
33524         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
33525         Payee_set_expiry_time(&this_ptr_conv, val_conv);
33526 }
33527
33528 uint32_t  __attribute__((visibility("default"))) TS_Payee_new(int8_tArray pubkey_arg, uint32_t features_arg, uint32_tArray route_hints_arg, uint32_t expiry_time_arg) {
33529         LDKPublicKey pubkey_arg_ref;
33530         CHECK(*((uint32_t*)pubkey_arg) == 33);
33531         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
33532         LDKInvoiceFeatures features_arg_conv;
33533         features_arg_conv.inner = (void*)(features_arg & (~1));
33534         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
33535         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
33536         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
33537         LDKCVec_RouteHintZ route_hints_arg_constr;
33538         route_hints_arg_constr.datalen = *((uint32_t*)route_hints_arg);
33539         if (route_hints_arg_constr.datalen > 0)
33540                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
33541         else
33542                 route_hints_arg_constr.data = NULL;
33543         uint32_t* route_hints_arg_vals = (uint32_t*)(route_hints_arg + 4);
33544         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
33545                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
33546                 LDKRouteHint route_hints_arg_conv_11_conv;
33547                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
33548                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
33549                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
33550                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
33551                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
33552         }
33553         void* expiry_time_arg_ptr = (void*)(((uint64_t)expiry_time_arg) & ~1);
33554         CHECK_ACCESS(expiry_time_arg_ptr);
33555         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
33556         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)expiry_time_arg) & ~1));
33557         LDKPayee ret_var = Payee_new(pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv);
33558         uint64_t ret_ref = 0;
33559         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33560         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33562         ret_ref = (uint64_t)ret_var.inner;
33563         if (ret_var.is_owned) {
33564                 ret_ref |= 1;
33565         }
33566         return ret_ref;
33567 }
33568
33569 static inline uint64_t Payee_clone_ptr(LDKPayee *NONNULL_PTR arg) {
33570         LDKPayee ret_var = Payee_clone(arg);
33571 uint64_t ret_ref = 0;
33572 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33573 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33574 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33575 ret_ref = (uint64_t)ret_var.inner;
33576 if (ret_var.is_owned) {
33577         ret_ref |= 1;
33578 }
33579         return ret_ref;
33580 }
33581 int64_t  __attribute__((visibility("default"))) TS_Payee_clone_ptr(uint32_t arg) {
33582         LDKPayee arg_conv;
33583         arg_conv.inner = (void*)(arg & (~1));
33584         arg_conv.is_owned = false;
33585         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33586         int64_t ret_val = Payee_clone_ptr(&arg_conv);
33587         return ret_val;
33588 }
33589
33590 uint32_t  __attribute__((visibility("default"))) TS_Payee_clone(uint32_t orig) {
33591         LDKPayee orig_conv;
33592         orig_conv.inner = (void*)(orig & (~1));
33593         orig_conv.is_owned = false;
33594         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33595         LDKPayee ret_var = Payee_clone(&orig_conv);
33596         uint64_t ret_ref = 0;
33597         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33598         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33600         ret_ref = (uint64_t)ret_var.inner;
33601         if (ret_var.is_owned) {
33602                 ret_ref |= 1;
33603         }
33604         return ret_ref;
33605 }
33606
33607 int64_t  __attribute__((visibility("default"))) TS_Payee_hash(uint32_t o) {
33608         LDKPayee o_conv;
33609         o_conv.inner = (void*)(o & (~1));
33610         o_conv.is_owned = false;
33611         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33612         int64_t ret_val = Payee_hash(&o_conv);
33613         return ret_val;
33614 }
33615
33616 jboolean  __attribute__((visibility("default"))) TS_Payee_eq(uint32_t a, uint32_t b) {
33617         LDKPayee a_conv;
33618         a_conv.inner = (void*)(a & (~1));
33619         a_conv.is_owned = false;
33620         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33621         LDKPayee b_conv;
33622         b_conv.inner = (void*)(b & (~1));
33623         b_conv.is_owned = false;
33624         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33625         jboolean ret_val = Payee_eq(&a_conv, &b_conv);
33626         return ret_val;
33627 }
33628
33629 int8_tArray  __attribute__((visibility("default"))) TS_Payee_write(uint32_t obj) {
33630         LDKPayee obj_conv;
33631         obj_conv.inner = (void*)(obj & (~1));
33632         obj_conv.is_owned = false;
33633         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33634         LDKCVec_u8Z ret_var = Payee_write(&obj_conv);
33635         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
33636         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
33637         CVec_u8Z_free(ret_var);
33638         return ret_arr;
33639 }
33640
33641 uint32_t  __attribute__((visibility("default"))) TS_Payee_read(int8_tArray ser) {
33642         LDKu8slice ser_ref;
33643         ser_ref.datalen = *((uint32_t*)ser);
33644         ser_ref.data = (int8_t*)(ser + 4);
33645         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
33646         *ret_conv = Payee_read(ser_ref);
33647         return (uint64_t)ret_conv;
33648 }
33649
33650 uint32_t  __attribute__((visibility("default"))) TS_Payee_from_node_id(int8_tArray pubkey) {
33651         LDKPublicKey pubkey_ref;
33652         CHECK(*((uint32_t*)pubkey) == 33);
33653         memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
33654         LDKPayee ret_var = Payee_from_node_id(pubkey_ref);
33655         uint64_t ret_ref = 0;
33656         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33657         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33659         ret_ref = (uint64_t)ret_var.inner;
33660         if (ret_var.is_owned) {
33661                 ret_ref |= 1;
33662         }
33663         return ret_ref;
33664 }
33665
33666 uint32_t  __attribute__((visibility("default"))) TS_Payee_for_keysend(int8_tArray pubkey) {
33667         LDKPublicKey pubkey_ref;
33668         CHECK(*((uint32_t*)pubkey) == 33);
33669         memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
33670         LDKPayee ret_var = Payee_for_keysend(pubkey_ref);
33671         uint64_t ret_ref = 0;
33672         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33673         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33675         ret_ref = (uint64_t)ret_var.inner;
33676         if (ret_var.is_owned) {
33677                 ret_ref |= 1;
33678         }
33679         return ret_ref;
33680 }
33681
33682 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
33683         LDKRouteHint this_obj_conv;
33684         this_obj_conv.inner = (void*)(this_obj & (~1));
33685         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33687         RouteHint_free(this_obj_conv);
33688 }
33689
33690 uint32_tArray  __attribute__((visibility("default"))) TS_RouteHint_get_a(uint32_t this_ptr) {
33691         LDKRouteHint this_ptr_conv;
33692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33693         this_ptr_conv.is_owned = false;
33694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33695         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
33696         uint32_tArray ret_arr = NULL;
33697         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
33698         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
33699         for (size_t o = 0; o < ret_var.datalen; o++) {
33700                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
33701                 uint64_t ret_conv_14_ref = 0;
33702                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33703                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33704                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
33705                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
33706                 if (ret_conv_14_var.is_owned) {
33707                         ret_conv_14_ref |= 1;
33708                 }
33709                 ret_arr_ptr[o] = ret_conv_14_ref;
33710         }
33711         
33712         FREE(ret_var.data);
33713         return ret_arr;
33714 }
33715
33716 void  __attribute__((visibility("default"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
33717         LDKRouteHint this_ptr_conv;
33718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33719         this_ptr_conv.is_owned = false;
33720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33721         LDKCVec_RouteHintHopZ val_constr;
33722         val_constr.datalen = *((uint32_t*)val);
33723         if (val_constr.datalen > 0)
33724                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
33725         else
33726                 val_constr.data = NULL;
33727         uint32_t* val_vals = (uint32_t*)(val + 4);
33728         for (size_t o = 0; o < val_constr.datalen; o++) {
33729                 uint32_t val_conv_14 = val_vals[o];
33730                 LDKRouteHintHop val_conv_14_conv;
33731                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
33732                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
33733                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
33734                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
33735                 val_constr.data[o] = val_conv_14_conv;
33736         }
33737         RouteHint_set_a(&this_ptr_conv, val_constr);
33738 }
33739
33740 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_new(uint32_tArray a_arg) {
33741         LDKCVec_RouteHintHopZ a_arg_constr;
33742         a_arg_constr.datalen = *((uint32_t*)a_arg);
33743         if (a_arg_constr.datalen > 0)
33744                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
33745         else
33746                 a_arg_constr.data = NULL;
33747         uint32_t* a_arg_vals = (uint32_t*)(a_arg + 4);
33748         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
33749                 uint32_t a_arg_conv_14 = a_arg_vals[o];
33750                 LDKRouteHintHop a_arg_conv_14_conv;
33751                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
33752                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
33753                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
33754                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
33755                 a_arg_constr.data[o] = a_arg_conv_14_conv;
33756         }
33757         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
33758         uint64_t ret_ref = 0;
33759         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33760         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33762         ret_ref = (uint64_t)ret_var.inner;
33763         if (ret_var.is_owned) {
33764                 ret_ref |= 1;
33765         }
33766         return ret_ref;
33767 }
33768
33769 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
33770         LDKRouteHint ret_var = RouteHint_clone(arg);
33771 uint64_t ret_ref = 0;
33772 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33773 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33774 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33775 ret_ref = (uint64_t)ret_var.inner;
33776 if (ret_var.is_owned) {
33777         ret_ref |= 1;
33778 }
33779         return ret_ref;
33780 }
33781 int64_t  __attribute__((visibility("default"))) TS_RouteHint_clone_ptr(uint32_t arg) {
33782         LDKRouteHint arg_conv;
33783         arg_conv.inner = (void*)(arg & (~1));
33784         arg_conv.is_owned = false;
33785         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33786         int64_t ret_val = RouteHint_clone_ptr(&arg_conv);
33787         return ret_val;
33788 }
33789
33790 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
33791         LDKRouteHint orig_conv;
33792         orig_conv.inner = (void*)(orig & (~1));
33793         orig_conv.is_owned = false;
33794         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33795         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
33796         uint64_t ret_ref = 0;
33797         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33798         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33800         ret_ref = (uint64_t)ret_var.inner;
33801         if (ret_var.is_owned) {
33802                 ret_ref |= 1;
33803         }
33804         return ret_ref;
33805 }
33806
33807 int64_t  __attribute__((visibility("default"))) TS_RouteHint_hash(uint32_t o) {
33808         LDKRouteHint o_conv;
33809         o_conv.inner = (void*)(o & (~1));
33810         o_conv.is_owned = false;
33811         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33812         int64_t ret_val = RouteHint_hash(&o_conv);
33813         return ret_val;
33814 }
33815
33816 jboolean  __attribute__((visibility("default"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
33817         LDKRouteHint a_conv;
33818         a_conv.inner = (void*)(a & (~1));
33819         a_conv.is_owned = false;
33820         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33821         LDKRouteHint b_conv;
33822         b_conv.inner = (void*)(b & (~1));
33823         b_conv.is_owned = false;
33824         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33825         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
33826         return ret_val;
33827 }
33828
33829 int8_tArray  __attribute__((visibility("default"))) TS_RouteHint_write(uint32_t obj) {
33830         LDKRouteHint obj_conv;
33831         obj_conv.inner = (void*)(obj & (~1));
33832         obj_conv.is_owned = false;
33833         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33834         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
33835         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
33836         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
33837         CVec_u8Z_free(ret_var);
33838         return ret_arr;
33839 }
33840
33841 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_read(int8_tArray ser) {
33842         LDKu8slice ser_ref;
33843         ser_ref.datalen = *((uint32_t*)ser);
33844         ser_ref.data = (int8_t*)(ser + 4);
33845         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
33846         *ret_conv = RouteHint_read(ser_ref);
33847         return (uint64_t)ret_conv;
33848 }
33849
33850 void  __attribute__((visibility("default"))) TS_RouteHintHop_free(uint32_t this_obj) {
33851         LDKRouteHintHop this_obj_conv;
33852         this_obj_conv.inner = (void*)(this_obj & (~1));
33853         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33855         RouteHintHop_free(this_obj_conv);
33856 }
33857
33858 int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
33859         LDKRouteHintHop this_ptr_conv;
33860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33861         this_ptr_conv.is_owned = false;
33862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33863         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
33864         memcpy((uint8_t*)(ret_arr + 4), RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
33865         return ret_arr;
33866 }
33867
33868 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
33869         LDKRouteHintHop this_ptr_conv;
33870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33871         this_ptr_conv.is_owned = false;
33872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33873         LDKPublicKey val_ref;
33874         CHECK(*((uint32_t*)val) == 33);
33875         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
33876         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
33877 }
33878
33879 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
33880         LDKRouteHintHop this_ptr_conv;
33881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33882         this_ptr_conv.is_owned = false;
33883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33884         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
33885         return ret_val;
33886 }
33887
33888 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
33889         LDKRouteHintHop this_ptr_conv;
33890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33891         this_ptr_conv.is_owned = false;
33892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33893         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
33894 }
33895
33896 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
33897         LDKRouteHintHop this_ptr_conv;
33898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33899         this_ptr_conv.is_owned = false;
33900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33901         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
33902         uint64_t ret_ref = 0;
33903         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33904         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33906         ret_ref = (uint64_t)ret_var.inner;
33907         if (ret_var.is_owned) {
33908                 ret_ref |= 1;
33909         }
33910         return ret_ref;
33911 }
33912
33913 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
33914         LDKRouteHintHop this_ptr_conv;
33915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33916         this_ptr_conv.is_owned = false;
33917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33918         LDKRoutingFees val_conv;
33919         val_conv.inner = (void*)(val & (~1));
33920         val_conv.is_owned = (val & 1) || (val == 0);
33921         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33922         val_conv = RoutingFees_clone(&val_conv);
33923         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
33924 }
33925
33926 int16_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
33927         LDKRouteHintHop this_ptr_conv;
33928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33929         this_ptr_conv.is_owned = false;
33930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33931         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
33932         return ret_val;
33933 }
33934
33935 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
33936         LDKRouteHintHop this_ptr_conv;
33937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33938         this_ptr_conv.is_owned = false;
33939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33940         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
33941 }
33942
33943 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
33944         LDKRouteHintHop this_ptr_conv;
33945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33946         this_ptr_conv.is_owned = false;
33947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33948         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
33949         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
33950         uint64_t ret_ref = (uint64_t)ret_copy;
33951         return ret_ref;
33952 }
33953
33954 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
33955         LDKRouteHintHop this_ptr_conv;
33956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33957         this_ptr_conv.is_owned = false;
33958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33959         void* val_ptr = (void*)(((uint64_t)val) & ~1);
33960         CHECK_ACCESS(val_ptr);
33961         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
33962         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
33963         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
33964 }
33965
33966 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
33967         LDKRouteHintHop this_ptr_conv;
33968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33969         this_ptr_conv.is_owned = false;
33970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33971         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
33972         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
33973         uint64_t ret_ref = (uint64_t)ret_copy;
33974         return ret_ref;
33975 }
33976
33977 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
33978         LDKRouteHintHop this_ptr_conv;
33979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33980         this_ptr_conv.is_owned = false;
33981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33982         void* val_ptr = (void*)(((uint64_t)val) & ~1);
33983         CHECK_ACCESS(val_ptr);
33984         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
33985         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
33986         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
33987 }
33988
33989 uint32_t  __attribute__((visibility("default"))) 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) {
33990         LDKPublicKey src_node_id_arg_ref;
33991         CHECK(*((uint32_t*)src_node_id_arg) == 33);
33992         memcpy(src_node_id_arg_ref.compressed_form, (uint8_t*)(src_node_id_arg + 4), 33);
33993         LDKRoutingFees fees_arg_conv;
33994         fees_arg_conv.inner = (void*)(fees_arg & (~1));
33995         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
33996         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
33997         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
33998         void* htlc_minimum_msat_arg_ptr = (void*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
33999         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
34000         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
34001         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1));
34002         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
34003         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
34004         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
34005         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
34006         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);
34007         uint64_t ret_ref = 0;
34008         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34009         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34011         ret_ref = (uint64_t)ret_var.inner;
34012         if (ret_var.is_owned) {
34013                 ret_ref |= 1;
34014         }
34015         return ret_ref;
34016 }
34017
34018 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
34019         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
34020 uint64_t ret_ref = 0;
34021 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34022 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34023 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34024 ret_ref = (uint64_t)ret_var.inner;
34025 if (ret_var.is_owned) {
34026         ret_ref |= 1;
34027 }
34028         return ret_ref;
34029 }
34030 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
34031         LDKRouteHintHop arg_conv;
34032         arg_conv.inner = (void*)(arg & (~1));
34033         arg_conv.is_owned = false;
34034         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34035         int64_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
34036         return ret_val;
34037 }
34038
34039 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t orig) {
34040         LDKRouteHintHop orig_conv;
34041         orig_conv.inner = (void*)(orig & (~1));
34042         orig_conv.is_owned = false;
34043         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34044         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
34045         uint64_t ret_ref = 0;
34046         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34047         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34049         ret_ref = (uint64_t)ret_var.inner;
34050         if (ret_var.is_owned) {
34051                 ret_ref |= 1;
34052         }
34053         return ret_ref;
34054 }
34055
34056 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_hash(uint32_t o) {
34057         LDKRouteHintHop o_conv;
34058         o_conv.inner = (void*)(o & (~1));
34059         o_conv.is_owned = false;
34060         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34061         int64_t ret_val = RouteHintHop_hash(&o_conv);
34062         return ret_val;
34063 }
34064
34065 jboolean  __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
34066         LDKRouteHintHop a_conv;
34067         a_conv.inner = (void*)(a & (~1));
34068         a_conv.is_owned = false;
34069         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34070         LDKRouteHintHop b_conv;
34071         b_conv.inner = (void*)(b & (~1));
34072         b_conv.is_owned = false;
34073         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34074         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
34075         return ret_val;
34076 }
34077
34078 int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_write(uint32_t obj) {
34079         LDKRouteHintHop obj_conv;
34080         obj_conv.inner = (void*)(obj & (~1));
34081         obj_conv.is_owned = false;
34082         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34083         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
34084         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
34085         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
34086         CVec_u8Z_free(ret_var);
34087         return ret_arr;
34088 }
34089
34090 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_read(int8_tArray ser) {
34091         LDKu8slice ser_ref;
34092         ser_ref.datalen = *((uint32_t*)ser);
34093         ser_ref.data = (int8_t*)(ser + 4);
34094         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
34095         *ret_conv = RouteHintHop_read(ser_ref);
34096         return (uint64_t)ret_conv;
34097 }
34098
34099 uint32_t  __attribute__((visibility("default"))) TS_find_route(int8_tArray our_node_pubkey, uint32_t params, uint32_t network, uint32_tArray first_hops, uint32_t logger, uint32_t scorer) {
34100         LDKPublicKey our_node_pubkey_ref;
34101         CHECK(*((uint32_t*)our_node_pubkey) == 33);
34102         memcpy(our_node_pubkey_ref.compressed_form, (uint8_t*)(our_node_pubkey + 4), 33);
34103         LDKRouteParameters params_conv;
34104         params_conv.inner = (void*)(params & (~1));
34105         params_conv.is_owned = false;
34106         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
34107         LDKNetworkGraph network_conv;
34108         network_conv.inner = (void*)(network & (~1));
34109         network_conv.is_owned = false;
34110         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
34111         LDKCVec_ChannelDetailsZ first_hops_constr;
34112         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
34113         if (first_hops != 0) {
34114                 first_hops_constr.datalen = *((uint32_t*)first_hops);
34115                 if (first_hops_constr.datalen > 0)
34116                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
34117                 else
34118                         first_hops_constr.data = NULL;
34119                 uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
34120                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
34121                         uint32_t first_hops_conv_16 = first_hops_vals[q];
34122                         LDKChannelDetails first_hops_conv_16_conv;
34123                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
34124                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
34125                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
34126                         first_hops_constr.data[q] = first_hops_conv_16_conv;
34127                 }
34128                 first_hops_ptr = &first_hops_constr;
34129         }
34130         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
34131         CHECK_ACCESS(logger_ptr);
34132         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34133         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
34134         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
34135         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
34136         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
34137         *ret_conv = find_route(our_node_pubkey_ref, &params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
34138         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
34139         return (uint64_t)ret_conv;
34140 }
34141
34142 void  __attribute__((visibility("default"))) TS_Scorer_free(uint32_t this_obj) {
34143         LDKScorer this_obj_conv;
34144         this_obj_conv.inner = (void*)(this_obj & (~1));
34145         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34147         Scorer_free(this_obj_conv);
34148 }
34149
34150 void  __attribute__((visibility("default"))) TS_ScoringParameters_free(uint32_t this_obj) {
34151         LDKScoringParameters this_obj_conv;
34152         this_obj_conv.inner = (void*)(this_obj & (~1));
34153         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34155         ScoringParameters_free(this_obj_conv);
34156 }
34157
34158 int64_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
34159         LDKScoringParameters this_ptr_conv;
34160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34161         this_ptr_conv.is_owned = false;
34162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34163         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
34164         return ret_val;
34165 }
34166
34167 void  __attribute__((visibility("default"))) TS_ScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
34168         LDKScoringParameters this_ptr_conv;
34169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34170         this_ptr_conv.is_owned = false;
34171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34172         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
34173 }
34174
34175 int64_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_failure_penalty_msat(uint32_t this_ptr) {
34176         LDKScoringParameters this_ptr_conv;
34177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34178         this_ptr_conv.is_owned = false;
34179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34180         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
34181         return ret_val;
34182 }
34183
34184 void  __attribute__((visibility("default"))) TS_ScoringParameters_set_failure_penalty_msat(uint32_t this_ptr, int64_t val) {
34185         LDKScoringParameters this_ptr_conv;
34186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34187         this_ptr_conv.is_owned = false;
34188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34189         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
34190 }
34191
34192 int64_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_failure_penalty_half_life(uint32_t this_ptr) {
34193         LDKScoringParameters this_ptr_conv;
34194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34195         this_ptr_conv.is_owned = false;
34196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34197         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
34198         return ret_val;
34199 }
34200
34201 void  __attribute__((visibility("default"))) TS_ScoringParameters_set_failure_penalty_half_life(uint32_t this_ptr, int64_t val) {
34202         LDKScoringParameters this_ptr_conv;
34203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34204         this_ptr_conv.is_owned = false;
34205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34206         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
34207 }
34208
34209 uint32_t  __attribute__((visibility("default"))) TS_ScoringParameters_new(int64_t base_penalty_msat_arg, int64_t failure_penalty_msat_arg, int64_t failure_penalty_half_life_arg) {
34210         LDKScoringParameters ret_var = ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, failure_penalty_half_life_arg);
34211         uint64_t ret_ref = 0;
34212         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34213         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34215         ret_ref = (uint64_t)ret_var.inner;
34216         if (ret_var.is_owned) {
34217                 ret_ref |= 1;
34218         }
34219         return ret_ref;
34220 }
34221
34222 int8_tArray  __attribute__((visibility("default"))) TS_ScoringParameters_write(uint32_t obj) {
34223         LDKScoringParameters obj_conv;
34224         obj_conv.inner = (void*)(obj & (~1));
34225         obj_conv.is_owned = false;
34226         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34227         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
34228         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
34229         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
34230         CVec_u8Z_free(ret_var);
34231         return ret_arr;
34232 }
34233
34234 uint32_t  __attribute__((visibility("default"))) TS_ScoringParameters_read(int8_tArray ser) {
34235         LDKu8slice ser_ref;
34236         ser_ref.datalen = *((uint32_t*)ser);
34237         ser_ref.data = (int8_t*)(ser + 4);
34238         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
34239         *ret_conv = ScoringParameters_read(ser_ref);
34240         return (uint64_t)ret_conv;
34241 }
34242
34243 uint32_t  __attribute__((visibility("default"))) TS_Scorer_new(uint32_t params) {
34244         LDKScoringParameters params_conv;
34245         params_conv.inner = (void*)(params & (~1));
34246         params_conv.is_owned = (params & 1) || (params == 0);
34247         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
34248         // Warning: we need a move here but no clone is available for LDKScoringParameters
34249         LDKScorer ret_var = Scorer_new(params_conv);
34250         uint64_t ret_ref = 0;
34251         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34252         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34254         ret_ref = (uint64_t)ret_var.inner;
34255         if (ret_var.is_owned) {
34256                 ret_ref |= 1;
34257         }
34258         return ret_ref;
34259 }
34260
34261 uint32_t  __attribute__((visibility("default"))) TS_Scorer_default() {
34262         LDKScorer ret_var = Scorer_default();
34263         uint64_t ret_ref = 0;
34264         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34265         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34267         ret_ref = (uint64_t)ret_var.inner;
34268         if (ret_var.is_owned) {
34269                 ret_ref |= 1;
34270         }
34271         return ret_ref;
34272 }
34273
34274 uint32_t  __attribute__((visibility("default"))) TS_ScoringParameters_default() {
34275         LDKScoringParameters ret_var = ScoringParameters_default();
34276         uint64_t ret_ref = 0;
34277         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34278         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34280         ret_ref = (uint64_t)ret_var.inner;
34281         if (ret_var.is_owned) {
34282                 ret_ref |= 1;
34283         }
34284         return ret_ref;
34285 }
34286
34287 uint32_t  __attribute__((visibility("default"))) TS_Scorer_as_Score(uint32_t this_arg) {
34288         LDKScorer this_arg_conv;
34289         this_arg_conv.inner = (void*)(this_arg & (~1));
34290         this_arg_conv.is_owned = false;
34291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34292         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
34293         *ret_ret = Scorer_as_Score(&this_arg_conv);
34294         return (uint64_t)ret_ret;
34295 }
34296
34297 int8_tArray  __attribute__((visibility("default"))) TS_Scorer_write(uint32_t obj) {
34298         LDKScorer obj_conv;
34299         obj_conv.inner = (void*)(obj & (~1));
34300         obj_conv.is_owned = false;
34301         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34302         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
34303         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
34304         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
34305         CVec_u8Z_free(ret_var);
34306         return ret_arr;
34307 }
34308
34309 uint32_t  __attribute__((visibility("default"))) TS_Scorer_read(int8_tArray ser) {
34310         LDKu8slice ser_ref;
34311         ser_ref.datalen = *((uint32_t*)ser);
34312         ser_ref.data = (int8_t*)(ser + 4);
34313         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
34314         *ret_conv = Scorer_read(ser_ref);
34315         return (uint64_t)ret_conv;
34316 }
34317
34318 void  __attribute__((visibility("default"))) TS_FilesystemPersister_free(uint32_t this_obj) {
34319         LDKFilesystemPersister this_obj_conv;
34320         this_obj_conv.inner = (void*)(this_obj & (~1));
34321         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34323         FilesystemPersister_free(this_obj_conv);
34324 }
34325
34326 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_new(jstring path_to_channel_data) {
34327         LDKStr path_to_channel_data_conv = str_ref_to_owned_c(path_to_channel_data);
34328         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
34329         uint64_t ret_ref = 0;
34330         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34331         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34333         ret_ref = (uint64_t)ret_var.inner;
34334         if (ret_var.is_owned) {
34335                 ret_ref |= 1;
34336         }
34337         return ret_ref;
34338 }
34339
34340 jstring  __attribute__((visibility("default"))) TS_FilesystemPersister_get_data_dir(uint32_t this_arg) {
34341         LDKFilesystemPersister this_arg_conv;
34342         this_arg_conv.inner = (void*)(this_arg & (~1));
34343         this_arg_conv.is_owned = false;
34344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34345         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
34346         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
34347         Str_free(ret_str);
34348         return ret_conv;
34349 }
34350
34351 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_persist_manager(jstring data_dir, uint32_t manager) {
34352         LDKStr data_dir_conv = str_ref_to_owned_c(data_dir);
34353         LDKChannelManager manager_conv;
34354         manager_conv.inner = (void*)(manager & (~1));
34355         manager_conv.is_owned = false;
34356         CHECK_INNER_FIELD_ACCESS_OR_NULL(manager_conv);
34357         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
34358         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
34359         return (uint64_t)ret_conv;
34360 }
34361
34362 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_read_channelmonitors(uint32_t this_arg, uint32_t keys_manager) {
34363         LDKFilesystemPersister this_arg_conv;
34364         this_arg_conv.inner = (void*)(this_arg & (~1));
34365         this_arg_conv.is_owned = false;
34366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34367         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
34368         CHECK_ACCESS(keys_manager_ptr);
34369         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
34370         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
34371         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
34372         return (uint64_t)ret_conv;
34373 }
34374
34375 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_as_Persist(uint32_t this_arg) {
34376         LDKFilesystemPersister this_arg_conv;
34377         this_arg_conv.inner = (void*)(this_arg & (~1));
34378         this_arg_conv.is_owned = false;
34379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34380         LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
34381         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
34382         return (uint64_t)ret_ret;
34383 }
34384
34385 void  __attribute__((visibility("default"))) TS_BackgroundProcessor_free(uint32_t this_obj) {
34386         LDKBackgroundProcessor this_obj_conv;
34387         this_obj_conv.inner = (void*)(this_obj & (~1));
34388         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34390         BackgroundProcessor_free(this_obj_conv);
34391 }
34392
34393 void  __attribute__((visibility("default"))) TS_ChannelManagerPersister_free(uint32_t this_ptr) {
34394         if ((this_ptr & 1) != 0) return;
34395         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
34396         CHECK_ACCESS(this_ptr_ptr);
34397         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(this_ptr_ptr);
34398         FREE((void*)this_ptr);
34399         ChannelManagerPersister_free(this_ptr_conv);
34400 }
34401
34402 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_start(uint32_t persister, uint32_t event_handler, uint32_t chain_monitor, uint32_t channel_manager, uint32_t net_graph_msg_handler, uint32_t peer_manager, uint32_t logger) {
34403         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
34404         CHECK_ACCESS(persister_ptr);
34405         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(persister_ptr);
34406         void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
34407         CHECK_ACCESS(event_handler_ptr);
34408         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
34409         LDKChainMonitor chain_monitor_conv;
34410         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
34411         chain_monitor_conv.is_owned = false;
34412         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
34413         LDKChannelManager channel_manager_conv;
34414         channel_manager_conv.inner = (void*)(channel_manager & (~1));
34415         channel_manager_conv.is_owned = false;
34416         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
34417         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
34418         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
34419         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
34420         CHECK_INNER_FIELD_ACCESS_OR_NULL(net_graph_msg_handler_conv);
34421         LDKPeerManager peer_manager_conv;
34422         peer_manager_conv.inner = (void*)(peer_manager & (~1));
34423         peer_manager_conv.is_owned = false;
34424         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
34425         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
34426         CHECK_ACCESS(logger_ptr);
34427         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34428         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, net_graph_msg_handler_conv, &peer_manager_conv, logger_conv);
34429         uint64_t ret_ref = 0;
34430         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34431         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34433         ret_ref = (uint64_t)ret_var.inner;
34434         if (ret_var.is_owned) {
34435                 ret_ref |= 1;
34436         }
34437         return ret_ref;
34438 }
34439
34440 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_join(uint32_t this_arg) {
34441         LDKBackgroundProcessor this_arg_conv;
34442         this_arg_conv.inner = (void*)(this_arg & (~1));
34443         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
34444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34445         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
34446         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
34447         *ret_conv = BackgroundProcessor_join(this_arg_conv);
34448         return (uint64_t)ret_conv;
34449 }
34450
34451 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_stop(uint32_t this_arg) {
34452         LDKBackgroundProcessor this_arg_conv;
34453         this_arg_conv.inner = (void*)(this_arg & (~1));
34454         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
34455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34456         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
34457         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
34458         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
34459         return (uint64_t)ret_conv;
34460 }
34461
34462 void  __attribute__((visibility("default"))) TS_check_platform() {
34463         check_platform();
34464 }
34465
34466 void  __attribute__((visibility("default"))) TS_Invoice_free(uint32_t this_obj) {
34467         LDKInvoice this_obj_conv;
34468         this_obj_conv.inner = (void*)(this_obj & (~1));
34469         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34471         Invoice_free(this_obj_conv);
34472 }
34473
34474 jboolean  __attribute__((visibility("default"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
34475         LDKInvoice a_conv;
34476         a_conv.inner = (void*)(a & (~1));
34477         a_conv.is_owned = false;
34478         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34479         LDKInvoice b_conv;
34480         b_conv.inner = (void*)(b & (~1));
34481         b_conv.is_owned = false;
34482         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34483         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
34484         return ret_val;
34485 }
34486
34487 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
34488         LDKInvoice ret_var = Invoice_clone(arg);
34489 uint64_t ret_ref = 0;
34490 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34491 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34492 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34493 ret_ref = (uint64_t)ret_var.inner;
34494 if (ret_var.is_owned) {
34495         ret_ref |= 1;
34496 }
34497         return ret_ref;
34498 }
34499 int64_t  __attribute__((visibility("default"))) TS_Invoice_clone_ptr(uint32_t arg) {
34500         LDKInvoice arg_conv;
34501         arg_conv.inner = (void*)(arg & (~1));
34502         arg_conv.is_owned = false;
34503         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34504         int64_t ret_val = Invoice_clone_ptr(&arg_conv);
34505         return ret_val;
34506 }
34507
34508 uint32_t  __attribute__((visibility("default"))) TS_Invoice_clone(uint32_t orig) {
34509         LDKInvoice orig_conv;
34510         orig_conv.inner = (void*)(orig & (~1));
34511         orig_conv.is_owned = false;
34512         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34513         LDKInvoice ret_var = Invoice_clone(&orig_conv);
34514         uint64_t ret_ref = 0;
34515         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34516         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34517         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34518         ret_ref = (uint64_t)ret_var.inner;
34519         if (ret_var.is_owned) {
34520                 ret_ref |= 1;
34521         }
34522         return ret_ref;
34523 }
34524
34525 void  __attribute__((visibility("default"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
34526         LDKSignedRawInvoice this_obj_conv;
34527         this_obj_conv.inner = (void*)(this_obj & (~1));
34528         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34530         SignedRawInvoice_free(this_obj_conv);
34531 }
34532
34533 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
34534         LDKSignedRawInvoice a_conv;
34535         a_conv.inner = (void*)(a & (~1));
34536         a_conv.is_owned = false;
34537         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34538         LDKSignedRawInvoice b_conv;
34539         b_conv.inner = (void*)(b & (~1));
34540         b_conv.is_owned = false;
34541         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34542         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
34543         return ret_val;
34544 }
34545
34546 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
34547         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
34548 uint64_t ret_ref = 0;
34549 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34550 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34551 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34552 ret_ref = (uint64_t)ret_var.inner;
34553 if (ret_var.is_owned) {
34554         ret_ref |= 1;
34555 }
34556         return ret_ref;
34557 }
34558 int64_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_clone_ptr(uint32_t arg) {
34559         LDKSignedRawInvoice arg_conv;
34560         arg_conv.inner = (void*)(arg & (~1));
34561         arg_conv.is_owned = false;
34562         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34563         int64_t ret_val = SignedRawInvoice_clone_ptr(&arg_conv);
34564         return ret_val;
34565 }
34566
34567 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_clone(uint32_t orig) {
34568         LDKSignedRawInvoice orig_conv;
34569         orig_conv.inner = (void*)(orig & (~1));
34570         orig_conv.is_owned = false;
34571         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34572         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
34573         uint64_t ret_ref = 0;
34574         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34575         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34577         ret_ref = (uint64_t)ret_var.inner;
34578         if (ret_var.is_owned) {
34579                 ret_ref |= 1;
34580         }
34581         return ret_ref;
34582 }
34583
34584 void  __attribute__((visibility("default"))) TS_RawInvoice_free(uint32_t this_obj) {
34585         LDKRawInvoice this_obj_conv;
34586         this_obj_conv.inner = (void*)(this_obj & (~1));
34587         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34589         RawInvoice_free(this_obj_conv);
34590 }
34591
34592 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
34593         LDKRawInvoice this_ptr_conv;
34594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34595         this_ptr_conv.is_owned = false;
34596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34597         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
34598         uint64_t ret_ref = 0;
34599         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34600         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34602         ret_ref = (uint64_t)ret_var.inner;
34603         if (ret_var.is_owned) {
34604                 ret_ref |= 1;
34605         }
34606         return ret_ref;
34607 }
34608
34609 void  __attribute__((visibility("default"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
34610         LDKRawInvoice this_ptr_conv;
34611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34612         this_ptr_conv.is_owned = false;
34613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34614         LDKRawDataPart val_conv;
34615         val_conv.inner = (void*)(val & (~1));
34616         val_conv.is_owned = (val & 1) || (val == 0);
34617         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34618         val_conv = RawDataPart_clone(&val_conv);
34619         RawInvoice_set_data(&this_ptr_conv, val_conv);
34620 }
34621
34622 jboolean  __attribute__((visibility("default"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
34623         LDKRawInvoice a_conv;
34624         a_conv.inner = (void*)(a & (~1));
34625         a_conv.is_owned = false;
34626         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34627         LDKRawInvoice b_conv;
34628         b_conv.inner = (void*)(b & (~1));
34629         b_conv.is_owned = false;
34630         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34631         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
34632         return ret_val;
34633 }
34634
34635 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
34636         LDKRawInvoice ret_var = RawInvoice_clone(arg);
34637 uint64_t ret_ref = 0;
34638 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34639 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34640 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34641 ret_ref = (uint64_t)ret_var.inner;
34642 if (ret_var.is_owned) {
34643         ret_ref |= 1;
34644 }
34645         return ret_ref;
34646 }
34647 int64_t  __attribute__((visibility("default"))) TS_RawInvoice_clone_ptr(uint32_t arg) {
34648         LDKRawInvoice arg_conv;
34649         arg_conv.inner = (void*)(arg & (~1));
34650         arg_conv.is_owned = false;
34651         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34652         int64_t ret_val = RawInvoice_clone_ptr(&arg_conv);
34653         return ret_val;
34654 }
34655
34656 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_clone(uint32_t orig) {
34657         LDKRawInvoice orig_conv;
34658         orig_conv.inner = (void*)(orig & (~1));
34659         orig_conv.is_owned = false;
34660         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34661         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
34662         uint64_t ret_ref = 0;
34663         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34664         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34666         ret_ref = (uint64_t)ret_var.inner;
34667         if (ret_var.is_owned) {
34668                 ret_ref |= 1;
34669         }
34670         return ret_ref;
34671 }
34672
34673 void  __attribute__((visibility("default"))) TS_RawDataPart_free(uint32_t this_obj) {
34674         LDKRawDataPart this_obj_conv;
34675         this_obj_conv.inner = (void*)(this_obj & (~1));
34676         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34678         RawDataPart_free(this_obj_conv);
34679 }
34680
34681 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
34682         LDKRawDataPart this_ptr_conv;
34683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34684         this_ptr_conv.is_owned = false;
34685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34686         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
34687         uint64_t ret_ref = 0;
34688         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34689         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34691         ret_ref = (uint64_t)ret_var.inner;
34692         if (ret_var.is_owned) {
34693                 ret_ref |= 1;
34694         }
34695         return ret_ref;
34696 }
34697
34698 void  __attribute__((visibility("default"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
34699         LDKRawDataPart 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         LDKPositiveTimestamp val_conv;
34704         val_conv.inner = (void*)(val & (~1));
34705         val_conv.is_owned = (val & 1) || (val == 0);
34706         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34707         val_conv = PositiveTimestamp_clone(&val_conv);
34708         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
34709 }
34710
34711 jboolean  __attribute__((visibility("default"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
34712         LDKRawDataPart a_conv;
34713         a_conv.inner = (void*)(a & (~1));
34714         a_conv.is_owned = false;
34715         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34716         LDKRawDataPart b_conv;
34717         b_conv.inner = (void*)(b & (~1));
34718         b_conv.is_owned = false;
34719         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34720         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
34721         return ret_val;
34722 }
34723
34724 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
34725         LDKRawDataPart ret_var = RawDataPart_clone(arg);
34726 uint64_t ret_ref = 0;
34727 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34728 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34729 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34730 ret_ref = (uint64_t)ret_var.inner;
34731 if (ret_var.is_owned) {
34732         ret_ref |= 1;
34733 }
34734         return ret_ref;
34735 }
34736 int64_t  __attribute__((visibility("default"))) TS_RawDataPart_clone_ptr(uint32_t arg) {
34737         LDKRawDataPart arg_conv;
34738         arg_conv.inner = (void*)(arg & (~1));
34739         arg_conv.is_owned = false;
34740         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34741         int64_t ret_val = RawDataPart_clone_ptr(&arg_conv);
34742         return ret_val;
34743 }
34744
34745 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_clone(uint32_t orig) {
34746         LDKRawDataPart orig_conv;
34747         orig_conv.inner = (void*)(orig & (~1));
34748         orig_conv.is_owned = false;
34749         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34750         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
34751         uint64_t ret_ref = 0;
34752         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34753         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34755         ret_ref = (uint64_t)ret_var.inner;
34756         if (ret_var.is_owned) {
34757                 ret_ref |= 1;
34758         }
34759         return ret_ref;
34760 }
34761
34762 void  __attribute__((visibility("default"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
34763         LDKPositiveTimestamp this_obj_conv;
34764         this_obj_conv.inner = (void*)(this_obj & (~1));
34765         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34767         PositiveTimestamp_free(this_obj_conv);
34768 }
34769
34770 jboolean  __attribute__((visibility("default"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
34771         LDKPositiveTimestamp a_conv;
34772         a_conv.inner = (void*)(a & (~1));
34773         a_conv.is_owned = false;
34774         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34775         LDKPositiveTimestamp b_conv;
34776         b_conv.inner = (void*)(b & (~1));
34777         b_conv.is_owned = false;
34778         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34779         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
34780         return ret_val;
34781 }
34782
34783 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
34784         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
34785 uint64_t ret_ref = 0;
34786 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34787 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34788 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34789 ret_ref = (uint64_t)ret_var.inner;
34790 if (ret_var.is_owned) {
34791         ret_ref |= 1;
34792 }
34793         return ret_ref;
34794 }
34795 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_clone_ptr(uint32_t arg) {
34796         LDKPositiveTimestamp arg_conv;
34797         arg_conv.inner = (void*)(arg & (~1));
34798         arg_conv.is_owned = false;
34799         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34800         int64_t ret_val = PositiveTimestamp_clone_ptr(&arg_conv);
34801         return ret_val;
34802 }
34803
34804 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_clone(uint32_t orig) {
34805         LDKPositiveTimestamp orig_conv;
34806         orig_conv.inner = (void*)(orig & (~1));
34807         orig_conv.is_owned = false;
34808         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34809         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
34810         uint64_t ret_ref = 0;
34811         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34812         CHECK((((uint64_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 = (uint64_t)ret_var.inner;
34815         if (ret_var.is_owned) {
34816                 ret_ref |= 1;
34817         }
34818         return ret_ref;
34819 }
34820
34821 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_clone(uint32_t orig) {
34822         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
34823         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
34824         return ret_conv;
34825 }
34826
34827 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_milli() {
34828         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
34829         return ret_conv;
34830 }
34831
34832 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_micro() {
34833         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
34834         return ret_conv;
34835 }
34836
34837 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_nano() {
34838         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
34839         return ret_conv;
34840 }
34841
34842 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_pico() {
34843         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
34844         return ret_conv;
34845 }
34846
34847 jboolean  __attribute__((visibility("default"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
34848         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
34849         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
34850         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
34851         return ret_val;
34852 }
34853
34854 int64_t  __attribute__((visibility("default"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
34855         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
34856         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
34857         return ret_val;
34858 }
34859
34860 uint32_t  __attribute__((visibility("default"))) TS_Currency_clone(uint32_t orig) {
34861         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
34862         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
34863         return ret_conv;
34864 }
34865
34866 uint32_t  __attribute__((visibility("default"))) TS_Currency_bitcoin() {
34867         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
34868         return ret_conv;
34869 }
34870
34871 uint32_t  __attribute__((visibility("default"))) TS_Currency_bitcoin_testnet() {
34872         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
34873         return ret_conv;
34874 }
34875
34876 uint32_t  __attribute__((visibility("default"))) TS_Currency_regtest() {
34877         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
34878         return ret_conv;
34879 }
34880
34881 uint32_t  __attribute__((visibility("default"))) TS_Currency_simnet() {
34882         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
34883         return ret_conv;
34884 }
34885
34886 uint32_t  __attribute__((visibility("default"))) TS_Currency_signet() {
34887         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
34888         return ret_conv;
34889 }
34890
34891 int64_t  __attribute__((visibility("default"))) TS_Currency_hash(uint32_t o) {
34892         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
34893         int64_t ret_val = Currency_hash(o_conv);
34894         return ret_val;
34895 }
34896
34897 jboolean  __attribute__((visibility("default"))) TS_Currency_eq(uint32_t a, uint32_t b) {
34898         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
34899         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
34900         jboolean ret_val = Currency_eq(a_conv, b_conv);
34901         return ret_val;
34902 }
34903
34904 void  __attribute__((visibility("default"))) TS_Sha256_free(uint32_t this_obj) {
34905         LDKSha256 this_obj_conv;
34906         this_obj_conv.inner = (void*)(this_obj & (~1));
34907         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34909         Sha256_free(this_obj_conv);
34910 }
34911
34912 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
34913         LDKSha256 ret_var = Sha256_clone(arg);
34914 uint64_t ret_ref = 0;
34915 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34916 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34917 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34918 ret_ref = (uint64_t)ret_var.inner;
34919 if (ret_var.is_owned) {
34920         ret_ref |= 1;
34921 }
34922         return ret_ref;
34923 }
34924 int64_t  __attribute__((visibility("default"))) TS_Sha256_clone_ptr(uint32_t arg) {
34925         LDKSha256 arg_conv;
34926         arg_conv.inner = (void*)(arg & (~1));
34927         arg_conv.is_owned = false;
34928         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34929         int64_t ret_val = Sha256_clone_ptr(&arg_conv);
34930         return ret_val;
34931 }
34932
34933 uint32_t  __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) {
34934         LDKSha256 orig_conv;
34935         orig_conv.inner = (void*)(orig & (~1));
34936         orig_conv.is_owned = false;
34937         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34938         LDKSha256 ret_var = Sha256_clone(&orig_conv);
34939         uint64_t ret_ref = 0;
34940         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34941         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34943         ret_ref = (uint64_t)ret_var.inner;
34944         if (ret_var.is_owned) {
34945                 ret_ref |= 1;
34946         }
34947         return ret_ref;
34948 }
34949
34950 int64_t  __attribute__((visibility("default"))) TS_Sha256_hash(uint32_t o) {
34951         LDKSha256 o_conv;
34952         o_conv.inner = (void*)(o & (~1));
34953         o_conv.is_owned = false;
34954         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34955         int64_t ret_val = Sha256_hash(&o_conv);
34956         return ret_val;
34957 }
34958
34959 jboolean  __attribute__((visibility("default"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
34960         LDKSha256 a_conv;
34961         a_conv.inner = (void*)(a & (~1));
34962         a_conv.is_owned = false;
34963         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34964         LDKSha256 b_conv;
34965         b_conv.inner = (void*)(b & (~1));
34966         b_conv.is_owned = false;
34967         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34968         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
34969         return ret_val;
34970 }
34971
34972 void  __attribute__((visibility("default"))) TS_Description_free(uint32_t this_obj) {
34973         LDKDescription this_obj_conv;
34974         this_obj_conv.inner = (void*)(this_obj & (~1));
34975         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34977         Description_free(this_obj_conv);
34978 }
34979
34980 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
34981         LDKDescription ret_var = Description_clone(arg);
34982 uint64_t ret_ref = 0;
34983 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34984 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34985 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34986 ret_ref = (uint64_t)ret_var.inner;
34987 if (ret_var.is_owned) {
34988         ret_ref |= 1;
34989 }
34990         return ret_ref;
34991 }
34992 int64_t  __attribute__((visibility("default"))) TS_Description_clone_ptr(uint32_t arg) {
34993         LDKDescription arg_conv;
34994         arg_conv.inner = (void*)(arg & (~1));
34995         arg_conv.is_owned = false;
34996         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34997         int64_t ret_val = Description_clone_ptr(&arg_conv);
34998         return ret_val;
34999 }
35000
35001 uint32_t  __attribute__((visibility("default"))) TS_Description_clone(uint32_t orig) {
35002         LDKDescription orig_conv;
35003         orig_conv.inner = (void*)(orig & (~1));
35004         orig_conv.is_owned = false;
35005         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35006         LDKDescription ret_var = Description_clone(&orig_conv);
35007         uint64_t ret_ref = 0;
35008         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35009         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35011         ret_ref = (uint64_t)ret_var.inner;
35012         if (ret_var.is_owned) {
35013                 ret_ref |= 1;
35014         }
35015         return ret_ref;
35016 }
35017
35018 int64_t  __attribute__((visibility("default"))) TS_Description_hash(uint32_t o) {
35019         LDKDescription o_conv;
35020         o_conv.inner = (void*)(o & (~1));
35021         o_conv.is_owned = false;
35022         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35023         int64_t ret_val = Description_hash(&o_conv);
35024         return ret_val;
35025 }
35026
35027 jboolean  __attribute__((visibility("default"))) TS_Description_eq(uint32_t a, uint32_t b) {
35028         LDKDescription a_conv;
35029         a_conv.inner = (void*)(a & (~1));
35030         a_conv.is_owned = false;
35031         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35032         LDKDescription b_conv;
35033         b_conv.inner = (void*)(b & (~1));
35034         b_conv.is_owned = false;
35035         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35036         jboolean ret_val = Description_eq(&a_conv, &b_conv);
35037         return ret_val;
35038 }
35039
35040 void  __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_obj) {
35041         LDKPayeePubKey this_obj_conv;
35042         this_obj_conv.inner = (void*)(this_obj & (~1));
35043         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35045         PayeePubKey_free(this_obj_conv);
35046 }
35047
35048 int8_tArray  __attribute__((visibility("default"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
35049         LDKPayeePubKey this_ptr_conv;
35050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35051         this_ptr_conv.is_owned = false;
35052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35053         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
35054         memcpy((uint8_t*)(ret_arr + 4), PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
35055         return ret_arr;
35056 }
35057
35058 void  __attribute__((visibility("default"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
35059         LDKPayeePubKey this_ptr_conv;
35060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35061         this_ptr_conv.is_owned = false;
35062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35063         LDKPublicKey val_ref;
35064         CHECK(*((uint32_t*)val) == 33);
35065         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
35066         PayeePubKey_set_a(&this_ptr_conv, val_ref);
35067 }
35068
35069 uint32_t  __attribute__((visibility("default"))) TS_PayeePubKey_new(int8_tArray a_arg) {
35070         LDKPublicKey a_arg_ref;
35071         CHECK(*((uint32_t*)a_arg) == 33);
35072         memcpy(a_arg_ref.compressed_form, (uint8_t*)(a_arg + 4), 33);
35073         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
35074         uint64_t ret_ref = 0;
35075         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35076         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35078         ret_ref = (uint64_t)ret_var.inner;
35079         if (ret_var.is_owned) {
35080                 ret_ref |= 1;
35081         }
35082         return ret_ref;
35083 }
35084
35085 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
35086         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
35087 uint64_t ret_ref = 0;
35088 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35089 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35090 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35091 ret_ref = (uint64_t)ret_var.inner;
35092 if (ret_var.is_owned) {
35093         ret_ref |= 1;
35094 }
35095         return ret_ref;
35096 }
35097 int64_t  __attribute__((visibility("default"))) TS_PayeePubKey_clone_ptr(uint32_t arg) {
35098         LDKPayeePubKey arg_conv;
35099         arg_conv.inner = (void*)(arg & (~1));
35100         arg_conv.is_owned = false;
35101         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35102         int64_t ret_val = PayeePubKey_clone_ptr(&arg_conv);
35103         return ret_val;
35104 }
35105
35106 uint32_t  __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t orig) {
35107         LDKPayeePubKey orig_conv;
35108         orig_conv.inner = (void*)(orig & (~1));
35109         orig_conv.is_owned = false;
35110         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35111         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
35112         uint64_t ret_ref = 0;
35113         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35114         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35116         ret_ref = (uint64_t)ret_var.inner;
35117         if (ret_var.is_owned) {
35118                 ret_ref |= 1;
35119         }
35120         return ret_ref;
35121 }
35122
35123 int64_t  __attribute__((visibility("default"))) TS_PayeePubKey_hash(uint32_t o) {
35124         LDKPayeePubKey o_conv;
35125         o_conv.inner = (void*)(o & (~1));
35126         o_conv.is_owned = false;
35127         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35128         int64_t ret_val = PayeePubKey_hash(&o_conv);
35129         return ret_val;
35130 }
35131
35132 jboolean  __attribute__((visibility("default"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
35133         LDKPayeePubKey a_conv;
35134         a_conv.inner = (void*)(a & (~1));
35135         a_conv.is_owned = false;
35136         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35137         LDKPayeePubKey b_conv;
35138         b_conv.inner = (void*)(b & (~1));
35139         b_conv.is_owned = false;
35140         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35141         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
35142         return ret_val;
35143 }
35144
35145 void  __attribute__((visibility("default"))) TS_ExpiryTime_free(uint32_t this_obj) {
35146         LDKExpiryTime this_obj_conv;
35147         this_obj_conv.inner = (void*)(this_obj & (~1));
35148         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35150         ExpiryTime_free(this_obj_conv);
35151 }
35152
35153 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
35154         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
35155 uint64_t ret_ref = 0;
35156 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35157 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35158 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35159 ret_ref = (uint64_t)ret_var.inner;
35160 if (ret_var.is_owned) {
35161         ret_ref |= 1;
35162 }
35163         return ret_ref;
35164 }
35165 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_clone_ptr(uint32_t arg) {
35166         LDKExpiryTime arg_conv;
35167         arg_conv.inner = (void*)(arg & (~1));
35168         arg_conv.is_owned = false;
35169         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35170         int64_t ret_val = ExpiryTime_clone_ptr(&arg_conv);
35171         return ret_val;
35172 }
35173
35174 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t orig) {
35175         LDKExpiryTime orig_conv;
35176         orig_conv.inner = (void*)(orig & (~1));
35177         orig_conv.is_owned = false;
35178         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35179         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
35180         uint64_t ret_ref = 0;
35181         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35182         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35184         ret_ref = (uint64_t)ret_var.inner;
35185         if (ret_var.is_owned) {
35186                 ret_ref |= 1;
35187         }
35188         return ret_ref;
35189 }
35190
35191 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_hash(uint32_t o) {
35192         LDKExpiryTime o_conv;
35193         o_conv.inner = (void*)(o & (~1));
35194         o_conv.is_owned = false;
35195         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35196         int64_t ret_val = ExpiryTime_hash(&o_conv);
35197         return ret_val;
35198 }
35199
35200 jboolean  __attribute__((visibility("default"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
35201         LDKExpiryTime a_conv;
35202         a_conv.inner = (void*)(a & (~1));
35203         a_conv.is_owned = false;
35204         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35205         LDKExpiryTime b_conv;
35206         b_conv.inner = (void*)(b & (~1));
35207         b_conv.is_owned = false;
35208         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35209         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
35210         return ret_val;
35211 }
35212
35213 void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
35214         LDKMinFinalCltvExpiry this_obj_conv;
35215         this_obj_conv.inner = (void*)(this_obj & (~1));
35216         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35218         MinFinalCltvExpiry_free(this_obj_conv);
35219 }
35220
35221 int64_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
35222         LDKMinFinalCltvExpiry this_ptr_conv;
35223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35224         this_ptr_conv.is_owned = false;
35225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35226         int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
35227         return ret_val;
35228 }
35229
35230 void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
35231         LDKMinFinalCltvExpiry this_ptr_conv;
35232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35233         this_ptr_conv.is_owned = false;
35234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35235         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
35236 }
35237
35238 uint32_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
35239         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
35240         uint64_t ret_ref = 0;
35241         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35242         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35244         ret_ref = (uint64_t)ret_var.inner;
35245         if (ret_var.is_owned) {
35246                 ret_ref |= 1;
35247         }
35248         return ret_ref;
35249 }
35250
35251 static inline uint64_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
35252         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
35253 uint64_t ret_ref = 0;
35254 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35255 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35256 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35257 ret_ref = (uint64_t)ret_var.inner;
35258 if (ret_var.is_owned) {
35259         ret_ref |= 1;
35260 }
35261         return ret_ref;
35262 }
35263 int64_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone_ptr(uint32_t arg) {
35264         LDKMinFinalCltvExpiry arg_conv;
35265         arg_conv.inner = (void*)(arg & (~1));
35266         arg_conv.is_owned = false;
35267         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35268         int64_t ret_val = MinFinalCltvExpiry_clone_ptr(&arg_conv);
35269         return ret_val;
35270 }
35271
35272 uint32_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
35273         LDKMinFinalCltvExpiry orig_conv;
35274         orig_conv.inner = (void*)(orig & (~1));
35275         orig_conv.is_owned = false;
35276         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35277         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
35278         uint64_t ret_ref = 0;
35279         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35280         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35282         ret_ref = (uint64_t)ret_var.inner;
35283         if (ret_var.is_owned) {
35284                 ret_ref |= 1;
35285         }
35286         return ret_ref;
35287 }
35288
35289 int64_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
35290         LDKMinFinalCltvExpiry o_conv;
35291         o_conv.inner = (void*)(o & (~1));
35292         o_conv.is_owned = false;
35293         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35294         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
35295         return ret_val;
35296 }
35297
35298 jboolean  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
35299         LDKMinFinalCltvExpiry a_conv;
35300         a_conv.inner = (void*)(a & (~1));
35301         a_conv.is_owned = false;
35302         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35303         LDKMinFinalCltvExpiry b_conv;
35304         b_conv.inner = (void*)(b & (~1));
35305         b_conv.is_owned = false;
35306         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35307         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
35308         return ret_val;
35309 }
35310
35311 void  __attribute__((visibility("default"))) TS_Fallback_free(uint32_t this_ptr) {
35312         if ((this_ptr & 1) != 0) return;
35313         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
35314         CHECK_ACCESS(this_ptr_ptr);
35315         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
35316         FREE((void*)this_ptr);
35317         Fallback_free(this_ptr_conv);
35318 }
35319
35320 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
35321         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
35322         *ret_copy = Fallback_clone(arg);
35323 uint64_t ret_ref = (uint64_t)ret_copy;
35324         return ret_ref;
35325 }
35326 int64_t  __attribute__((visibility("default"))) TS_Fallback_clone_ptr(uint32_t arg) {
35327         LDKFallback* arg_conv = (LDKFallback*)arg;
35328         int64_t ret_val = Fallback_clone_ptr(arg_conv);
35329         return ret_val;
35330 }
35331
35332 uint32_t  __attribute__((visibility("default"))) TS_Fallback_clone(uint32_t orig) {
35333         LDKFallback* orig_conv = (LDKFallback*)orig;
35334         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
35335         *ret_copy = Fallback_clone(orig_conv);
35336         uint64_t ret_ref = (uint64_t)ret_copy;
35337         return ret_ref;
35338 }
35339
35340 uint32_t  __attribute__((visibility("default"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
35341         
35342         LDKCVec_u8Z program_ref;
35343         program_ref.datalen = *((uint32_t*)program);
35344         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
35345         memcpy(program_ref.data, (uint8_t*)(program + 4), program_ref.datalen);
35346         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
35347         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
35348         uint64_t ret_ref = (uint64_t)ret_copy;
35349         return ret_ref;
35350 }
35351
35352 uint32_t  __attribute__((visibility("default"))) TS_Fallback_pub_key_hash(int8_tArray a) {
35353         LDKTwentyBytes a_ref;
35354         CHECK(*((uint32_t*)a) == 20);
35355         memcpy(a_ref.data, (uint8_t*)(a + 4), 20);
35356         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
35357         *ret_copy = Fallback_pub_key_hash(a_ref);
35358         uint64_t ret_ref = (uint64_t)ret_copy;
35359         return ret_ref;
35360 }
35361
35362 uint32_t  __attribute__((visibility("default"))) TS_Fallback_script_hash(int8_tArray a) {
35363         LDKTwentyBytes a_ref;
35364         CHECK(*((uint32_t*)a) == 20);
35365         memcpy(a_ref.data, (uint8_t*)(a + 4), 20);
35366         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
35367         *ret_copy = Fallback_script_hash(a_ref);
35368         uint64_t ret_ref = (uint64_t)ret_copy;
35369         return ret_ref;
35370 }
35371
35372 int64_t  __attribute__((visibility("default"))) TS_Fallback_hash(uint32_t o) {
35373         LDKFallback* o_conv = (LDKFallback*)o;
35374         int64_t ret_val = Fallback_hash(o_conv);
35375         return ret_val;
35376 }
35377
35378 jboolean  __attribute__((visibility("default"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
35379         LDKFallback* a_conv = (LDKFallback*)a;
35380         LDKFallback* b_conv = (LDKFallback*)b;
35381         jboolean ret_val = Fallback_eq(a_conv, b_conv);
35382         return ret_val;
35383 }
35384
35385 void  __attribute__((visibility("default"))) TS_InvoiceSignature_free(uint32_t this_obj) {
35386         LDKInvoiceSignature this_obj_conv;
35387         this_obj_conv.inner = (void*)(this_obj & (~1));
35388         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35390         InvoiceSignature_free(this_obj_conv);
35391 }
35392
35393 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
35394         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
35395 uint64_t ret_ref = 0;
35396 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35397 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35398 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35399 ret_ref = (uint64_t)ret_var.inner;
35400 if (ret_var.is_owned) {
35401         ret_ref |= 1;
35402 }
35403         return ret_ref;
35404 }
35405 int64_t  __attribute__((visibility("default"))) TS_InvoiceSignature_clone_ptr(uint32_t arg) {
35406         LDKInvoiceSignature arg_conv;
35407         arg_conv.inner = (void*)(arg & (~1));
35408         arg_conv.is_owned = false;
35409         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35410         int64_t ret_val = InvoiceSignature_clone_ptr(&arg_conv);
35411         return ret_val;
35412 }
35413
35414 uint32_t  __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint32_t orig) {
35415         LDKInvoiceSignature orig_conv;
35416         orig_conv.inner = (void*)(orig & (~1));
35417         orig_conv.is_owned = false;
35418         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35419         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
35420         uint64_t ret_ref = 0;
35421         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35422         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35424         ret_ref = (uint64_t)ret_var.inner;
35425         if (ret_var.is_owned) {
35426                 ret_ref |= 1;
35427         }
35428         return ret_ref;
35429 }
35430
35431 jboolean  __attribute__((visibility("default"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
35432         LDKInvoiceSignature a_conv;
35433         a_conv.inner = (void*)(a & (~1));
35434         a_conv.is_owned = false;
35435         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35436         LDKInvoiceSignature b_conv;
35437         b_conv.inner = (void*)(b & (~1));
35438         b_conv.is_owned = false;
35439         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35440         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
35441         return ret_val;
35442 }
35443
35444 void  __attribute__((visibility("default"))) TS_PrivateRoute_free(uint32_t this_obj) {
35445         LDKPrivateRoute this_obj_conv;
35446         this_obj_conv.inner = (void*)(this_obj & (~1));
35447         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35449         PrivateRoute_free(this_obj_conv);
35450 }
35451
35452 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
35453         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
35454 uint64_t ret_ref = 0;
35455 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35456 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35457 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35458 ret_ref = (uint64_t)ret_var.inner;
35459 if (ret_var.is_owned) {
35460         ret_ref |= 1;
35461 }
35462         return ret_ref;
35463 }
35464 int64_t  __attribute__((visibility("default"))) TS_PrivateRoute_clone_ptr(uint32_t arg) {
35465         LDKPrivateRoute arg_conv;
35466         arg_conv.inner = (void*)(arg & (~1));
35467         arg_conv.is_owned = false;
35468         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35469         int64_t ret_val = PrivateRoute_clone_ptr(&arg_conv);
35470         return ret_val;
35471 }
35472
35473 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t orig) {
35474         LDKPrivateRoute orig_conv;
35475         orig_conv.inner = (void*)(orig & (~1));
35476         orig_conv.is_owned = false;
35477         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35478         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
35479         uint64_t ret_ref = 0;
35480         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35481         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35483         ret_ref = (uint64_t)ret_var.inner;
35484         if (ret_var.is_owned) {
35485                 ret_ref |= 1;
35486         }
35487         return ret_ref;
35488 }
35489
35490 int64_t  __attribute__((visibility("default"))) TS_PrivateRoute_hash(uint32_t o) {
35491         LDKPrivateRoute o_conv;
35492         o_conv.inner = (void*)(o & (~1));
35493         o_conv.is_owned = false;
35494         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35495         int64_t ret_val = PrivateRoute_hash(&o_conv);
35496         return ret_val;
35497 }
35498
35499 jboolean  __attribute__((visibility("default"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
35500         LDKPrivateRoute a_conv;
35501         a_conv.inner = (void*)(a & (~1));
35502         a_conv.is_owned = false;
35503         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35504         LDKPrivateRoute b_conv;
35505         b_conv.inner = (void*)(b & (~1));
35506         b_conv.is_owned = false;
35507         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35508         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
35509         return ret_val;
35510 }
35511
35512 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
35513         LDKSignedRawInvoice this_arg_conv;
35514         this_arg_conv.inner = (void*)(this_arg & (~1));
35515         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
35516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35517         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
35518         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
35519         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
35520         return ((uint64_t)ret_conv);
35521 }
35522
35523 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
35524         LDKSignedRawInvoice this_arg_conv;
35525         this_arg_conv.inner = (void*)(this_arg & (~1));
35526         this_arg_conv.is_owned = false;
35527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35528         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
35529         uint64_t ret_ref = 0;
35530         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35531         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35533         ret_ref = (uint64_t)ret_var.inner;
35534         if (ret_var.is_owned) {
35535                 ret_ref |= 1;
35536         }
35537         return ret_ref;
35538 }
35539
35540 int8_tArray  __attribute__((visibility("default"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
35541         LDKSignedRawInvoice this_arg_conv;
35542         this_arg_conv.inner = (void*)(this_arg & (~1));
35543         this_arg_conv.is_owned = false;
35544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35545         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
35546         memcpy((uint8_t*)(ret_arr + 4), *SignedRawInvoice_hash(&this_arg_conv), 32);
35547         return ret_arr;
35548 }
35549
35550 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
35551         LDKSignedRawInvoice this_arg_conv;
35552         this_arg_conv.inner = (void*)(this_arg & (~1));
35553         this_arg_conv.is_owned = false;
35554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35555         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
35556         uint64_t ret_ref = 0;
35557         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35558         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35560         ret_ref = (uint64_t)ret_var.inner;
35561         if (ret_var.is_owned) {
35562                 ret_ref |= 1;
35563         }
35564         return ret_ref;
35565 }
35566
35567 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
35568         LDKSignedRawInvoice this_arg_conv;
35569         this_arg_conv.inner = (void*)(this_arg & (~1));
35570         this_arg_conv.is_owned = false;
35571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35572         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
35573         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
35574         return (uint64_t)ret_conv;
35575 }
35576
35577 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
35578         LDKSignedRawInvoice this_arg_conv;
35579         this_arg_conv.inner = (void*)(this_arg & (~1));
35580         this_arg_conv.is_owned = false;
35581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35582         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
35583         return ret_val;
35584 }
35585
35586 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_hash(uint32_t this_arg) {
35587         LDKRawInvoice this_arg_conv;
35588         this_arg_conv.inner = (void*)(this_arg & (~1));
35589         this_arg_conv.is_owned = false;
35590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35591         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
35592         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_hash(&this_arg_conv).data, 32);
35593         return ret_arr;
35594 }
35595
35596 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
35597         LDKRawInvoice this_arg_conv;
35598         this_arg_conv.inner = (void*)(this_arg & (~1));
35599         this_arg_conv.is_owned = false;
35600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35601         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
35602         uint64_t ret_ref = 0;
35603         if ((uint64_t)ret_var.inner > 4096) {
35604                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35605                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35607                 ret_ref = (uint64_t)ret_var.inner;
35608                 if (ret_var.is_owned) {
35609                         ret_ref |= 1;
35610                 }
35611         }
35612         return ret_ref;
35613 }
35614
35615 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description(uint32_t this_arg) {
35616         LDKRawInvoice this_arg_conv;
35617         this_arg_conv.inner = (void*)(this_arg & (~1));
35618         this_arg_conv.is_owned = false;
35619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35620         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
35621         uint64_t ret_ref = 0;
35622         if ((uint64_t)ret_var.inner > 4096) {
35623                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35624                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35626                 ret_ref = (uint64_t)ret_var.inner;
35627                 if (ret_var.is_owned) {
35628                         ret_ref |= 1;
35629                 }
35630         }
35631         return ret_ref;
35632 }
35633
35634 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
35635         LDKRawInvoice this_arg_conv;
35636         this_arg_conv.inner = (void*)(this_arg & (~1));
35637         this_arg_conv.is_owned = false;
35638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35639         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
35640         uint64_t ret_ref = 0;
35641         if ((uint64_t)ret_var.inner > 4096) {
35642                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35643                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35645                 ret_ref = (uint64_t)ret_var.inner;
35646                 if (ret_var.is_owned) {
35647                         ret_ref |= 1;
35648                 }
35649         }
35650         return ret_ref;
35651 }
35652
35653 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
35654         LDKRawInvoice this_arg_conv;
35655         this_arg_conv.inner = (void*)(this_arg & (~1));
35656         this_arg_conv.is_owned = false;
35657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35658         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
35659         uint64_t ret_ref = 0;
35660         if ((uint64_t)ret_var.inner > 4096) {
35661                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35662                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35664                 ret_ref = (uint64_t)ret_var.inner;
35665                 if (ret_var.is_owned) {
35666                         ret_ref |= 1;
35667                 }
35668         }
35669         return ret_ref;
35670 }
35671
35672 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
35673         LDKRawInvoice this_arg_conv;
35674         this_arg_conv.inner = (void*)(this_arg & (~1));
35675         this_arg_conv.is_owned = false;
35676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35677         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
35678         uint64_t ret_ref = 0;
35679         if ((uint64_t)ret_var.inner > 4096) {
35680                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35681                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35683                 ret_ref = (uint64_t)ret_var.inner;
35684                 if (ret_var.is_owned) {
35685                         ret_ref |= 1;
35686                 }
35687         }
35688         return ret_ref;
35689 }
35690
35691 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
35692         LDKRawInvoice this_arg_conv;
35693         this_arg_conv.inner = (void*)(this_arg & (~1));
35694         this_arg_conv.is_owned = false;
35695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35696         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
35697         uint64_t ret_ref = 0;
35698         if ((uint64_t)ret_var.inner > 4096) {
35699                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35700                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35702                 ret_ref = (uint64_t)ret_var.inner;
35703                 if (ret_var.is_owned) {
35704                         ret_ref |= 1;
35705                 }
35706         }
35707         return ret_ref;
35708 }
35709
35710 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
35711         LDKRawInvoice this_arg_conv;
35712         this_arg_conv.inner = (void*)(this_arg & (~1));
35713         this_arg_conv.is_owned = false;
35714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35715         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
35716         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_payment_secret(&this_arg_conv).data, 32);
35717         return ret_arr;
35718 }
35719
35720 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_features(uint32_t this_arg) {
35721         LDKRawInvoice this_arg_conv;
35722         this_arg_conv.inner = (void*)(this_arg & (~1));
35723         this_arg_conv.is_owned = false;
35724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35725         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
35726         uint64_t ret_ref = 0;
35727         if ((uint64_t)ret_var.inner > 4096) {
35728                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35729                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35731                 ret_ref = (uint64_t)ret_var.inner;
35732                 if (ret_var.is_owned) {
35733                         ret_ref |= 1;
35734                 }
35735         }
35736         return ret_ref;
35737 }
35738
35739 uint32_tArray  __attribute__((visibility("default"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
35740         LDKRawInvoice this_arg_conv;
35741         this_arg_conv.inner = (void*)(this_arg & (~1));
35742         this_arg_conv.is_owned = false;
35743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35744         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
35745         uint32_tArray ret_arr = NULL;
35746         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
35747         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
35748         for (size_t o = 0; o < ret_var.datalen; o++) {
35749                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
35750                 uint64_t ret_conv_14_ref = 0;
35751                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35752                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35753                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
35754                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
35755                 if (ret_conv_14_var.is_owned) {
35756                         ret_conv_14_ref |= 1;
35757                 }
35758                 ret_arr_ptr[o] = ret_conv_14_ref;
35759         }
35760         
35761         FREE(ret_var.data);
35762         return ret_arr;
35763 }
35764
35765 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
35766         LDKRawInvoice this_arg_conv;
35767         this_arg_conv.inner = (void*)(this_arg & (~1));
35768         this_arg_conv.is_owned = false;
35769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35770         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35771         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
35772         uint64_t ret_ref = (uint64_t)ret_copy;
35773         return ret_ref;
35774 }
35775
35776 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_currency(uint32_t this_arg) {
35777         LDKRawInvoice this_arg_conv;
35778         this_arg_conv.inner = (void*)(this_arg & (~1));
35779         this_arg_conv.is_owned = false;
35780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35781         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
35782         return ret_conv;
35783 }
35784
35785 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
35786         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
35787         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
35788         return (uint64_t)ret_conv;
35789 }
35790
35791 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_system_time(int64_t time) {
35792         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
35793         *ret_conv = PositiveTimestamp_from_system_time(time);
35794         return (uint64_t)ret_conv;
35795 }
35796
35797 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
35798         LDKPositiveTimestamp this_arg_conv;
35799         this_arg_conv.inner = (void*)(this_arg & (~1));
35800         this_arg_conv.is_owned = false;
35801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35802         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
35803         return ret_val;
35804 }
35805
35806 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_time(uint32_t this_arg) {
35807         LDKPositiveTimestamp this_arg_conv;
35808         this_arg_conv.inner = (void*)(this_arg & (~1));
35809         this_arg_conv.is_owned = false;
35810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35811         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
35812         return ret_val;
35813 }
35814
35815 uint32_t  __attribute__((visibility("default"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
35816         LDKInvoice this_arg_conv;
35817         this_arg_conv.inner = (void*)(this_arg & (~1));
35818         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
35819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35820         this_arg_conv = Invoice_clone(&this_arg_conv);
35821         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
35822         uint64_t ret_ref = 0;
35823         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35824         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35826         ret_ref = (uint64_t)ret_var.inner;
35827         if (ret_var.is_owned) {
35828                 ret_ref |= 1;
35829         }
35830         return ret_ref;
35831 }
35832
35833 uint32_t  __attribute__((visibility("default"))) TS_Invoice_check_signature(uint32_t this_arg) {
35834         LDKInvoice this_arg_conv;
35835         this_arg_conv.inner = (void*)(this_arg & (~1));
35836         this_arg_conv.is_owned = false;
35837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35838         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
35839         *ret_conv = Invoice_check_signature(&this_arg_conv);
35840         return (uint64_t)ret_conv;
35841 }
35842
35843 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
35844         LDKSignedRawInvoice signed_invoice_conv;
35845         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
35846         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
35847         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
35848         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
35849         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
35850         *ret_conv = Invoice_from_signed(signed_invoice_conv);
35851         return (uint64_t)ret_conv;
35852 }
35853
35854 int64_t  __attribute__((visibility("default"))) TS_Invoice_timestamp(uint32_t this_arg) {
35855         LDKInvoice this_arg_conv;
35856         this_arg_conv.inner = (void*)(this_arg & (~1));
35857         this_arg_conv.is_owned = false;
35858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35859         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
35860         return ret_val;
35861 }
35862
35863 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_hash(uint32_t this_arg) {
35864         LDKInvoice this_arg_conv;
35865         this_arg_conv.inner = (void*)(this_arg & (~1));
35866         this_arg_conv.is_owned = false;
35867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35868         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
35869         memcpy((uint8_t*)(ret_arr + 4), *Invoice_payment_hash(&this_arg_conv), 32);
35870         return ret_arr;
35871 }
35872
35873 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
35874         LDKInvoice this_arg_conv;
35875         this_arg_conv.inner = (void*)(this_arg & (~1));
35876         this_arg_conv.is_owned = false;
35877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35878         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
35879         memcpy((uint8_t*)(ret_arr + 4), Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
35880         return ret_arr;
35881 }
35882
35883 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_secret(uint32_t this_arg) {
35884         LDKInvoice this_arg_conv;
35885         this_arg_conv.inner = (void*)(this_arg & (~1));
35886         this_arg_conv.is_owned = false;
35887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35888         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
35889         memcpy((uint8_t*)(ret_arr + 4), *Invoice_payment_secret(&this_arg_conv), 32);
35890         return ret_arr;
35891 }
35892
35893 uint32_t  __attribute__((visibility("default"))) TS_Invoice_features(uint32_t this_arg) {
35894         LDKInvoice this_arg_conv;
35895         this_arg_conv.inner = (void*)(this_arg & (~1));
35896         this_arg_conv.is_owned = false;
35897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35898         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
35899         uint64_t ret_ref = 0;
35900         if ((uint64_t)ret_var.inner > 4096) {
35901                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35902                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35904                 ret_ref = (uint64_t)ret_var.inner;
35905                 if (ret_var.is_owned) {
35906                         ret_ref |= 1;
35907                 }
35908         }
35909         return ret_ref;
35910 }
35911
35912 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
35913         LDKInvoice this_arg_conv;
35914         this_arg_conv.inner = (void*)(this_arg & (~1));
35915         this_arg_conv.is_owned = false;
35916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35917         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
35918         memcpy((uint8_t*)(ret_arr + 4), Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
35919         return ret_arr;
35920 }
35921
35922 int64_t  __attribute__((visibility("default"))) TS_Invoice_expiry_time(uint32_t this_arg) {
35923         LDKInvoice this_arg_conv;
35924         this_arg_conv.inner = (void*)(this_arg & (~1));
35925         this_arg_conv.is_owned = false;
35926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35927         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
35928         return ret_val;
35929 }
35930
35931 jboolean  __attribute__((visibility("default"))) TS_Invoice_is_expired(uint32_t this_arg) {
35932         LDKInvoice this_arg_conv;
35933         this_arg_conv.inner = (void*)(this_arg & (~1));
35934         this_arg_conv.is_owned = false;
35935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35936         jboolean ret_val = Invoice_is_expired(&this_arg_conv);
35937         return ret_val;
35938 }
35939
35940 int64_t  __attribute__((visibility("default"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
35941         LDKInvoice this_arg_conv;
35942         this_arg_conv.inner = (void*)(this_arg & (~1));
35943         this_arg_conv.is_owned = false;
35944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35945         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
35946         return ret_val;
35947 }
35948
35949 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_private_routes(uint32_t this_arg) {
35950         LDKInvoice this_arg_conv;
35951         this_arg_conv.inner = (void*)(this_arg & (~1));
35952         this_arg_conv.is_owned = false;
35953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35954         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
35955         uint32_tArray ret_arr = NULL;
35956         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
35957         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
35958         for (size_t o = 0; o < ret_var.datalen; o++) {
35959                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
35960                 uint64_t ret_conv_14_ref = 0;
35961                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35962                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35963                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
35964                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
35965                 if (ret_conv_14_var.is_owned) {
35966                         ret_conv_14_ref |= 1;
35967                 }
35968                 ret_arr_ptr[o] = ret_conv_14_ref;
35969         }
35970         
35971         FREE(ret_var.data);
35972         return ret_arr;
35973 }
35974
35975 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_route_hints(uint32_t this_arg) {
35976         LDKInvoice this_arg_conv;
35977         this_arg_conv.inner = (void*)(this_arg & (~1));
35978         this_arg_conv.is_owned = false;
35979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35980         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
35981         uint32_tArray ret_arr = NULL;
35982         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
35983         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
35984         for (size_t l = 0; l < ret_var.datalen; l++) {
35985                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
35986                 uint64_t ret_conv_11_ref = 0;
35987                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35988                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35989                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
35990                 ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
35991                 if (ret_conv_11_var.is_owned) {
35992                         ret_conv_11_ref |= 1;
35993                 }
35994                 ret_arr_ptr[l] = ret_conv_11_ref;
35995         }
35996         
35997         FREE(ret_var.data);
35998         return ret_arr;
35999 }
36000
36001 uint32_t  __attribute__((visibility("default"))) TS_Invoice_currency(uint32_t this_arg) {
36002         LDKInvoice this_arg_conv;
36003         this_arg_conv.inner = (void*)(this_arg & (~1));
36004         this_arg_conv.is_owned = false;
36005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36006         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
36007         return ret_conv;
36008 }
36009
36010 uint32_t  __attribute__((visibility("default"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
36011         LDKInvoice this_arg_conv;
36012         this_arg_conv.inner = (void*)(this_arg & (~1));
36013         this_arg_conv.is_owned = false;
36014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36015         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36016         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
36017         uint64_t ret_ref = (uint64_t)ret_copy;
36018         return ret_ref;
36019 }
36020
36021 uint32_t  __attribute__((visibility("default"))) TS_Description_new(jstring description) {
36022         LDKStr description_conv = str_ref_to_owned_c(description);
36023         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
36024         *ret_conv = Description_new(description_conv);
36025         return (uint64_t)ret_conv;
36026 }
36027
36028 jstring  __attribute__((visibility("default"))) TS_Description_into_inner(uint32_t this_arg) {
36029         LDKDescription this_arg_conv;
36030         this_arg_conv.inner = (void*)(this_arg & (~1));
36031         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
36032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36033         this_arg_conv = Description_clone(&this_arg_conv);
36034         LDKStr ret_str = Description_into_inner(this_arg_conv);
36035         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
36036         Str_free(ret_str);
36037         return ret_conv;
36038 }
36039
36040 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
36041         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
36042         *ret_conv = ExpiryTime_from_seconds(seconds);
36043         return (uint64_t)ret_conv;
36044 }
36045
36046 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_duration(int64_t duration) {
36047         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
36048         *ret_conv = ExpiryTime_from_duration(duration);
36049         return (uint64_t)ret_conv;
36050 }
36051
36052 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
36053         LDKExpiryTime this_arg_conv;
36054         this_arg_conv.inner = (void*)(this_arg & (~1));
36055         this_arg_conv.is_owned = false;
36056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36057         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
36058         return ret_val;
36059 }
36060
36061 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
36062         LDKExpiryTime this_arg_conv;
36063         this_arg_conv.inner = (void*)(this_arg & (~1));
36064         this_arg_conv.is_owned = false;
36065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36066         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
36067         return ret_val;
36068 }
36069
36070 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_new(uint32_t hops) {
36071         LDKRouteHint hops_conv;
36072         hops_conv.inner = (void*)(hops & (~1));
36073         hops_conv.is_owned = (hops & 1) || (hops == 0);
36074         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
36075         hops_conv = RouteHint_clone(&hops_conv);
36076         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
36077         *ret_conv = PrivateRoute_new(hops_conv);
36078         return (uint64_t)ret_conv;
36079 }
36080
36081 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
36082         LDKPrivateRoute this_arg_conv;
36083         this_arg_conv.inner = (void*)(this_arg & (~1));
36084         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
36085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36086         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
36087         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
36088         uint64_t ret_ref = 0;
36089         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36090         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36092         ret_ref = (uint64_t)ret_var.inner;
36093         if (ret_var.is_owned) {
36094                 ret_ref |= 1;
36095         }
36096         return ret_ref;
36097 }
36098
36099 uint32_t  __attribute__((visibility("default"))) TS_CreationError_clone(uint32_t orig) {
36100         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
36101         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
36102         return ret_conv;
36103 }
36104
36105 uint32_t  __attribute__((visibility("default"))) TS_CreationError_description_too_long() {
36106         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
36107         return ret_conv;
36108 }
36109
36110 uint32_t  __attribute__((visibility("default"))) TS_CreationError_route_too_long() {
36111         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
36112         return ret_conv;
36113 }
36114
36115 uint32_t  __attribute__((visibility("default"))) TS_CreationError_timestamp_out_of_bounds() {
36116         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
36117         return ret_conv;
36118 }
36119
36120 uint32_t  __attribute__((visibility("default"))) TS_CreationError_expiry_time_out_of_bounds() {
36121         uint32_t ret_conv = LDKCreationError_to_js(CreationError_expiry_time_out_of_bounds());
36122         return ret_conv;
36123 }
36124
36125 jboolean  __attribute__((visibility("default"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
36126         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
36127         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
36128         jboolean ret_val = CreationError_eq(a_conv, b_conv);
36129         return ret_val;
36130 }
36131
36132 jstring  __attribute__((visibility("default"))) TS_CreationError_to_str(uint32_t o) {
36133         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
36134         LDKStr ret_str = CreationError_to_str(o_conv);
36135         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
36136         Str_free(ret_str);
36137         return ret_conv;
36138 }
36139
36140 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_clone(uint32_t orig) {
36141         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
36142         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
36143         return ret_conv;
36144 }
36145
36146 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_payment_hash() {
36147         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
36148         return ret_conv;
36149 }
36150
36151 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_hashes() {
36152         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
36153         return ret_conv;
36154 }
36155
36156 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_description() {
36157         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
36158         return ret_conv;
36159 }
36160
36161 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_descriptions() {
36162         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
36163         return ret_conv;
36164 }
36165
36166 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_payment_secret() {
36167         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
36168         return ret_conv;
36169 }
36170
36171 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_secrets() {
36172         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
36173         return ret_conv;
36174 }
36175
36176 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_features() {
36177         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
36178         return ret_conv;
36179 }
36180
36181 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_recovery_id() {
36182         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
36183         return ret_conv;
36184 }
36185
36186 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_signature() {
36187         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
36188         return ret_conv;
36189 }
36190
36191 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_imprecise_amount() {
36192         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
36193         return ret_conv;
36194 }
36195
36196 jboolean  __attribute__((visibility("default"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
36197         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
36198         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
36199         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
36200         return ret_val;
36201 }
36202
36203 jstring  __attribute__((visibility("default"))) TS_SemanticError_to_str(uint32_t o) {
36204         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
36205         LDKStr ret_str = SemanticError_to_str(o_conv);
36206         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
36207         Str_free(ret_str);
36208         return ret_conv;
36209 }
36210
36211 void  __attribute__((visibility("default"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
36212         if ((this_ptr & 1) != 0) return;
36213         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
36214         CHECK_ACCESS(this_ptr_ptr);
36215         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
36216         FREE((void*)this_ptr);
36217         SignOrCreationError_free(this_ptr_conv);
36218 }
36219
36220 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
36221         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
36222         *ret_copy = SignOrCreationError_clone(arg);
36223 uint64_t ret_ref = (uint64_t)ret_copy;
36224         return ret_ref;
36225 }
36226 int64_t  __attribute__((visibility("default"))) TS_SignOrCreationError_clone_ptr(uint32_t arg) {
36227         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
36228         int64_t ret_val = SignOrCreationError_clone_ptr(arg_conv);
36229         return ret_val;
36230 }
36231
36232 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_clone(uint32_t orig) {
36233         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
36234         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
36235         *ret_copy = SignOrCreationError_clone(orig_conv);
36236         uint64_t ret_ref = (uint64_t)ret_copy;
36237         return ret_ref;
36238 }
36239
36240 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_sign_error() {
36241         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
36242         *ret_copy = SignOrCreationError_sign_error();
36243         uint64_t ret_ref = (uint64_t)ret_copy;
36244         return ret_ref;
36245 }
36246
36247 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_creation_error(uint32_t a) {
36248         LDKCreationError a_conv = LDKCreationError_from_js(a);
36249         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
36250         *ret_copy = SignOrCreationError_creation_error(a_conv);
36251         uint64_t ret_ref = (uint64_t)ret_copy;
36252         return ret_ref;
36253 }
36254
36255 jboolean  __attribute__((visibility("default"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
36256         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
36257         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
36258         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
36259         return ret_val;
36260 }
36261
36262 jstring  __attribute__((visibility("default"))) TS_SignOrCreationError_to_str(uint32_t o) {
36263         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
36264         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
36265         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
36266         Str_free(ret_str);
36267         return ret_conv;
36268 }
36269
36270 void  __attribute__((visibility("default"))) TS_InvoicePayer_free(uint32_t this_obj) {
36271         LDKInvoicePayer this_obj_conv;
36272         this_obj_conv.inner = (void*)(this_obj & (~1));
36273         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36275         InvoicePayer_free(this_obj_conv);
36276 }
36277
36278 void  __attribute__((visibility("default"))) TS_Payer_free(uint32_t this_ptr) {
36279         if ((this_ptr & 1) != 0) return;
36280         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
36281         CHECK_ACCESS(this_ptr_ptr);
36282         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
36283         FREE((void*)this_ptr);
36284         Payer_free(this_ptr_conv);
36285 }
36286
36287 void  __attribute__((visibility("default"))) TS_Router_free(uint32_t this_ptr) {
36288         if ((this_ptr & 1) != 0) return;
36289         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
36290         CHECK_ACCESS(this_ptr_ptr);
36291         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
36292         FREE((void*)this_ptr);
36293         Router_free(this_ptr_conv);
36294 }
36295
36296 void  __attribute__((visibility("default"))) TS_RetryAttempts_free(uint32_t this_obj) {
36297         LDKRetryAttempts this_obj_conv;
36298         this_obj_conv.inner = (void*)(this_obj & (~1));
36299         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36301         RetryAttempts_free(this_obj_conv);
36302 }
36303
36304 int64_t  __attribute__((visibility("default"))) TS_RetryAttempts_get_a(uint32_t this_ptr) {
36305         LDKRetryAttempts this_ptr_conv;
36306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36307         this_ptr_conv.is_owned = false;
36308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36309         int64_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
36310         return ret_val;
36311 }
36312
36313 void  __attribute__((visibility("default"))) TS_RetryAttempts_set_a(uint32_t this_ptr, int64_t val) {
36314         LDKRetryAttempts this_ptr_conv;
36315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36316         this_ptr_conv.is_owned = false;
36317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36318         RetryAttempts_set_a(&this_ptr_conv, val);
36319 }
36320
36321 uint32_t  __attribute__((visibility("default"))) TS_RetryAttempts_new(int64_t a_arg) {
36322         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
36323         uint64_t ret_ref = 0;
36324         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36325         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36327         ret_ref = (uint64_t)ret_var.inner;
36328         if (ret_var.is_owned) {
36329                 ret_ref |= 1;
36330         }
36331         return ret_ref;
36332 }
36333
36334 static inline uint64_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
36335         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
36336 uint64_t ret_ref = 0;
36337 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36338 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36339 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36340 ret_ref = (uint64_t)ret_var.inner;
36341 if (ret_var.is_owned) {
36342         ret_ref |= 1;
36343 }
36344         return ret_ref;
36345 }
36346 int64_t  __attribute__((visibility("default"))) TS_RetryAttempts_clone_ptr(uint32_t arg) {
36347         LDKRetryAttempts arg_conv;
36348         arg_conv.inner = (void*)(arg & (~1));
36349         arg_conv.is_owned = false;
36350         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36351         int64_t ret_val = RetryAttempts_clone_ptr(&arg_conv);
36352         return ret_val;
36353 }
36354
36355 uint32_t  __attribute__((visibility("default"))) TS_RetryAttempts_clone(uint32_t orig) {
36356         LDKRetryAttempts orig_conv;
36357         orig_conv.inner = (void*)(orig & (~1));
36358         orig_conv.is_owned = false;
36359         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36360         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
36361         uint64_t ret_ref = 0;
36362         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36363         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36365         ret_ref = (uint64_t)ret_var.inner;
36366         if (ret_var.is_owned) {
36367                 ret_ref |= 1;
36368         }
36369         return ret_ref;
36370 }
36371
36372 jboolean  __attribute__((visibility("default"))) TS_RetryAttempts_eq(uint32_t a, uint32_t b) {
36373         LDKRetryAttempts a_conv;
36374         a_conv.inner = (void*)(a & (~1));
36375         a_conv.is_owned = false;
36376         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36377         LDKRetryAttempts b_conv;
36378         b_conv.inner = (void*)(b & (~1));
36379         b_conv.is_owned = false;
36380         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36381         jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
36382         return ret_val;
36383 }
36384
36385 int64_t  __attribute__((visibility("default"))) TS_RetryAttempts_hash(uint32_t o) {
36386         LDKRetryAttempts o_conv;
36387         o_conv.inner = (void*)(o & (~1));
36388         o_conv.is_owned = false;
36389         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36390         int64_t ret_val = RetryAttempts_hash(&o_conv);
36391         return ret_val;
36392 }
36393
36394 void  __attribute__((visibility("default"))) TS_PaymentError_free(uint32_t this_ptr) {
36395         if ((this_ptr & 1) != 0) return;
36396         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
36397         CHECK_ACCESS(this_ptr_ptr);
36398         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
36399         FREE((void*)this_ptr);
36400         PaymentError_free(this_ptr_conv);
36401 }
36402
36403 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
36404         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
36405         *ret_copy = PaymentError_clone(arg);
36406 uint64_t ret_ref = (uint64_t)ret_copy;
36407         return ret_ref;
36408 }
36409 int64_t  __attribute__((visibility("default"))) TS_PaymentError_clone_ptr(uint32_t arg) {
36410         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
36411         int64_t ret_val = PaymentError_clone_ptr(arg_conv);
36412         return ret_val;
36413 }
36414
36415 uint32_t  __attribute__((visibility("default"))) TS_PaymentError_clone(uint32_t orig) {
36416         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
36417         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
36418         *ret_copy = PaymentError_clone(orig_conv);
36419         uint64_t ret_ref = (uint64_t)ret_copy;
36420         return ret_ref;
36421 }
36422
36423 uint32_t  __attribute__((visibility("default"))) TS_PaymentError_invoice(jstring a) {
36424         LDKStr a_conv = str_ref_to_owned_c(a);
36425         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
36426         *ret_copy = PaymentError_invoice(a_conv);
36427         uint64_t ret_ref = (uint64_t)ret_copy;
36428         return ret_ref;
36429 }
36430
36431 uint32_t  __attribute__((visibility("default"))) TS_PaymentError_routing(uint32_t a) {
36432         LDKLightningError a_conv;
36433         a_conv.inner = (void*)(a & (~1));
36434         a_conv.is_owned = (a & 1) || (a == 0);
36435         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36436         a_conv = LightningError_clone(&a_conv);
36437         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
36438         *ret_copy = PaymentError_routing(a_conv);
36439         uint64_t ret_ref = (uint64_t)ret_copy;
36440         return ret_ref;
36441 }
36442
36443 uint32_t  __attribute__((visibility("default"))) TS_PaymentError_sending(uint32_t a) {
36444         void* a_ptr = (void*)(((uint64_t)a) & ~1);
36445         CHECK_ACCESS(a_ptr);
36446         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
36447         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)a) & ~1));
36448         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
36449         *ret_copy = PaymentError_sending(a_conv);
36450         uint64_t ret_ref = (uint64_t)ret_copy;
36451         return ret_ref;
36452 }
36453
36454 uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_new(uint32_t payer, uint32_t router, uint32_t scorer, uint32_t logger, uint32_t event_handler, uint32_t retry_attempts) {
36455         void* payer_ptr = (void*)(((uint64_t)payer) & ~1);
36456         CHECK_ACCESS(payer_ptr);
36457         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
36458         void* router_ptr = (void*)(((uint64_t)router) & ~1);
36459         CHECK_ACCESS(router_ptr);
36460         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
36461         LDKLockableScore scorer_conv;
36462         scorer_conv.inner = (void*)(scorer & (~1));
36463         scorer_conv.is_owned = false;
36464         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
36465         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
36466         CHECK_ACCESS(logger_ptr);
36467         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
36468         void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
36469         CHECK_ACCESS(event_handler_ptr);
36470         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
36471         LDKRetryAttempts retry_attempts_conv;
36472         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
36473         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
36474         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
36475         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
36476         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
36477         uint64_t ret_ref = 0;
36478         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36479         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36481         ret_ref = (uint64_t)ret_var.inner;
36482         if (ret_var.is_owned) {
36483                 ret_ref |= 1;
36484         }
36485         return ret_ref;
36486 }
36487
36488 uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
36489         LDKInvoicePayer this_arg_conv;
36490         this_arg_conv.inner = (void*)(this_arg & (~1));
36491         this_arg_conv.is_owned = false;
36492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36493         LDKInvoice invoice_conv;
36494         invoice_conv.inner = (void*)(invoice & (~1));
36495         invoice_conv.is_owned = false;
36496         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
36497         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
36498         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
36499         return (uint64_t)ret_conv;
36500 }
36501
36502 uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_pay_zero_value_invoice(uint32_t this_arg, uint32_t invoice, int64_t amount_msats) {
36503         LDKInvoicePayer this_arg_conv;
36504         this_arg_conv.inner = (void*)(this_arg & (~1));
36505         this_arg_conv.is_owned = false;
36506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36507         LDKInvoice invoice_conv;
36508         invoice_conv.inner = (void*)(invoice & (~1));
36509         invoice_conv.is_owned = false;
36510         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
36511         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
36512         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
36513         return (uint64_t)ret_conv;
36514 }
36515
36516 void  __attribute__((visibility("default"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
36517         LDKInvoicePayer this_arg_conv;
36518         this_arg_conv.inner = (void*)(this_arg & (~1));
36519         this_arg_conv.is_owned = false;
36520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36521         unsigned char payment_hash_arr[32];
36522         CHECK(*((uint32_t*)payment_hash) == 32);
36523         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
36524         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
36525         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
36526 }
36527
36528 uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
36529         LDKInvoicePayer this_arg_conv;
36530         this_arg_conv.inner = (void*)(this_arg & (~1));
36531         this_arg_conv.is_owned = false;
36532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36533         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
36534         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
36535         return (uint64_t)ret_ret;
36536 }
36537
36538 uint32_t  __attribute__((visibility("default"))) TS_create_invoice_from_channelmanager(uint32_t channelmanager, uint32_t keys_manager, uint32_t network, uint32_t amt_msat, jstring description) {
36539         LDKChannelManager channelmanager_conv;
36540         channelmanager_conv.inner = (void*)(channelmanager & (~1));
36541         channelmanager_conv.is_owned = false;
36542         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
36543         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
36544         CHECK_ACCESS(keys_manager_ptr);
36545         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
36546         LDKCurrency network_conv = LDKCurrency_from_js(network);
36547         void* amt_msat_ptr = (void*)(((uint64_t)amt_msat) & ~1);
36548         CHECK_ACCESS(amt_msat_ptr);
36549         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
36550         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1));
36551         LDKStr description_conv = str_ref_to_owned_c(description);
36552         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
36553         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
36554         return (uint64_t)ret_conv;
36555 }
36556
36557 void  __attribute__((visibility("default"))) TS_DefaultRouter_free(uint32_t this_obj) {
36558         LDKDefaultRouter this_obj_conv;
36559         this_obj_conv.inner = (void*)(this_obj & (~1));
36560         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36562         DefaultRouter_free(this_obj_conv);
36563 }
36564
36565 uint32_t  __attribute__((visibility("default"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger) {
36566         LDKNetworkGraph network_graph_conv;
36567         network_graph_conv.inner = (void*)(network_graph & (~1));
36568         network_graph_conv.is_owned = false;
36569         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
36570         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
36571         CHECK_ACCESS(logger_ptr);
36572         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
36573         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
36574         uint64_t ret_ref = 0;
36575         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36576         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36578         ret_ref = (uint64_t)ret_var.inner;
36579         if (ret_var.is_owned) {
36580                 ret_ref |= 1;
36581         }
36582         return ret_ref;
36583 }
36584
36585 uint32_t  __attribute__((visibility("default"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
36586         LDKDefaultRouter this_arg_conv;
36587         this_arg_conv.inner = (void*)(this_arg & (~1));
36588         this_arg_conv.is_owned = false;
36589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36590         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
36591         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
36592         return (uint64_t)ret_ret;
36593 }
36594
36595 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
36596         LDKChannelManager this_arg_conv;
36597         this_arg_conv.inner = (void*)(this_arg & (~1));
36598         this_arg_conv.is_owned = false;
36599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36600         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
36601         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
36602         return (uint64_t)ret_ret;
36603 }
36604
36605 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_from_str(jstring s) {
36606         LDKStr s_conv = str_ref_to_owned_c(s);
36607         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
36608         *ret_conv = SiPrefix_from_str(s_conv);
36609         return (uint64_t)ret_conv;
36610 }
36611
36612 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_str(jstring s) {
36613         LDKStr s_conv = str_ref_to_owned_c(s);
36614         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
36615         *ret_conv = Invoice_from_str(s_conv);
36616         return (uint64_t)ret_conv;
36617 }
36618
36619 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_from_str(jstring s) {
36620         LDKStr s_conv = str_ref_to_owned_c(s);
36621         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
36622         *ret_conv = SignedRawInvoice_from_str(s_conv);
36623         return (uint64_t)ret_conv;
36624 }
36625
36626 jstring  __attribute__((visibility("default"))) TS_Invoice_to_str(uint32_t o) {
36627         LDKInvoice o_conv;
36628         o_conv.inner = (void*)(o & (~1));
36629         o_conv.is_owned = false;
36630         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36631         LDKStr ret_str = Invoice_to_str(&o_conv);
36632         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
36633         Str_free(ret_str);
36634         return ret_conv;
36635 }
36636
36637 jstring  __attribute__((visibility("default"))) TS_SignedRawInvoice_to_str(uint32_t o) {
36638         LDKSignedRawInvoice o_conv;
36639         o_conv.inner = (void*)(o & (~1));
36640         o_conv.is_owned = false;
36641         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36642         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
36643         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
36644         Str_free(ret_str);
36645         return ret_conv;
36646 }
36647
36648 jstring  __attribute__((visibility("default"))) TS_Currency_to_str(uint32_t o) {
36649         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
36650         LDKStr ret_str = Currency_to_str(o_conv);
36651         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
36652         Str_free(ret_str);
36653         return ret_conv;
36654 }
36655
36656 jstring  __attribute__((visibility("default"))) TS_SiPrefix_to_str(uint32_t o) {
36657         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
36658         LDKStr ret_str = SiPrefix_to_str(o_conv);
36659         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
36660         Str_free(ret_str);
36661         return ret_conv;
36662 }
36663