Update auto-generated bindings
[ldk-java] / ts / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include "js-wasm.h"
4 #include <stdatomic.h>
5 #include <lightning.h>
6
7 // These should be provided...somehow...
8 void *memset(void *s, int c, size_t n);
9 void *memcpy(void *dest, const void *src, size_t n);
10 int memcmp(const void *s1, const void *s2, size_t n);
11
12 void __attribute__((noreturn)) abort(void);
13 static inline void assert(bool expression) {
14         if (!expression) { abort(); }
15 }
16
17 void *malloc(size_t size);
18 void free(void *ptr);
19
20 #define MALLOC(a, _) malloc(a)
21 #define FREE(p) if ((long)(p) > 1024) { free(p); }
22 #define DO_ASSERT(a) (void)(a)
23 #define CHECK(a)
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 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u8Z_new(int8_tArray elems) {
315         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
316         ret->datalen = *((uint32_t*)elems);
317         if (ret->datalen == 0) {
318                 ret->data = NULL;
319         } else {
320                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
321                 int8_t *java_elems = (int8_t*)(elems + 4);
322                 for (size_t i = 0; i < ret->datalen; i++) {
323                         ret->data[i] = java_elems[i];
324                 }
325         }
326         return (uint64_t)ret;
327 }
328 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
329         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
330         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
331         return ret;
332 }
333 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) {
334         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
335         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
336         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
337         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
338         CVec_u8Z_free(ret_var);
339         return ret_arr;
340 }
341
342 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}int64_t  __attribute__((visibility("default"))) TS_TxOut_get_value(uint32_t thing) {
343         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
344         int64_t ret_val = TxOut_get_value(thing_conv);
345         return ret_val;
346 }
347
348 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_result_ok(uint32_t arg) {
349         return ((LDKCResult_SecretKeyErrorZ*)arg)->result_ok;
350 }
351 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_ok(uint32_t arg) {
352         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
353         CHECK(val->result_ok);
354         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
355         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).bytes, 32);
356         return res_arr;
357 }
358 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_err(uint32_t arg) {
359         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
360         CHECK(!val->result_ok);
361         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
362         return err_conv;
363 }
364 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_result_ok(uint32_t arg) {
365         return ((LDKCResult_PublicKeyErrorZ*)arg)->result_ok;
366 }
367 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_ok(uint32_t arg) {
368         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
369         CHECK(val->result_ok);
370         int8_tArray res_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
371         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compressed_form, 33);
372         return res_arr;
373 }
374 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_err(uint32_t arg) {
375         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
376         CHECK(!val->result_ok);
377         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
378         return err_conv;
379 }
380 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_result_ok(uint32_t arg) {
381         return ((LDKCResult_TxCreationKeysDecodeErrorZ*)arg)->result_ok;
382 }
383 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t arg) {
384         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
385         CHECK(val->result_ok);
386         LDKTxCreationKeys res_var = (*val->contents.result);
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         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
390         return res_ref;
391 }
392 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t arg) {
393         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
394         CHECK(!val->result_ok);
395         LDKDecodeError err_var = (*val->contents.err);
396         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
397         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
398         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
399         return err_ref;
400 }
401 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_result_ok(uint32_t arg) {
402         return ((LDKCResult_ChannelPublicKeysDecodeErrorZ*)arg)->result_ok;
403 }
404 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t arg) {
405         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
406         CHECK(val->result_ok);
407         LDKChannelPublicKeys res_var = (*val->contents.result);
408         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
409         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
410         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
411         return res_ref;
412 }
413 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t arg) {
414         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
415         CHECK(!val->result_ok);
416         LDKDecodeError err_var = (*val->contents.err);
417         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
418         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
419         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
420         return err_ref;
421 }
422 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_result_ok(uint32_t arg) {
423         return ((LDKCResult_TxCreationKeysErrorZ*)arg)->result_ok;
424 }
425 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_ok(uint32_t arg) {
426         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
427         CHECK(val->result_ok);
428         LDKTxCreationKeys res_var = (*val->contents.result);
429         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
430         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
431         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
432         return res_ref;
433 }
434 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_err(uint32_t arg) {
435         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
436         CHECK(!val->result_ok);
437         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
438         return err_conv;
439 }
440 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u32Z_ref_from_ptr(uint32_t ptr) {
441         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
442         switch(obj->tag) {
443                 case LDKCOption_u32Z_Some: {
444                         return 0 /* LDKCOption_u32Z - Some */; (void) obj->some;
445                 }
446                 case LDKCOption_u32Z_None: {
447                         return 0 /* LDKCOption_u32Z - None */;
448                 }
449                 default: abort();
450         }
451 }
452 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_result_ok(uint32_t arg) {
453         return ((LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)arg)->result_ok;
454 }
455 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t arg) {
456         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
457         CHECK(val->result_ok);
458         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
459         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
460         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
461         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
462         return res_ref;
463 }
464 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t arg) {
465         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
466         CHECK(!val->result_ok);
467         LDKDecodeError err_var = (*val->contents.err);
468         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
469         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
470         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
471         return err_ref;
472 }
473 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
474         return ((LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
475 }
476 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
477         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
478         CHECK(val->result_ok);
479         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
480         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
481         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
482         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
483         return res_ref;
484 }
485 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
486         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
487         CHECK(!val->result_ok);
488         LDKDecodeError err_var = (*val->contents.err);
489         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
490         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
491         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
492         return err_ref;
493 }
494 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_result_ok(uint32_t arg) {
495         return ((LDKCResult_ChannelTransactionParametersDecodeErrorZ*)arg)->result_ok;
496 }
497 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
498         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
499         CHECK(val->result_ok);
500         LDKChannelTransactionParameters res_var = (*val->contents.result);
501         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
502         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
503         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
504         return res_ref;
505 }
506 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
507         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
508         CHECK(!val->result_ok);
509         LDKDecodeError err_var = (*val->contents.err);
510         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
511         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
512         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
513         return err_ref;
514 }
515 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
516         return ((LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
517 }
518 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
519         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
520         CHECK(val->result_ok);
521         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
522         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
523         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
524         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
525         return res_ref;
526 }
527 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
528         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
529         CHECK(!val->result_ok);
530         LDKDecodeError err_var = (*val->contents.err);
531         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
532         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
533         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
534         return err_ref;
535 }
536 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
537         return ((LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)arg)->result_ok;
538 }
539 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
540         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
541         CHECK(val->result_ok);
542         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
543         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
544         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
545         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
546         return res_ref;
547 }
548 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
549         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
550         CHECK(!val->result_ok);
551         LDKDecodeError err_var = (*val->contents.err);
552         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
553         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
554         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
555         return err_ref;
556 }
557 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_result_ok(uint32_t arg) {
558         return ((LDKCResult_TrustedClosingTransactionNoneZ*)arg)->result_ok;
559 }
560 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t arg) {
561         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
562         CHECK(val->result_ok);
563         LDKTrustedClosingTransaction res_var = (*val->contents.result);
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         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
567         return res_ref;
568 }
569 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_get_err(uint32_t arg) {
570         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
571         CHECK(!val->result_ok);
572         return *val->contents.err;
573 }
574 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_result_ok(uint32_t arg) {
575         return ((LDKCResult_CommitmentTransactionDecodeErrorZ*)arg)->result_ok;
576 }
577 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
578         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
579         CHECK(val->result_ok);
580         LDKCommitmentTransaction res_var = (*val->contents.result);
581         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
582         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
583         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
584         return res_ref;
585 }
586 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
587         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
588         CHECK(!val->result_ok);
589         LDKDecodeError err_var = (*val->contents.err);
590         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
591         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
592         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
593         return err_ref;
594 }
595 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(uint32_t arg) {
596         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
597 }
598 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t arg) {
599         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
600         CHECK(val->result_ok);
601         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
602         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
603         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
604         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
605         return res_ref;
606 }
607 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
608         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
609         CHECK(!val->result_ok);
610         return *val->contents.err;
611 }
612 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_result_ok(uint32_t arg) {
613         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
614 }
615 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_ok(uint32_t arg) {
616         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
617         CHECK(val->result_ok);
618         LDKCVec_SignatureZ res_var = (*val->contents.result);
619         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
620         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
621         for (size_t m = 0; m < res_var.datalen; m++) {
622                 int8_tArray res_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
623                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_var.data[m].compact_form, 64);
624                 res_arr_ptr[m] = res_conv_12_arr;
625         }
626         return res_arr;
627 }
628 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
629         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
630         CHECK(!val->result_ok);
631         return *val->contents.err;
632 }
633 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_result_ok(uint32_t arg) {
634         return ((LDKCResult_ShutdownScriptDecodeErrorZ*)arg)->result_ok;
635 }
636 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t arg) {
637         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
638         CHECK(val->result_ok);
639         LDKShutdownScript res_var = (*val->contents.result);
640         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
641         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
642         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
643         return res_ref;
644 }
645 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t arg) {
646         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
647         CHECK(!val->result_ok);
648         LDKDecodeError err_var = (*val->contents.err);
649         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
650         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
651         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
652         return err_ref;
653 }
654 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_result_ok(uint32_t arg) {
655         return ((LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)arg)->result_ok;
656 }
657 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t arg) {
658         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
659         CHECK(val->result_ok);
660         LDKShutdownScript res_var = (*val->contents.result);
661         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
662         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
663         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
664         return res_ref;
665 }
666 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t arg) {
667         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
668         CHECK(!val->result_ok);
669         LDKInvalidShutdownScript err_var = (*val->contents.err);
670         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
671         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
672         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
673         return err_ref;
674 }
675 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_result_ok(uint32_t arg) {
676         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
677 }
678 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_ok(uint32_t arg) {
679         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
680         CHECK(val->result_ok);
681         return *val->contents.result;
682 }
683 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_err(uint32_t arg) {
684         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
685         CHECK(!val->result_ok);
686         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
687         return err_conv;
688 }
689 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_result_ok(uint32_t arg) {
690         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
691 }
692 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_ok(uint32_t arg) {
693         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
694         CHECK(val->result_ok);
695         LDKRouteHop res_var = (*val->contents.result);
696         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
697         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
698         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
699         return res_ref;
700 }
701 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_err(uint32_t arg) {
702         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
703         CHECK(!val->result_ok);
704         LDKDecodeError err_var = (*val->contents.err);
705         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
706         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
707         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
708         return err_ref;
709 }
710 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
711         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
712         ret->datalen = *((uint32_t*)elems);
713         if (ret->datalen == 0) {
714                 ret->data = NULL;
715         } else {
716                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
717                 uint32_t *java_elems = (uint32_t*)(elems + 4);
718                 for (size_t i = 0; i < ret->datalen; i++) {
719                         uint32_t arr_elem = java_elems[i];
720                         LDKRouteHop arr_elem_conv;
721                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
722                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
723                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
724                         ret->data[i] = arr_elem_conv;
725                 }
726         }
727         return (uint64_t)ret;
728 }
729 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
730         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
731         for (size_t i = 0; i < ret.datalen; i++) {
732                 ret.data[i] = RouteHop_clone(&orig->data[i]);
733         }
734         return ret;
735 }
736 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
737         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
738         for (size_t i = 0; i < ret.datalen; i++) {
739                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
740         }
741         return ret;
742 }
743 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_result_ok(uint32_t arg) {
744         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
745 }
746 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
747         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
748         CHECK(val->result_ok);
749         LDKRoute res_var = (*val->contents.result);
750         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
751         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
752         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
753         return res_ref;
754 }
755 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
756         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
757         CHECK(!val->result_ok);
758         LDKDecodeError err_var = (*val->contents.err);
759         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
760         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
761         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
762         return err_ref;
763 }
764 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(uint32_t ptr) {
765         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
766         switch(obj->tag) {
767                 case LDKCOption_u64Z_Some: {
768                         return 0 /* LDKCOption_u64Z - Some */; (void) obj->some;
769                 }
770                 case LDKCOption_u64Z_None: {
771                         return 0 /* LDKCOption_u64Z - None */;
772                 }
773                 default: abort();
774         }
775 }
776 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
777         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
778         ret->datalen = *((uint32_t*)elems);
779         if (ret->datalen == 0) {
780                 ret->data = NULL;
781         } else {
782                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
783                 uint32_t *java_elems = (uint32_t*)(elems + 4);
784                 for (size_t i = 0; i < ret->datalen; i++) {
785                         uint32_t arr_elem = java_elems[i];
786                         LDKChannelDetails arr_elem_conv;
787                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
788                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
789                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
790                         ret->data[i] = arr_elem_conv;
791                 }
792         }
793         return (uint64_t)ret;
794 }
795 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
796         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
797         for (size_t i = 0; i < ret.datalen; i++) {
798                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
799         }
800         return ret;
801 }
802 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
803         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
804         ret->datalen = *((uint32_t*)elems);
805         if (ret->datalen == 0) {
806                 ret->data = NULL;
807         } else {
808                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
809                 uint32_t *java_elems = (uint32_t*)(elems + 4);
810                 for (size_t i = 0; i < ret->datalen; i++) {
811                         uint32_t arr_elem = java_elems[i];
812                         LDKRouteHint arr_elem_conv;
813                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
814                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
815                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
816                         ret->data[i] = arr_elem_conv;
817                 }
818         }
819         return (uint64_t)ret;
820 }
821 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
822         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
823         for (size_t i = 0; i < ret.datalen; i++) {
824                 ret.data[i] = RouteHint_clone(&orig->data[i]);
825         }
826         return ret;
827 }
828 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_result_ok(uint32_t arg) {
829         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
830 }
831 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
832         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
833         CHECK(val->result_ok);
834         LDKRoute res_var = (*val->contents.result);
835         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
836         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
837         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
838         return res_ref;
839 }
840 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
841         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
842         CHECK(!val->result_ok);
843         LDKLightningError err_var = (*val->contents.err);
844         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
845         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
846         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
847         return err_ref;
848 }
849 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
850         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
851 }
852 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
853         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
854         CHECK(val->result_ok);
855         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
856         return (uint64_t)res_ref;
857 }
858 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
859         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
860         CHECK(!val->result_ok);
861         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
862         return err_conv;
863 }
864 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
865         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
866         ret->a = a;
867         LDKTransaction b_ref;
868         b_ref.datalen = *((uint32_t*)b);
869         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
870         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
871         b_ref.data_is_owned = false;
872         ret->b = b_ref;
873         return (uint64_t)ret;
874 }
875 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
876         return tuple->a;
877 }
878 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t tuple) {
879         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
880         int64_t ret_val = C2Tuple_usizeTransactionZ_get_a(tuple_conv);
881         return ret_val;
882 }
883
884 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
885         return tuple->b;
886 }
887 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t tuple) {
888         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
889         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(tuple_conv);
890         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
891         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
892         Transaction_free(ret_var);
893         return ret_arr;
894 }
895
896 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransactionZZ_new(uint32_tArray elems) {
897         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
898         ret->datalen = *((uint32_t*)elems);
899         if (ret->datalen == 0) {
900                 ret->data = NULL;
901         } else {
902                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
903                 uint32_t *java_elems = (uint32_t*)(elems + 4);
904                 for (size_t i = 0; i < ret->datalen; i++) {
905                         uint32_t arr_elem = java_elems[i];
906                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
907                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
908                         ret->data[i] = arr_elem_conv;
909                 }
910         }
911         return (uint64_t)ret;
912 }
913 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
914         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
915         for (size_t i = 0; i < ret.datalen; i++) {
916                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
917         }
918         return ret;
919 }
920 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
921         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
922         for (size_t i = 0; i < ret.datalen; i++) {
923                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
924         }
925         return ret;
926 }
927 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(uint32_t arg) {
928         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
929 }
930 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
931         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
932         CHECK(val->result_ok);
933         return *val->contents.result;
934 }
935 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
936         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
937         CHECK(!val->result_ok);
938         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
939         return err_conv;
940 }
941 uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(uint32_t ptr) {
942         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
943         switch(obj->tag) {
944                 case LDKMonitorEvent_HTLCEvent: {
945                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
946                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
947                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
948                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
949                         return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref;
950                 }
951                 case LDKMonitorEvent_CommitmentTxConfirmed: {
952                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
953                         CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
954                         CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
955                         uint64_t commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1;
956                         return 0 /* LDKMonitorEvent - CommitmentTxConfirmed */; (void) commitment_tx_confirmed_ref;
957                 }
958                 default: abort();
959         }
960 }
961 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(uint32_tArray elems) {
962         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
963         ret->datalen = *((uint32_t*)elems);
964         if (ret->datalen == 0) {
965                 ret->data = NULL;
966         } else {
967                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
968                 uint32_t *java_elems = (uint32_t*)(elems + 4);
969                 for (size_t i = 0; i < ret->datalen; i++) {
970                         uint32_t arr_elem = java_elems[i];
971                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
972                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
973                         ret->data[i] = arr_elem_conv;
974                 }
975         }
976         return (uint64_t)ret;
977 }
978 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
979         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
980         for (size_t i = 0; i < ret.datalen; i++) {
981                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
982         }
983         return ret;
984 }
985 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ref_from_ptr(uint32_t ptr) {
986         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
987         switch(obj->tag) {
988                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
989                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
990                         *some_conv = obj->some;
991                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
992                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - Some */; (void) ((uint64_t)some_conv);
993                 }
994                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
995                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - None */;
996                 }
997                 default: abort();
998         }
999 }
1000 uint32_t __attribute__((visibility("default"))) TS_LDKNetworkUpdate_ref_from_ptr(uint32_t ptr) {
1001         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1002         switch(obj->tag) {
1003                 case LDKNetworkUpdate_ChannelUpdateMessage: {
1004                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1005                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1006                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1007                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1008                         return 0 /* LDKNetworkUpdate - ChannelUpdateMessage */; (void) msg_ref;
1009                 }
1010                 case LDKNetworkUpdate_ChannelClosed: {
1011                         return 0 /* LDKNetworkUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
1012                 }
1013                 case LDKNetworkUpdate_NodeFailure: {
1014                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1015                         memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
1016                         return 0 /* LDKNetworkUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
1017                 }
1018                 default: abort();
1019         }
1020 }
1021 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_NetworkUpdateZ_ref_from_ptr(uint32_t ptr) {
1022         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1023         switch(obj->tag) {
1024                 case LDKCOption_NetworkUpdateZ_Some: {
1025                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1026                         return 0 /* LDKCOption_NetworkUpdateZ - Some */; (void) some_ref;
1027                 }
1028                 case LDKCOption_NetworkUpdateZ_None: {
1029                         return 0 /* LDKCOption_NetworkUpdateZ - None */;
1030                 }
1031                 default: abort();
1032         }
1033 }
1034 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
1035         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1036         switch(obj->tag) {
1037                 case LDKSpendableOutputDescriptor_StaticOutput: {
1038                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1039                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1040                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1041                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1042                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1043                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (uint64_t)output_ref;
1044                 }
1045                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1046                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1047                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1048                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1049                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1050                         return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */; (void) delayed_payment_output_ref;
1051                 }
1052                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1053                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1054                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1055                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1056                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1057                         return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */; (void) static_payment_output_ref;
1058                 }
1059                 default: abort();
1060         }
1061 }
1062 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescriptorZ_new(uint32_tArray elems) {
1063         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1064         ret->datalen = *((uint32_t*)elems);
1065         if (ret->datalen == 0) {
1066                 ret->data = NULL;
1067         } else {
1068                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1069                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1070                 for (size_t i = 0; i < ret->datalen; i++) {
1071                         uint32_t arr_elem = java_elems[i];
1072                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1073                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1074                         ret->data[i] = arr_elem_conv;
1075                 }
1076         }
1077         return (uint64_t)ret;
1078 }
1079 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1080         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1081         for (size_t i = 0; i < ret.datalen; i++) {
1082                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1083         }
1084         return ret;
1085 }
1086 uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
1087         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1088         switch(obj->tag) {
1089                 case LDKErrorAction_DisconnectPeer: {
1090                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1091                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1092                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1093                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1094                         return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
1095                 }
1096                 case LDKErrorAction_IgnoreError: {
1097                         return 0 /* LDKErrorAction - IgnoreError */;
1098                 }
1099                 case LDKErrorAction_IgnoreAndLog: {
1100                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
1101                         return 0 /* LDKErrorAction - IgnoreAndLog */; (void) ignore_and_log_conv;
1102                 }
1103                 case LDKErrorAction_SendErrorMessage: {
1104                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1105                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1106                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1107                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1108                         return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
1109                 }
1110                 default: abort();
1111         }
1112 }
1113 uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
1114         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1115         switch(obj->tag) {
1116                 case LDKMessageSendEvent_SendAcceptChannel: {
1117                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1118                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
1119                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1120                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1121                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1122                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1123                         return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
1124                 }
1125                 case LDKMessageSendEvent_SendOpenChannel: {
1126                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1127                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
1128                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1129                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1130                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1131                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1132                         return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
1133                 }
1134                 case LDKMessageSendEvent_SendFundingCreated: {
1135                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1136                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
1137                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1138                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1139                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1140                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1141                         return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
1142                 }
1143                 case LDKMessageSendEvent_SendFundingSigned: {
1144                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1145                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
1146                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1147                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1148                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1149                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1150                         return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
1151                 }
1152                 case LDKMessageSendEvent_SendFundingLocked: {
1153                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1154                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
1155                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1156                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1157                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1158                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1159                         return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
1160                 }
1161                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1162                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1163                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
1164                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1165                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1166                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1167                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1168                         return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
1169                 }
1170                 case LDKMessageSendEvent_UpdateHTLCs: {
1171                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1172                         memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
1173                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1174                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1175                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1176                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1177                         return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
1178                 }
1179                 case LDKMessageSendEvent_SendRevokeAndACK: {
1180                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1181                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
1182                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1183                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1184                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1185                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1186                         return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
1187                 }
1188                 case LDKMessageSendEvent_SendClosingSigned: {
1189                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1190                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
1191                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1192                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1193                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1194                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1195                         return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
1196                 }
1197                 case LDKMessageSendEvent_SendShutdown: {
1198                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1199                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
1200                         LDKShutdown msg_var = obj->send_shutdown.msg;
1201                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1202                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1203                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1204                         return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
1205                 }
1206                 case LDKMessageSendEvent_SendChannelReestablish: {
1207                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1208                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
1209                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1210                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1211                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1212                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1213                         return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
1214                 }
1215                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1216                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1217                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1218                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1219                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1220                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1221                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1222                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1223                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1224                         return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
1225                 }
1226                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1227                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1228                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1229                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1230                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1231                         return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
1232                 }
1233                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1234                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1235                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1236                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1237                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1238                         return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
1239                 }
1240                 case LDKMessageSendEvent_SendChannelUpdate: {
1241                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1242                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_update.node_id.compressed_form, 33);
1243                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1244                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1245                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1246                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1247                         return 0 /* LDKMessageSendEvent - SendChannelUpdate */; (void) node_id_arr; (void) msg_ref;
1248                 }
1249                 case LDKMessageSendEvent_HandleError: {
1250                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1251                         memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33);
1252                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1253                         return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
1254                 }
1255                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1256                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1257                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
1258                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1259                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1260                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1261                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1262                         return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
1263                 }
1264                 case LDKMessageSendEvent_SendShortIdsQuery: {
1265                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1266                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
1267                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1268                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1269                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1270                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1271                         return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
1272                 }
1273                 case LDKMessageSendEvent_SendReplyChannelRange: {
1274                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1275                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_reply_channel_range.node_id.compressed_form, 33);
1276                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1277                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1278                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1279                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1280                         return 0 /* LDKMessageSendEvent - SendReplyChannelRange */; (void) node_id_arr; (void) msg_ref;
1281                 }
1282                 default: abort();
1283         }
1284 }
1285 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_new(uint32_tArray elems) {
1286         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1287         ret->datalen = *((uint32_t*)elems);
1288         if (ret->datalen == 0) {
1289                 ret->data = NULL;
1290         } else {
1291                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1292                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1293                 for (size_t i = 0; i < ret->datalen; i++) {
1294                         uint32_t arr_elem = java_elems[i];
1295                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1296                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1297                         ret->data[i] = arr_elem_conv;
1298                 }
1299         }
1300         return (uint64_t)ret;
1301 }
1302 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1303         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1304         for (size_t i = 0; i < ret.datalen; i++) {
1305                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1306         }
1307         return ret;
1308 }
1309 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1310         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1311 }
1312 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1313         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1314         CHECK(val->result_ok);
1315         LDKInitFeatures res_var = (*val->contents.result);
1316         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1317         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1318         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1319         return res_ref;
1320 }
1321 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1322         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1323         CHECK(!val->result_ok);
1324         LDKDecodeError err_var = (*val->contents.err);
1325         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1326         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1327         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1328         return err_ref;
1329 }
1330 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1331         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1332 }
1333 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1334         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1335         CHECK(val->result_ok);
1336         LDKNodeFeatures res_var = (*val->contents.result);
1337         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1338         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1339         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1340         return res_ref;
1341 }
1342 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1343         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1344         CHECK(!val->result_ok);
1345         LDKDecodeError err_var = (*val->contents.err);
1346         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1347         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1348         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1349         return err_ref;
1350 }
1351 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1352         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1353 }
1354 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1355         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1356         CHECK(val->result_ok);
1357         LDKChannelFeatures res_var = (*val->contents.result);
1358         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1359         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1360         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1361         return res_ref;
1362 }
1363 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1364         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1365         CHECK(!val->result_ok);
1366         LDKDecodeError err_var = (*val->contents.err);
1367         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1368         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1369         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1370         return err_ref;
1371 }
1372 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
1373         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
1374 }
1375 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1376         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1377         CHECK(val->result_ok);
1378         LDKInvoiceFeatures res_var = (*val->contents.result);
1379         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1380         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1381         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1382         return res_ref;
1383 }
1384 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1385         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1386         CHECK(!val->result_ok);
1387         LDKDecodeError err_var = (*val->contents.err);
1388         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1389         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1390         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1391         return err_ref;
1392 }
1393 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1394         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1395 }
1396 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1397         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1398         CHECK(val->result_ok);
1399         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
1400         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1401         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1402         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1403         return res_ref;
1404 }
1405 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1406         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1407         CHECK(!val->result_ok);
1408         LDKDecodeError err_var = (*val->contents.err);
1409         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1410         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1411         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1412         return err_ref;
1413 }
1414 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1415         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1416 }
1417 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1418         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1419         CHECK(val->result_ok);
1420         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
1421         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1422         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1423         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1424         return res_ref;
1425 }
1426 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1427         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1428         CHECK(!val->result_ok);
1429         LDKDecodeError err_var = (*val->contents.err);
1430         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1431         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1432         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1433         return err_ref;
1434 }
1435 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1436         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1437 }
1438 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1439         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1440         CHECK(val->result_ok);
1441         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1442         return res_ref;
1443 }
1444 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1445         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1446         CHECK(!val->result_ok);
1447         LDKDecodeError err_var = (*val->contents.err);
1448         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1449         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1450         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1451         return err_ref;
1452 }
1453 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_result_ok(uint32_t arg) {
1454         return ((LDKCResult_NoneNoneZ*)arg)->result_ok;
1455 }
1456 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_ok(uint32_t arg) {
1457         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
1458         CHECK(val->result_ok);
1459         return *val->contents.result;
1460 }
1461 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_err(uint32_t arg) {
1462         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
1463         CHECK(!val->result_ok);
1464         return *val->contents.err;
1465 }
1466 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
1467         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1468         LDKSignature a_ref;
1469         CHECK(*((uint32_t*)a) == 64);
1470         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
1471         ret->a = a_ref;
1472         LDKCVec_SignatureZ b_constr;
1473         b_constr.datalen = *((uint32_t*)b);
1474         if (b_constr.datalen > 0)
1475                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
1476         else
1477                 b_constr.data = NULL;
1478         int8_tArray* b_vals = (int8_tArray*)(b + 4);
1479         for (size_t m = 0; m < b_constr.datalen; m++) {
1480                 int8_tArray b_conv_12 = b_vals[m];
1481                 LDKSignature b_conv_12_ref;
1482                 CHECK(*((uint32_t*)b_conv_12) == 64);
1483                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
1484                 b_constr.data[m] = b_conv_12_ref;
1485         }
1486         ret->b = b_constr;
1487         return (uint64_t)ret;
1488 }
1489 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
1490         return tuple->a;
1491 }
1492 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t tuple) {
1493         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
1494         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1495         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_SignatureCVec_SignatureZZ_get_a(tuple_conv).compact_form, 64);
1496         return ret_arr;
1497 }
1498
1499 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
1500         return tuple->b;
1501 }
1502 ptrArray  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t tuple) {
1503         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
1504         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(tuple_conv);
1505         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1506         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
1507         for (size_t m = 0; m < ret_var.datalen; m++) {
1508                 int8_tArray ret_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1509                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compact_form, 64);
1510                 ret_arr_ptr[m] = ret_conv_12_arr;
1511         }
1512         FREE(ret_var.data);
1513         return ret_arr;
1514 }
1515
1516 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(uint32_t arg) {
1517         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
1518 }
1519 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
1520         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1521         CHECK(val->result_ok);
1522         LDKC2Tuple_SignatureCVec_SignatureZZ* res_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1523         *res_conv = (*val->contents.result);
1524         *res_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(res_conv);
1525         return ((uint64_t)res_conv);
1526 }
1527 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
1528         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1529         CHECK(!val->result_ok);
1530         return *val->contents.err;
1531 }
1532 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_result_ok(uint32_t arg) {
1533         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
1534 }
1535 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
1536         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1537         CHECK(val->result_ok);
1538         int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1539         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
1540         return res_arr;
1541 }
1542 void  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
1543         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1544         CHECK(!val->result_ok);
1545         return *val->contents.err;
1546 }
1547 typedef struct LDKBaseSign_JCalls {
1548         atomic_size_t refcnt;
1549         uint32_t get_per_commitment_point_meth;
1550         uint32_t release_commitment_secret_meth;
1551         uint32_t validate_holder_commitment_meth;
1552         uint32_t channel_keys_id_meth;
1553         uint32_t sign_counterparty_commitment_meth;
1554         uint32_t validate_counterparty_revocation_meth;
1555         uint32_t sign_holder_commitment_and_htlcs_meth;
1556         uint32_t sign_justice_revoked_output_meth;
1557         uint32_t sign_justice_revoked_htlc_meth;
1558         uint32_t sign_counterparty_htlc_transaction_meth;
1559         uint32_t sign_closing_transaction_meth;
1560         uint32_t sign_channel_announcement_meth;
1561         uint32_t ready_channel_meth;
1562 } LDKBaseSign_JCalls;
1563 static void LDKBaseSign_JCalls_free(void* this_arg) {
1564         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1565         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1566                 js_free(j_calls->get_per_commitment_point_meth);
1567                 js_free(j_calls->release_commitment_secret_meth);
1568                 js_free(j_calls->validate_holder_commitment_meth);
1569                 js_free(j_calls->channel_keys_id_meth);
1570                 js_free(j_calls->sign_counterparty_commitment_meth);
1571                 js_free(j_calls->validate_counterparty_revocation_meth);
1572                 js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
1573                 js_free(j_calls->sign_justice_revoked_output_meth);
1574                 js_free(j_calls->sign_justice_revoked_htlc_meth);
1575                 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
1576                 js_free(j_calls->sign_closing_transaction_meth);
1577                 js_free(j_calls->sign_channel_announcement_meth);
1578                 js_free(j_calls->ready_channel_meth);
1579                 FREE(j_calls);
1580         }
1581 }
1582 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1583         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1584         int8_tArray ret = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
1585         LDKPublicKey ret_ref;
1586         CHECK(*((uint32_t*)ret) == 33);
1587         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
1588         return ret_ref;
1589 }
1590 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1591         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1592         int8_tArray ret = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
1593         LDKThirtyTwoBytes ret_ref;
1594         CHECK(*((uint32_t*)ret) == 32);
1595         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1596         return ret_ref;
1597 }
1598 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
1599         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1600         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
1601         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
1602         CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1603         CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1604         uint64_t holder_tx_ref = (uint64_t)holder_tx_var.inner;
1605         if (holder_tx_var.is_owned) {
1606                 holder_tx_ref |= 1;
1607         }
1608         uint32_t ret = js_invoke_function_1(j_calls->validate_holder_commitment_meth, holder_tx_ref);
1609         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1);
1610         ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1));
1611         return ret_conv;
1612 }
1613 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
1614         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1615         int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth);
1616         LDKThirtyTwoBytes ret_ref;
1617         CHECK(*((uint32_t*)ret) == 32);
1618         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1619         return ret_ref;
1620 }
1621 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1622         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1623         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1624         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1625         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1626         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1627         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1628         if (commitment_tx_var.is_owned) {
1629                 commitment_tx_ref |= 1;
1630         }
1631         uint32_t ret = js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1632         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1633         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1634         return ret_conv;
1635 }
1636 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
1637         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1638         int8_tArray secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1639         memcpy((uint8_t*)(secret_arr + 4), *secret, 32);
1640         uint32_t ret = js_invoke_function_2(j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
1641         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1);
1642         ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1));
1643         return ret_conv;
1644 }
1645 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1646         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1647         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1648         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1649         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1650         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1651         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1652         if (commitment_tx_var.is_owned) {
1653                 commitment_tx_ref |= 1;
1654         }
1655         uint32_t ret = js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
1656         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
1657         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
1658         return ret_conv;
1659 }
1660 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]) {
1661         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1662         LDKTransaction justice_tx_var = justice_tx;
1663         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1664         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1665         Transaction_free(justice_tx_var);
1666         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1667         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1668         uint32_t ret = js_invoke_function_4(j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
1669         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1670         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1671         return ret_conv;
1672 }
1673 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) {
1674         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1675         LDKTransaction justice_tx_var = justice_tx;
1676         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1677         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1678         Transaction_free(justice_tx_var);
1679         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1680         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1681         LDKHTLCOutputInCommitment htlc_var = *htlc;
1682         htlc_var = HTLCOutputInCommitment_clone(htlc);
1683         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1684         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1685         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
1686         if (htlc_var.is_owned) {
1687                 htlc_ref |= 1;
1688         }
1689         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);
1690         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1691         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1692         return ret_conv;
1693 }
1694 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) {
1695         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1696         LDKTransaction htlc_tx_var = htlc_tx;
1697         int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1698         memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
1699         Transaction_free(htlc_tx_var);
1700         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1701         memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
1702         LDKHTLCOutputInCommitment htlc_var = *htlc;
1703         htlc_var = HTLCOutputInCommitment_clone(htlc);
1704         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1705         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1706         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
1707         if (htlc_var.is_owned) {
1708                 htlc_ref |= 1;
1709         }
1710         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);
1711         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1712         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1713         return ret_conv;
1714 }
1715 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
1716         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1717         LDKClosingTransaction closing_tx_var = *closing_tx;
1718         // Warning: we may need a move here but no clone is available for LDKClosingTransaction
1719         CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1720         CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1721         uint64_t closing_tx_ref = (uint64_t)closing_tx_var.inner;
1722         if (closing_tx_var.is_owned) {
1723                 closing_tx_ref |= 1;
1724         }
1725         uint32_t ret = js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_ref);
1726         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1727         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1728         return ret_conv;
1729 }
1730 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1731         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1732         LDKUnsignedChannelAnnouncement msg_var = *msg;
1733         msg_var = UnsignedChannelAnnouncement_clone(msg);
1734         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1735         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1736         uint64_t msg_ref = (uint64_t)msg_var.inner;
1737         if (msg_var.is_owned) {
1738                 msg_ref |= 1;
1739         }
1740         uint32_t ret = js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
1741         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1742         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
1743         return ret_conv;
1744 }
1745 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1746         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1747         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1748         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
1749         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1750         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1751         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
1752         if (channel_parameters_var.is_owned) {
1753                 channel_parameters_ref |= 1;
1754         }
1755         js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
1756 }
1757 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
1758         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
1759         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1760 }
1761 static inline LDKBaseSign LDKBaseSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1762         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
1763         atomic_init(&calls->refcnt, 1);
1764         //TODO: Assign calls->o from o
1765
1766         LDKChannelPublicKeys pubkeys_conv;
1767         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1768         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1769         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1770
1771         LDKBaseSign ret = {
1772                 .this_arg = (void*) calls,
1773                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
1774                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
1775                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
1776                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
1777                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
1778                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
1779                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
1780                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
1781                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
1782                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
1783                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
1784                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
1785                 .ready_channel = ready_channel_LDKBaseSign_jcall,
1786                 .free = LDKBaseSign_JCalls_free,
1787                 .pubkeys = pubkeys_conv,
1788                 .set_pubkeys = NULL,
1789         };
1790         return ret;
1791 }
1792 long  __attribute__((visibility("default"))) TS_LDKBaseSign_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1793         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
1794         *res_ptr = LDKBaseSign_init(o, pubkeys);
1795         return (long)res_ptr;
1796 }
1797 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
1798         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1799         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1800         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
1801         return ret_arr;
1802 }
1803
1804 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
1805         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1806         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1807         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
1808         return ret_arr;
1809 }
1810
1811 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_validate_holder_commitment(uint32_t this_arg, uint32_t holder_tx) {
1812         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1813         LDKHolderCommitmentTransaction holder_tx_conv;
1814         holder_tx_conv.inner = (void*)(holder_tx & (~1));
1815         holder_tx_conv.is_owned = false;
1816         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
1817         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv);
1818         return (uint64_t)ret_conv;
1819 }
1820
1821 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
1822         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1823         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1824         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
1825         return ret_arr;
1826 }
1827
1828 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
1829         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1830         LDKCommitmentTransaction commitment_tx_conv;
1831         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1832         commitment_tx_conv.is_owned = false;
1833         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1834         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1835         return (uint64_t)ret_conv;
1836 }
1837
1838 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_validate_counterparty_revocation(uint32_t this_arg, int64_t idx, int8_tArray secret) {
1839         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1840         unsigned char secret_arr[32];
1841         CHECK(*((uint32_t*)secret) == 32);
1842         memcpy(secret_arr, (uint8_t*)(secret + 4), 32);
1843         unsigned char (*secret_ref)[32] = &secret_arr;
1844         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
1845         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
1846         return (uint64_t)ret_conv;
1847 }
1848
1849 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
1850         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1851         LDKHolderCommitmentTransaction commitment_tx_conv;
1852         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1853         commitment_tx_conv.is_owned = false;
1854         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1855         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
1856         return (uint64_t)ret_conv;
1857 }
1858
1859 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) {
1860         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1861         LDKTransaction justice_tx_ref;
1862         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1863         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1864         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1865         justice_tx_ref.data_is_owned = true;
1866         unsigned char per_commitment_key_arr[32];
1867         CHECK(*((uint32_t*)per_commitment_key) == 32);
1868         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1869         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1870         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1871         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
1872         return (uint64_t)ret_conv;
1873 }
1874
1875 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) {
1876         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1877         LDKTransaction justice_tx_ref;
1878         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1879         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1880         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1881         justice_tx_ref.data_is_owned = true;
1882         unsigned char per_commitment_key_arr[32];
1883         CHECK(*((uint32_t*)per_commitment_key) == 32);
1884         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1885         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1886         LDKHTLCOutputInCommitment htlc_conv;
1887         htlc_conv.inner = (void*)(htlc & (~1));
1888         htlc_conv.is_owned = false;
1889         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1890         *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);
1891         return (uint64_t)ret_conv;
1892 }
1893
1894 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) {
1895         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1896         LDKTransaction htlc_tx_ref;
1897         htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
1898         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
1899         memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
1900         htlc_tx_ref.data_is_owned = true;
1901         LDKPublicKey per_commitment_point_ref;
1902         CHECK(*((uint32_t*)per_commitment_point) == 33);
1903         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
1904         LDKHTLCOutputInCommitment htlc_conv;
1905         htlc_conv.inner = (void*)(htlc & (~1));
1906         htlc_conv.is_owned = false;
1907         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1908         *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);
1909         return (uint64_t)ret_conv;
1910 }
1911
1912 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
1913         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1914         LDKClosingTransaction closing_tx_conv;
1915         closing_tx_conv.inner = (void*)(closing_tx & (~1));
1916         closing_tx_conv.is_owned = false;
1917         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1918         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
1919         return (uint64_t)ret_conv;
1920 }
1921
1922 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
1923         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1924         LDKUnsignedChannelAnnouncement msg_conv;
1925         msg_conv.inner = (void*)(msg & (~1));
1926         msg_conv.is_owned = false;
1927         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1928         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
1929         return (uint64_t)ret_conv;
1930 }
1931
1932 void  __attribute__((visibility("default"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
1933         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1934         LDKChannelTransactionParameters channel_parameters_conv;
1935         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
1936         channel_parameters_conv.is_owned = false;
1937         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
1938 }
1939
1940 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
1941         if (this_arg->set_pubkeys != NULL)
1942                 this_arg->set_pubkeys(this_arg);
1943         return this_arg->pubkeys;
1944 }
1945 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
1946         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
1947         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
1948         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1949         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1950         uint64_t ret_ref = (uint64_t)ret_var.inner;
1951         if (ret_var.is_owned) {
1952                 ret_ref |= 1;
1953         }
1954         return ret_ref;
1955 }
1956
1957 typedef struct LDKSign_JCalls {
1958         atomic_size_t refcnt;
1959         LDKBaseSign_JCalls* BaseSign;
1960         uint32_t write_meth;
1961 } LDKSign_JCalls;
1962 static void LDKSign_JCalls_free(void* this_arg) {
1963         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1964         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1965                 js_free(j_calls->write_meth);
1966                 FREE(j_calls);
1967         }
1968 }
1969 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
1970         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
1971         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
1972         LDKCVec_u8Z ret_ref;
1973         ret_ref.datalen = *((uint32_t*)ret);
1974         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1975         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
1976         return ret_ref;
1977 }
1978 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
1979         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
1980         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1981         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
1982 }
1983 static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* BaseSign, uint32_t pubkeys) {
1984         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
1985         atomic_init(&calls->refcnt, 1);
1986         //TODO: Assign calls->o from o
1987
1988         LDKChannelPublicKeys pubkeys_conv;
1989         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1990         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1991         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1992
1993         LDKSign ret = {
1994                 .this_arg = (void*) calls,
1995                 .write = write_LDKSign_jcall,
1996                 .cloned = LDKSign_JCalls_cloned,
1997                 .free = LDKSign_JCalls_free,
1998                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
1999         };
2000         calls->BaseSign = ret.BaseSign.this_arg;
2001         return ret;
2002 }
2003 long  __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* BaseSign, uint32_t pubkeys) {
2004         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2005         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
2006         return (long)res_ptr;
2007 }
2008 int8_tArray  __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
2009         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2010         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2011         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2012         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2013         CVec_u8Z_free(ret_var);
2014         return ret_arr;
2015 }
2016
2017 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_result_ok(uint32_t arg) {
2018         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
2019 }
2020 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) {
2021         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2022         CHECK(val->result_ok);
2023         LDKSign* res_ret =MALLOC(sizeof(LDKSign), "LDKSign");
2024         *res_ret = Sign_clone(&(*val->contents.result));
2025         return (uint64_t)res_ret;
2026 }
2027 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) {
2028         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2029         CHECK(!val->result_ok);
2030         LDKDecodeError err_var = (*val->contents.err);
2031         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2032         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2033         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2034         return err_ref;
2035 }
2036 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_result_ok(uint32_t arg) {
2037         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
2038 }
2039 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_ok(uint32_t arg) {
2040         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2041         CHECK(val->result_ok);
2042         int8_tArray es_arr = init_arr(68, sizeof(uint8_t), "Native int8_tArray Bytes");
2043         memcpy((uint8_t*)(es_arr + 4), (*val->contents.result).serialized_form, 68);
2044         return es_arr;
2045 }
2046 void  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_err(uint32_t arg) {
2047         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2048         CHECK(!val->result_ok);
2049         return *val->contents.err;
2050 }
2051 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2052         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2053         for (size_t i = 0; i < ret.datalen; i++) {
2054                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2055         }
2056         return ret;
2057 }
2058 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_result_ok(uint32_t arg) {
2059         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2060 }
2061 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t arg) {
2062         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2063         CHECK(val->result_ok);
2064         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2065         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
2066         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
2067         for (size_t m = 0; m < res_var.datalen; m++) {
2068                 LDKCVec_u8Z res_conv_12_var = res_var.data[m];
2069                 int8_tArray res_conv_12_arr = init_arr(res_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2070                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
2071                 res_arr_ptr[m] = res_conv_12_arr;
2072         }
2073         return res_arr;
2074 }
2075 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
2076         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2077         CHECK(!val->result_ok);
2078         return *val->contents.err;
2079 }
2080 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_result_ok(uint32_t arg) {
2081         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2082 }
2083 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t arg) {
2084         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2085         CHECK(val->result_ok);
2086         LDKInMemorySigner res_var = (*val->contents.result);
2087         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2088         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2089         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2090         return res_ref;
2091 }
2092 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
2093         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2094         CHECK(!val->result_ok);
2095         LDKDecodeError err_var = (*val->contents.err);
2096         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2097         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2098         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2099         return err_ref;
2100 }
2101 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tArray elems) {
2102         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2103         ret->datalen = *((uint32_t*)elems);
2104         if (ret->datalen == 0) {
2105                 ret->data = NULL;
2106         } else {
2107                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2108                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2109                 for (size_t i = 0; i < ret->datalen; i++) {
2110                         uint32_t arr_elem = java_elems[i];
2111                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
2112                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
2113                         ret->data[i] = arr_elem_conv;
2114                 }
2115         }
2116         return (uint64_t)ret;
2117 }
2118 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2119         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2120         for (size_t i = 0; i < ret.datalen; i++) {
2121                 ret.data[i] = TxOut_clone(&orig->data[i]);
2122         }
2123         return ret;
2124 }
2125 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_result_ok(uint32_t arg) {
2126         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
2127 }
2128 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_ok(uint32_t arg) {
2129         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2130         CHECK(val->result_ok);
2131         LDKTransaction res_var = (*val->contents.result);
2132         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2133         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
2134         return res_arr;
2135 }
2136 void  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_err(uint32_t arg) {
2137         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2138         CHECK(!val->result_ok);
2139         return *val->contents.err;
2140 }
2141 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
2142         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2143         LDKThirtyTwoBytes a_ref;
2144         CHECK(*((uint32_t*)a) == 32);
2145         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2146         ret->a = a_ref;
2147         LDKChannelMonitor b_conv;
2148         b_conv.inner = (void*)(b & (~1));
2149         b_conv.is_owned = (b & 1) || (b == 0);
2150         b_conv = ChannelMonitor_clone(&b_conv);
2151         ret->b = b_conv;
2152         return (uint64_t)ret;
2153 }
2154 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
2155         return ThirtyTwoBytes_clone(&tuple->a);
2156 }
2157 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t tuple) {
2158         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
2159         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2160         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_BlockHashChannelMonitorZ_get_a(tuple_conv).data, 32);
2161         return ret_arr;
2162 }
2163
2164 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
2165         return ChannelMonitor_clone(&tuple->b);
2166 }
2167 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t tuple) {
2168         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
2169         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(tuple_conv);
2170         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2171         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2172         uint64_t ret_ref = (uint64_t)ret_var.inner;
2173         if (ret_var.is_owned) {
2174                 ret_ref |= 1;
2175         }
2176         return ret_ref;
2177 }
2178
2179 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_BlockHashChannelMonitorZZ_new(uint32_tArray elems) {
2180         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
2181         ret->datalen = *((uint32_t*)elems);
2182         if (ret->datalen == 0) {
2183                 ret->data = NULL;
2184         } else {
2185                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
2186                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2187                 for (size_t i = 0; i < ret->datalen; i++) {
2188                         uint32_t arr_elem = java_elems[i];
2189                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
2190                         arr_elem_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1));
2191                         ret->data[i] = arr_elem_conv;
2192                 }
2193         }
2194         return (uint64_t)ret;
2195 }
2196 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
2197         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
2198         for (size_t i = 0; i < ret.datalen; i++) {
2199                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
2200         }
2201         return ret;
2202 }
2203 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_result_ok(uint32_t arg) {
2204         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
2205 }
2206 uint32_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(uint32_t arg) {
2207         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2208         CHECK(val->result_ok);
2209         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2210         uint32_tArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2211         uint32_t *res_arr_ptr = (uint32_t*)(res_arr + 4);
2212         for (size_t j = 0; j < res_var.datalen; j++) {
2213                 LDKC2Tuple_BlockHashChannelMonitorZ* res_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2214                 *res_conv_35_conv = res_var.data[j];
2215                 *res_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv_35_conv);
2216                 res_arr_ptr[j] = ((uint64_t)res_conv_35_conv);
2217         }
2218         return res_arr;
2219 }
2220 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(uint32_t arg) {
2221         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2222         CHECK(!val->result_ok);
2223         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
2224         return err_conv;
2225 }
2226 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u16Z_ref_from_ptr(uint32_t ptr) {
2227         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
2228         switch(obj->tag) {
2229                 case LDKCOption_u16Z_Some: {
2230                         return 0 /* LDKCOption_u16Z - Some */; (void) obj->some;
2231                 }
2232                 case LDKCOption_u16Z_None: {
2233                         return 0 /* LDKCOption_u16Z - None */;
2234                 }
2235                 default: abort();
2236         }
2237 }
2238 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
2239         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
2240         switch(obj->tag) {
2241                 case LDKAPIError_APIMisuseError: {
2242                         LDKStr err_str = obj->api_misuse_error.err;
2243                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2244                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_conv;
2245                 }
2246                 case LDKAPIError_FeeRateTooHigh: {
2247                         LDKStr err_str = obj->fee_rate_too_high.err;
2248                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2249                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_conv; (void) obj->fee_rate_too_high.feerate;
2250                 }
2251                 case LDKAPIError_RouteError: {
2252                         LDKStr err_str = obj->route_error.err;
2253                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2254                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
2255                 }
2256                 case LDKAPIError_ChannelUnavailable: {
2257                         LDKStr err_str = obj->channel_unavailable.err;
2258                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2259                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_conv;
2260                 }
2261                 case LDKAPIError_MonitorUpdateFailed: {
2262                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
2263                 }
2264                 case LDKAPIError_IncompatibleShutdownScript: {
2265                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
2266                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2267                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2268                         uint64_t script_ref = (uint64_t)script_var.inner & ~1;
2269                         return 0 /* LDKAPIError - IncompatibleShutdownScript */; (void) script_ref;
2270                 }
2271                 default: abort();
2272         }
2273 }
2274 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
2275         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
2276 }
2277 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
2278         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2279         CHECK(val->result_ok);
2280         return *val->contents.result;
2281 }
2282 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
2283         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2284         CHECK(!val->result_ok);
2285         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2286         return err_ref;
2287 }
2288 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_CResult_NoneAPIErrorZZ_new(uint32_tArray elems) {
2289         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
2290         ret->datalen = *((uint32_t*)elems);
2291         if (ret->datalen == 0) {
2292                 ret->data = NULL;
2293         } else {
2294                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
2295                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2296                 for (size_t i = 0; i < ret->datalen; i++) {
2297                         uint32_t arr_elem = java_elems[i];
2298                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
2299                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
2300                         ret->data[i] = arr_elem_conv;
2301                 }
2302         }
2303         return (uint64_t)ret;
2304 }
2305 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2306         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2307         for (size_t i = 0; i < ret.datalen; i++) {
2308                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2309         }
2310         return ret;
2311 }
2312 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_APIErrorZ_new(uint32_tArray elems) {
2313         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
2314         ret->datalen = *((uint32_t*)elems);
2315         if (ret->datalen == 0) {
2316                 ret->data = NULL;
2317         } else {
2318                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
2319                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2320                 for (size_t i = 0; i < ret->datalen; i++) {
2321                         uint32_t arr_elem = java_elems[i];
2322                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
2323                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
2324                         ret->data[i] = arr_elem_conv;
2325                 }
2326         }
2327         return (uint64_t)ret;
2328 }
2329 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2330         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2331         for (size_t i = 0; i < ret.datalen; i++) {
2332                 ret.data[i] = APIError_clone(&orig->data[i]);
2333         }
2334         return ret;
2335 }
2336 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_from_ptr(uint32_t ptr) {
2337         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
2338         switch(obj->tag) {
2339                 case LDKPaymentSendFailure_ParameterError: {
2340                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
2341                         return 0 /* LDKPaymentSendFailure - ParameterError */; (void) parameter_error_ref;
2342                 }
2343                 case LDKPaymentSendFailure_PathParameterError: {
2344                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
2345                         uint32_tArray path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2346                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(path_parameter_error_arr + 4);
2347                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
2348                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2349                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
2350                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
2351                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
2352                         }
2353                         return 0 /* LDKPaymentSendFailure - PathParameterError */; (void) path_parameter_error_arr;
2354                 }
2355                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
2356                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
2357                         uint32_tArray all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2358                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(all_failed_retry_safe_arr + 4);
2359                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
2360                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
2361                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
2362                         }
2363                         return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */; (void) all_failed_retry_safe_arr;
2364                 }
2365                 case LDKPaymentSendFailure_PartialFailure: {
2366                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
2367                         uint32_tArray partial_failure_arr = init_arr(partial_failure_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2368                         uint32_t *partial_failure_arr_ptr = (uint32_t*)(partial_failure_arr + 4);
2369                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
2370                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2371                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
2372                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
2373                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
2374                         }
2375                         return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) partial_failure_arr;
2376                 }
2377                 default: abort();
2378         }
2379 }
2380 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
2381         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
2382 }
2383 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
2384         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2385         CHECK(val->result_ok);
2386         return *val->contents.result;
2387 }
2388 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
2389         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2390         CHECK(!val->result_ok);
2391         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2392         return err_ref;
2393 }
2394 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentHashPaymentSendFailureZ_result_ok(uint32_t arg) {
2395         return ((LDKCResult_PaymentHashPaymentSendFailureZ*)arg)->result_ok;
2396 }
2397 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentHashPaymentSendFailureZ_get_ok(uint32_t arg) {
2398         LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1);
2399         CHECK(val->result_ok);
2400         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2401         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2402         return res_arr;
2403 }
2404 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentHashPaymentSendFailureZ_get_err(uint32_t arg) {
2405         LDKCResult_PaymentHashPaymentSendFailureZ *val = (LDKCResult_PaymentHashPaymentSendFailureZ*)(arg & ~1);
2406         CHECK(!val->result_ok);
2407         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2408         return err_ref;
2409 }
2410 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
2411         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
2412         switch(obj->tag) {
2413                 case LDKNetAddress_IPv4: {
2414                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
2415                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
2416                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
2417                 }
2418                 case LDKNetAddress_IPv6: {
2419                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
2420                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
2421                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
2422                 }
2423                 case LDKNetAddress_OnionV2: {
2424                         int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
2425                         memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
2426                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
2427                 }
2428                 case LDKNetAddress_OnionV3: {
2429                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2430                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
2431                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
2432                 }
2433                 default: abort();
2434         }
2435 }
2436 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
2437         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
2438         ret->datalen = *((uint32_t*)elems);
2439         if (ret->datalen == 0) {
2440                 ret->data = NULL;
2441         } else {
2442                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
2443                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2444                 for (size_t i = 0; i < ret->datalen; i++) {
2445                         uint32_t arr_elem = java_elems[i];
2446                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
2447                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
2448                         ret->data[i] = arr_elem_conv;
2449                 }
2450         }
2451         return (uint64_t)ret;
2452 }
2453 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
2454         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
2455         for (size_t i = 0; i < ret.datalen; i++) {
2456                 ret.data[i] = NetAddress_clone(&orig->data[i]);
2457         }
2458         return ret;
2459 }
2460 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
2461         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
2462         LDKThirtyTwoBytes a_ref;
2463         CHECK(*((uint32_t*)a) == 32);
2464         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2465         ret->a = a_ref;
2466         LDKThirtyTwoBytes b_ref;
2467         CHECK(*((uint32_t*)b) == 32);
2468         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
2469         ret->b = b_ref;
2470         return (uint64_t)ret;
2471 }
2472 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
2473         return ThirtyTwoBytes_clone(&tuple->a);
2474 }
2475 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t tuple) {
2476         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
2477         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2478         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentSecretZ_get_a(tuple_conv).data, 32);
2479         return ret_arr;
2480 }
2481
2482 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
2483         return ThirtyTwoBytes_clone(&tuple->b);
2484 }
2485 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t tuple) {
2486         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
2487         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2488         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentSecretZ_get_b(tuple_conv).data, 32);
2489         return ret_arr;
2490 }
2491
2492 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_result_ok(uint32_t arg) {
2493         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
2494 }
2495 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_ok(uint32_t arg) {
2496         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2497         CHECK(val->result_ok);
2498         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2499         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2500         return res_arr;
2501 }
2502 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_err(uint32_t arg) {
2503         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2504         CHECK(!val->result_ok);
2505         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2506         return err_ref;
2507 }
2508 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
2509         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
2510         ret->datalen = *((uint32_t*)elems);
2511         if (ret->datalen == 0) {
2512                 ret->data = NULL;
2513         } else {
2514                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
2515                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2516                 for (size_t i = 0; i < ret->datalen; i++) {
2517                         uint32_t arr_elem = java_elems[i];
2518                         LDKChannelMonitor arr_elem_conv;
2519                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2520                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2521                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
2522                         ret->data[i] = arr_elem_conv;
2523                 }
2524         }
2525         return (uint64_t)ret;
2526 }
2527 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2528         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2529         for (size_t i = 0; i < ret.datalen; i++) {
2530                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2531         }
2532         return ret;
2533 }
2534 typedef struct LDKWatch_JCalls {
2535         atomic_size_t refcnt;
2536         uint32_t watch_channel_meth;
2537         uint32_t update_channel_meth;
2538         uint32_t release_pending_monitor_events_meth;
2539 } LDKWatch_JCalls;
2540 static void LDKWatch_JCalls_free(void* this_arg) {
2541         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2542         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2543                 js_free(j_calls->watch_channel_meth);
2544                 js_free(j_calls->update_channel_meth);
2545                 js_free(j_calls->release_pending_monitor_events_meth);
2546                 FREE(j_calls);
2547         }
2548 }
2549 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2550         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2551         LDKOutPoint funding_txo_var = funding_txo;
2552         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2553         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2554         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
2555         if (funding_txo_var.is_owned) {
2556                 funding_txo_ref |= 1;
2557         }
2558         LDKChannelMonitor monitor_var = monitor;
2559         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2560         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2561         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
2562         if (monitor_var.is_owned) {
2563                 monitor_ref |= 1;
2564         }
2565         uint32_t ret = js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2566         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2567         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2568         return ret_conv;
2569 }
2570 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2571         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2572         LDKOutPoint funding_txo_var = funding_txo;
2573         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2574         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2575         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
2576         if (funding_txo_var.is_owned) {
2577                 funding_txo_ref |= 1;
2578         }
2579         LDKChannelMonitorUpdate update_var = update;
2580         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2581         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2582         uint64_t update_ref = (uint64_t)update_var.inner;
2583         if (update_var.is_owned) {
2584                 update_ref |= 1;
2585         }
2586         uint32_t ret = js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
2587         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
2588         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
2589         return ret_conv;
2590 }
2591 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
2592         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2593         uint32_tArray ret = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
2594         LDKCVec_MonitorEventZ ret_constr;
2595         ret_constr.datalen = *((uint32_t*)ret);
2596         if (ret_constr.datalen > 0)
2597                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2598         else
2599                 ret_constr.data = NULL;
2600         uint32_t* ret_vals = (uint32_t*)(ret + 4);
2601         for (size_t o = 0; o < ret_constr.datalen; o++) {
2602                 uint32_t ret_conv_14 = ret_vals[o];
2603                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
2604                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
2605                 ret_constr.data[o] = ret_conv_14_conv;
2606         }
2607         return ret_constr;
2608 }
2609 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
2610         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
2611         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2612 }
2613 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
2614         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2615         atomic_init(&calls->refcnt, 1);
2616         //TODO: Assign calls->o from o
2617
2618         LDKWatch ret = {
2619                 .this_arg = (void*) calls,
2620                 .watch_channel = watch_channel_LDKWatch_jcall,
2621                 .update_channel = update_channel_LDKWatch_jcall,
2622                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
2623                 .free = LDKWatch_JCalls_free,
2624         };
2625         return ret;
2626 }
2627 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
2628         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2629         *res_ptr = LDKWatch_init(o);
2630         return (long)res_ptr;
2631 }
2632 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
2633         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2634         LDKOutPoint funding_txo_conv;
2635         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2636         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2637         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2638         LDKChannelMonitor monitor_conv;
2639         monitor_conv.inner = (void*)(monitor & (~1));
2640         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
2641         monitor_conv = ChannelMonitor_clone(&monitor_conv);
2642         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2643         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
2644         return (uint64_t)ret_conv;
2645 }
2646
2647 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
2648         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2649         LDKOutPoint funding_txo_conv;
2650         funding_txo_conv.inner = (void*)(funding_txo & (~1));
2651         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
2652         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
2653         LDKChannelMonitorUpdate update_conv;
2654         update_conv.inner = (void*)(update & (~1));
2655         update_conv.is_owned = (update & 1) || (update == 0);
2656         update_conv = ChannelMonitorUpdate_clone(&update_conv);
2657         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2658         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
2659         return (uint64_t)ret_conv;
2660 }
2661
2662 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
2663         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
2664         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
2665         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2666         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
2667         for (size_t o = 0; o < ret_var.datalen; o++) {
2668                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2669                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
2670                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
2671                 ret_arr_ptr[o] = ret_conv_14_ref;
2672         }
2673         FREE(ret_var.data);
2674         return ret_arr;
2675 }
2676
2677 typedef struct LDKBroadcasterInterface_JCalls {
2678         atomic_size_t refcnt;
2679         uint32_t broadcast_transaction_meth;
2680 } LDKBroadcasterInterface_JCalls;
2681 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
2682         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2683         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2684                 js_free(j_calls->broadcast_transaction_meth);
2685                 FREE(j_calls);
2686         }
2687 }
2688 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
2689         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
2690         LDKTransaction tx_var = tx;
2691         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2692         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
2693         Transaction_free(tx_var);
2694         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
2695 }
2696 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
2697         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
2698         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2699 }
2700 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
2701         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
2702         atomic_init(&calls->refcnt, 1);
2703         //TODO: Assign calls->o from o
2704
2705         LDKBroadcasterInterface ret = {
2706                 .this_arg = (void*) calls,
2707                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
2708                 .free = LDKBroadcasterInterface_JCalls_free,
2709         };
2710         return ret;
2711 }
2712 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
2713         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
2714         *res_ptr = LDKBroadcasterInterface_init(o);
2715         return (long)res_ptr;
2716 }
2717 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
2718         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
2719         LDKTransaction tx_ref;
2720         tx_ref.datalen = *((uint32_t*)tx);
2721         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
2722         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
2723         tx_ref.data_is_owned = true;
2724         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
2725 }
2726
2727 typedef struct LDKKeysInterface_JCalls {
2728         atomic_size_t refcnt;
2729         uint32_t get_node_secret_meth;
2730         uint32_t get_destination_script_meth;
2731         uint32_t get_shutdown_scriptpubkey_meth;
2732         uint32_t get_channel_signer_meth;
2733         uint32_t get_secure_random_bytes_meth;
2734         uint32_t read_chan_signer_meth;
2735         uint32_t sign_invoice_meth;
2736 } LDKKeysInterface_JCalls;
2737 static void LDKKeysInterface_JCalls_free(void* this_arg) {
2738         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2739         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2740                 js_free(j_calls->get_node_secret_meth);
2741                 js_free(j_calls->get_destination_script_meth);
2742                 js_free(j_calls->get_shutdown_scriptpubkey_meth);
2743                 js_free(j_calls->get_channel_signer_meth);
2744                 js_free(j_calls->get_secure_random_bytes_meth);
2745                 js_free(j_calls->read_chan_signer_meth);
2746                 js_free(j_calls->sign_invoice_meth);
2747                 FREE(j_calls);
2748         }
2749 }
2750 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
2751         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2752         int8_tArray ret = js_invoke_function_0(j_calls->get_node_secret_meth);
2753         LDKSecretKey ret_ref;
2754         CHECK(*((uint32_t*)ret) == 32);
2755         memcpy(ret_ref.bytes, (uint8_t*)(ret + 4), 32);
2756         return ret_ref;
2757 }
2758 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
2759         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2760         int8_tArray ret = js_invoke_function_0(j_calls->get_destination_script_meth);
2761         LDKCVec_u8Z ret_ref;
2762         ret_ref.datalen = *((uint32_t*)ret);
2763         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2764         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
2765         return ret_ref;
2766 }
2767 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
2768         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2769         uint32_t ret = js_invoke_function_0(j_calls->get_shutdown_scriptpubkey_meth);
2770         LDKShutdownScript ret_conv;
2771         ret_conv.inner = (void*)(ret & (~1));
2772         ret_conv.is_owned = (ret & 1) || (ret == 0);
2773         ret_conv = ShutdownScript_clone(&ret_conv);
2774         return ret_conv;
2775 }
2776 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
2777         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2778         uint32_t ret = js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
2779         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
2780         ret_conv = Sign_clone(&ret_conv);
2781         return ret_conv;
2782 }
2783 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
2784         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2785         int8_tArray ret = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
2786         LDKThirtyTwoBytes ret_ref;
2787         CHECK(*((uint32_t*)ret) == 32);
2788         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
2789         return ret_ref;
2790 }
2791 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
2792         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2793         LDKu8slice reader_var = reader;
2794         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2795         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
2796         uint32_t ret = js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
2797         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
2798         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
2799         return ret_conv;
2800 }
2801 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
2802         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
2803         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
2804         int8_tArray invoice_preimage_arr = init_arr(invoice_preimage_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2805         memcpy((uint8_t*)(invoice_preimage_arr + 4), invoice_preimage_var.data, invoice_preimage_var.datalen);
2806         CVec_u8Z_free(invoice_preimage_var);
2807         uint32_t ret = js_invoke_function_1(j_calls->sign_invoice_meth, invoice_preimage_arr);
2808         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
2809         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
2810         return ret_conv;
2811 }
2812 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
2813         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
2814         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2815 }
2816 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
2817         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
2818         atomic_init(&calls->refcnt, 1);
2819         //TODO: Assign calls->o from o
2820
2821         LDKKeysInterface ret = {
2822                 .this_arg = (void*) calls,
2823                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
2824                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
2825                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
2826                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
2827                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
2828                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
2829                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
2830                 .free = LDKKeysInterface_JCalls_free,
2831         };
2832         return ret;
2833 }
2834 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
2835         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
2836         *res_ptr = LDKKeysInterface_init(o);
2837         return (long)res_ptr;
2838 }
2839 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
2840         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2841         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2842         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
2843         return ret_arr;
2844 }
2845
2846 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
2847         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2848         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
2849         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2850         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2851         CVec_u8Z_free(ret_var);
2852         return ret_arr;
2853 }
2854
2855 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
2856         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2857         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
2858         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2859         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2860         uint64_t ret_ref = (uint64_t)ret_var.inner;
2861         if (ret_var.is_owned) {
2862                 ret_ref |= 1;
2863         }
2864         return ret_ref;
2865 }
2866
2867 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
2868         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2869         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
2870         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
2871         return (uint64_t)ret_ret;
2872 }
2873
2874 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
2875         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2876         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2877         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
2878         return ret_arr;
2879 }
2880
2881 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
2882         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2883         LDKu8slice reader_ref;
2884         reader_ref.datalen = *((uint32_t*)reader);
2885         reader_ref.data = (int8_t*)(reader + 4);
2886         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
2887         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
2888         return (uint64_t)ret_conv;
2889 }
2890
2891 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
2892         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
2893         LDKCVec_u8Z invoice_preimage_ref;
2894         invoice_preimage_ref.datalen = *((uint32_t*)invoice_preimage);
2895         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
2896         memcpy(invoice_preimage_ref.data, (uint8_t*)(invoice_preimage + 4), invoice_preimage_ref.datalen);
2897         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
2898         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
2899         return (uint64_t)ret_conv;
2900 }
2901
2902 typedef struct LDKFeeEstimator_JCalls {
2903         atomic_size_t refcnt;
2904         uint32_t get_est_sat_per_1000_weight_meth;
2905 } LDKFeeEstimator_JCalls;
2906 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2907         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2908         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2909                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
2910                 FREE(j_calls);
2911         }
2912 }
2913 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2914         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2915         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
2916         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2917 }
2918 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
2919         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
2920         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2921 }
2922 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
2923         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2924         atomic_init(&calls->refcnt, 1);
2925         //TODO: Assign calls->o from o
2926
2927         LDKFeeEstimator ret = {
2928                 .this_arg = (void*) calls,
2929                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
2930                 .free = LDKFeeEstimator_JCalls_free,
2931         };
2932         return ret;
2933 }
2934 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
2935         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2936         *res_ptr = LDKFeeEstimator_init(o);
2937         return (long)res_ptr;
2938 }
2939 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
2940         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
2941         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
2942         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
2943         return ret_val;
2944 }
2945
2946 typedef struct LDKLogger_JCalls {
2947         atomic_size_t refcnt;
2948         uint32_t log_meth;
2949 } LDKLogger_JCalls;
2950 static void LDKLogger_JCalls_free(void* this_arg) {
2951         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2952         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2953                 js_free(j_calls->log_meth);
2954                 FREE(j_calls);
2955         }
2956 }
2957 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
2958         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2959         const char* record_str = record;
2960         jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
2961         js_invoke_function_1(j_calls->log_meth, record_conv);
2962 }
2963 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
2964         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
2965         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2966 }
2967 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
2968         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2969         atomic_init(&calls->refcnt, 1);
2970         //TODO: Assign calls->o from o
2971
2972         LDKLogger ret = {
2973                 .this_arg = (void*) calls,
2974                 .log = log_LDKLogger_jcall,
2975                 .free = LDKLogger_JCalls_free,
2976         };
2977         return ret;
2978 }
2979 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
2980         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2981         *res_ptr = LDKLogger_init(o);
2982         return (long)res_ptr;
2983 }
2984 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
2985         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
2986         LDKThirtyTwoBytes a_ref;
2987         CHECK(*((uint32_t*)a) == 32);
2988         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2989         ret->a = a_ref;
2990         LDKChannelManager b_conv;
2991         b_conv.inner = (void*)(b & (~1));
2992         b_conv.is_owned = (b & 1) || (b == 0);
2993         // Warning: we need a move here but no clone is available for LDKChannelManager
2994         ret->b = b_conv;
2995         return (uint64_t)ret;
2996 }
2997 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
2998         return ThirtyTwoBytes_clone(&tuple->a);
2999 }
3000 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t tuple) {
3001         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
3002         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3003         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_BlockHashChannelManagerZ_get_a(tuple_conv).data, 32);
3004         return ret_arr;
3005 }
3006
3007 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
3008         return &tuple->b;
3009 }
3010 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t tuple) {
3011         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
3012         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
3013         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3014         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3015         uint64_t ret_ref = (uint64_t)ret_var.inner & ~1;
3016         return ret_ref;
3017 }
3018
3019 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
3020         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
3021 }
3022 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
3023         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3024         CHECK(val->result_ok);
3025         LDKC2Tuple_BlockHashChannelManagerZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
3026         *res_conv = (*val->contents.result);
3027         // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
3028         return ((uint64_t)res_conv) | 1;
3029 }
3030 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
3031         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3032         CHECK(!val->result_ok);
3033         LDKDecodeError err_var = (*val->contents.err);
3034         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3035         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3036         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3037         return err_ref;
3038 }
3039 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) {
3040         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
3041 }
3042 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t arg) {
3043         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
3044         CHECK(val->result_ok);
3045         LDKChannelConfig res_var = (*val->contents.result);
3046         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3047         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3048         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3049         return res_ref;
3050 }
3051 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
3052         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
3053         CHECK(!val->result_ok);
3054         LDKDecodeError err_var = (*val->contents.err);
3055         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3056         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3057         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3058         return err_ref;
3059 }
3060 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_result_ok(uint32_t arg) {
3061         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
3062 }
3063 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_ok(uint32_t arg) {
3064         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
3065         CHECK(val->result_ok);
3066         LDKOutPoint res_var = (*val->contents.result);
3067         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3068         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3069         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3070         return res_ref;
3071 }
3072 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
3073         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
3074         CHECK(!val->result_ok);
3075         LDKDecodeError err_var = (*val->contents.err);
3076         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3077         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3078         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3079         return err_ref;
3080 }
3081 typedef struct LDKType_JCalls {
3082         atomic_size_t refcnt;
3083         uint32_t type_id_meth;
3084         uint32_t debug_str_meth;
3085         uint32_t write_meth;
3086 } LDKType_JCalls;
3087 static void LDKType_JCalls_free(void* this_arg) {
3088         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3089         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3090                 js_free(j_calls->type_id_meth);
3091                 js_free(j_calls->debug_str_meth);
3092                 js_free(j_calls->write_meth);
3093                 FREE(j_calls);
3094         }
3095 }
3096 uint16_t type_id_LDKType_jcall(const void* this_arg) {
3097         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3098         return js_invoke_function_0(j_calls->type_id_meth);
3099 }
3100 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
3101         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3102         uint32_t ret = js_invoke_function_0(j_calls->debug_str_meth);
3103         LDKStr ret_conv = str_ref_to_owned_c(ret);
3104         return ret_conv;
3105 }
3106 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
3107         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3108         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
3109         LDKCVec_u8Z ret_ref;
3110         ret_ref.datalen = *((uint32_t*)ret);
3111         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3112         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
3113         return ret_ref;
3114 }
3115 static void LDKType_JCalls_cloned(LDKType* new_obj) {
3116         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
3117         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3118 }
3119 static inline LDKType LDKType_init (/*TODO: JS Object Reference */void* o) {
3120         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
3121         atomic_init(&calls->refcnt, 1);
3122         //TODO: Assign calls->o from o
3123
3124         LDKType ret = {
3125                 .this_arg = (void*) calls,
3126                 .type_id = type_id_LDKType_jcall,
3127                 .debug_str = debug_str_LDKType_jcall,
3128                 .write = write_LDKType_jcall,
3129                 .cloned = LDKType_JCalls_cloned,
3130                 .free = LDKType_JCalls_free,
3131         };
3132         return ret;
3133 }
3134 long  __attribute__((visibility("default"))) TS_LDKType_new(/*TODO: JS Object Reference */void* o) {
3135         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
3136         *res_ptr = LDKType_init(o);
3137         return (long)res_ptr;
3138 }
3139 int16_t  __attribute__((visibility("default"))) TS_Type_type_id(uint32_t this_arg) {
3140         LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
3141         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
3142         return ret_val;
3143 }
3144
3145 jstring  __attribute__((visibility("default"))) TS_Type_debug_str(uint32_t this_arg) {
3146         LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
3147         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
3148         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
3149         Str_free(ret_str);
3150         return ret_conv;
3151 }
3152
3153 int8_tArray  __attribute__((visibility("default"))) TS_Type_write(uint32_t this_arg) {
3154         LDKType* this_arg_conv = (LDKType*)(((uint64_t)this_arg) & ~1);
3155         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3156         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3157         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3158         CVec_u8Z_free(ret_var);
3159         return ret_arr;
3160 }
3161
3162 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_TypeZ_ref_from_ptr(uint32_t ptr) {
3163         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
3164         switch(obj->tag) {
3165                 case LDKCOption_TypeZ_Some: {
3166                         LDKType* some_ret =MALLOC(sizeof(LDKType), "LDKType");
3167                         *some_ret = Type_clone(&obj->some);
3168                         return 0 /* LDKCOption_TypeZ - Some */; (void) (uint64_t)some_ret;
3169                 }
3170                 case LDKCOption_TypeZ_None: {
3171                         return 0 /* LDKCOption_TypeZ - None */;
3172                 }
3173                 default: abort();
3174         }
3175 }
3176 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_result_ok(uint32_t arg) {
3177         return ((LDKCResult_COption_TypeZDecodeErrorZ*)arg)->result_ok;
3178 }
3179 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t arg) {
3180         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
3181         CHECK(val->result_ok);
3182         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3183         return res_ref;
3184 }
3185 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_err(uint32_t arg) {
3186         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
3187         CHECK(!val->result_ok);
3188         LDKDecodeError err_var = (*val->contents.err);
3189         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3190         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3191         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3192         return err_ref;
3193 }
3194 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_result_ok(uint32_t arg) {
3195         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
3196 }
3197 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_ok(uint32_t arg) {
3198         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
3199         CHECK(val->result_ok);
3200         uint32_t res_conv = LDKSiPrefix_to_js((*val->contents.result));
3201         return res_conv;
3202 }
3203 void  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_err(uint32_t arg) {
3204         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
3205         CHECK(!val->result_ok);
3206         return *val->contents.err;
3207 }
3208 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_result_ok(uint32_t arg) {
3209         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
3210 }
3211 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_ok(uint32_t arg) {
3212         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
3213         CHECK(val->result_ok);
3214         LDKInvoice res_var = (*val->contents.result);
3215         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3216         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3217         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3218         return res_ref;
3219 }
3220 void  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_err(uint32_t arg) {
3221         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
3222         CHECK(!val->result_ok);
3223         return *val->contents.err;
3224 }
3225 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_result_ok(uint32_t arg) {
3226         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
3227 }
3228 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_ok(uint32_t arg) {
3229         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
3230         CHECK(val->result_ok);
3231         LDKSignedRawInvoice res_var = (*val->contents.result);
3232         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3233         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3234         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3235         return res_ref;
3236 }
3237 void  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_err(uint32_t arg) {
3238         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
3239         CHECK(!val->result_ok);
3240         return *val->contents.err;
3241 }
3242 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
3243         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
3244         LDKRawInvoice a_conv;
3245         a_conv.inner = (void*)(a & (~1));
3246         a_conv.is_owned = (a & 1) || (a == 0);
3247         a_conv = RawInvoice_clone(&a_conv);
3248         ret->a = a_conv;
3249         LDKThirtyTwoBytes b_ref;
3250         CHECK(*((uint32_t*)b) == 32);
3251         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
3252         ret->b = b_ref;
3253         LDKInvoiceSignature c_conv;
3254         c_conv.inner = (void*)(c & (~1));
3255         c_conv.is_owned = (c & 1) || (c == 0);
3256         c_conv = InvoiceSignature_clone(&c_conv);
3257         ret->c = c_conv;
3258         return (uint64_t)ret;
3259 }
3260 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
3261         return RawInvoice_clone(&tuple->a);
3262 }
3263 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t tuple) {
3264         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
3265         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
3266         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3267         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3268         uint64_t ret_ref = (uint64_t)ret_var.inner;
3269         if (ret_var.is_owned) {
3270                 ret_ref |= 1;
3271         }
3272         return ret_ref;
3273 }
3274
3275 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
3276         return ThirtyTwoBytes_clone(&tuple->b);
3277 }
3278 int8_tArray  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t tuple) {
3279         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
3280         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3281         memcpy((uint8_t*)(ret_arr + 4), C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(tuple_conv).data, 32);
3282         return ret_arr;
3283 }
3284
3285 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
3286         return InvoiceSignature_clone(&tuple->c);
3287 }
3288 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t tuple) {
3289         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
3290         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
3291         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3292         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3293         uint64_t ret_ref = (uint64_t)ret_var.inner;
3294         if (ret_var.is_owned) {
3295                 ret_ref |= 1;
3296         }
3297         return ret_ref;
3298 }
3299
3300 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_result_ok(uint32_t arg) {
3301         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
3302 }
3303 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_ok(uint32_t arg) {
3304         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
3305         CHECK(val->result_ok);
3306         LDKPayeePubKey res_var = (*val->contents.result);
3307         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3308         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3309         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3310         return res_ref;
3311 }
3312 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_err(uint32_t arg) {
3313         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
3314         CHECK(!val->result_ok);
3315         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3316         return err_conv;
3317 }
3318 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_PrivateRouteZ_new(uint32_tArray elems) {
3319         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
3320         ret->datalen = *((uint32_t*)elems);
3321         if (ret->datalen == 0) {
3322                 ret->data = NULL;
3323         } else {
3324                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
3325                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3326                 for (size_t i = 0; i < ret->datalen; i++) {
3327                         uint32_t arr_elem = java_elems[i];
3328                         LDKPrivateRoute arr_elem_conv;
3329                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3330                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3331                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
3332                         ret->data[i] = arr_elem_conv;
3333                 }
3334         }
3335         return (uint64_t)ret;
3336 }
3337 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
3338         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
3339         for (size_t i = 0; i < ret.datalen; i++) {
3340                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
3341         }
3342         return ret;
3343 }
3344 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_result_ok(uint32_t arg) {
3345         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
3346 }
3347 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t arg) {
3348         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
3349         CHECK(val->result_ok);
3350         LDKPositiveTimestamp res_var = (*val->contents.result);
3351         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3352         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3353         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3354         return res_ref;
3355 }
3356 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_err(uint32_t arg) {
3357         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
3358         CHECK(!val->result_ok);
3359         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3360         return err_conv;
3361 }
3362 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_result_ok(uint32_t arg) {
3363         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
3364 }
3365 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_ok(uint32_t arg) {
3366         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3367         CHECK(val->result_ok);
3368         return *val->contents.result;
3369 }
3370 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_err(uint32_t arg) {
3371         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3372         CHECK(!val->result_ok);
3373         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3374         return err_conv;
3375 }
3376 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_result_ok(uint32_t arg) {
3377         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
3378 }
3379 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_ok(uint32_t arg) {
3380         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3381         CHECK(val->result_ok);
3382         LDKInvoice res_var = (*val->contents.result);
3383         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3384         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3385         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3386         return res_ref;
3387 }
3388 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_err(uint32_t arg) {
3389         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3390         CHECK(!val->result_ok);
3391         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3392         return err_conv;
3393 }
3394 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_result_ok(uint32_t arg) {
3395         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
3396 }
3397 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_ok(uint32_t arg) {
3398         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3399         CHECK(val->result_ok);
3400         LDKDescription res_var = (*val->contents.result);
3401         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3402         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3403         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3404         return res_ref;
3405 }
3406 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_err(uint32_t arg) {
3407         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3408         CHECK(!val->result_ok);
3409         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3410         return err_conv;
3411 }
3412 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_result_ok(uint32_t arg) {
3413         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
3414 }
3415 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_ok(uint32_t arg) {
3416         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3417         CHECK(val->result_ok);
3418         LDKExpiryTime res_var = (*val->contents.result);
3419         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3420         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3421         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3422         return res_ref;
3423 }
3424 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_err(uint32_t arg) {
3425         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3426         CHECK(!val->result_ok);
3427         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3428         return err_conv;
3429 }
3430 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_result_ok(uint32_t arg) {
3431         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
3432 }
3433 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_ok(uint32_t arg) {
3434         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3435         CHECK(val->result_ok);
3436         LDKPrivateRoute res_var = (*val->contents.result);
3437         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3438         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3439         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3440         return res_ref;
3441 }
3442 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_err(uint32_t arg) {
3443         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3444         CHECK(!val->result_ok);
3445         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3446         return err_conv;
3447 }
3448 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_result_ok(uint32_t arg) {
3449         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
3450 }
3451 jstring  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_ok(uint32_t arg) {
3452         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3453         CHECK(val->result_ok);
3454         LDKStr res_str = (*val->contents.result);
3455         jstring res_conv = str_ref_to_ts(res_str.chars, res_str.len);
3456         return res_conv;
3457 }
3458 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_err(uint32_t arg) {
3459         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3460         CHECK(!val->result_ok);
3461         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3462         return err_conv;
3463 }
3464 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3465         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
3466 }
3467 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3468         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3469         CHECK(val->result_ok);
3470         LDKChannelMonitorUpdate res_var = (*val->contents.result);
3471         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3472         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3473         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3474         return res_ref;
3475 }
3476 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
3477         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3478         CHECK(!val->result_ok);
3479         LDKDecodeError err_var = (*val->contents.err);
3480         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3481         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3482         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3483         return err_ref;
3484 }
3485 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_result_ok(uint32_t arg) {
3486         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
3487 }
3488 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3489         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3490         CHECK(val->result_ok);
3491         LDKHTLCUpdate res_var = (*val->contents.result);
3492         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3493         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3494         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
3495         return res_ref;
3496 }
3497 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
3498         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3499         CHECK(!val->result_ok);
3500         LDKDecodeError err_var = (*val->contents.err);
3501         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3502         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3503         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3504         return err_ref;
3505 }
3506 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
3507         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
3508 }
3509 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
3510         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3511         CHECK(val->result_ok);
3512         return *val->contents.result;
3513 }
3514 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
3515         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
3516         CHECK(!val->result_ok);
3517         LDKMonitorUpdateError err_var = (*val->contents.err);
3518         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3519         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3520         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
3521         return err_ref;
3522 }
3523 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
3524         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
3525         LDKOutPoint a_conv;
3526         a_conv.inner = (void*)(a & (~1));
3527         a_conv.is_owned = (a & 1) || (a == 0);
3528         a_conv = OutPoint_clone(&a_conv);
3529         ret->a = a_conv;
3530         LDKCVec_u8Z b_ref;
3531         b_ref.datalen = *((uint32_t*)b);
3532         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3533         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
3534         ret->b = b_ref;
3535         return (uint64_t)ret;
3536 }
3537 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
3538         return OutPoint_clone(&tuple->a);
3539 }
3540 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t tuple) {
3541         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
3542         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
3543         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3544         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3545         uint64_t ret_ref = (uint64_t)ret_var.inner;
3546         if (ret_var.is_owned) {
3547                 ret_ref |= 1;
3548         }
3549         return ret_ref;
3550 }
3551
3552 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
3553         return CVec_u8Z_clone(&tuple->b);
3554 }
3555 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t tuple) {
3556         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
3557         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(tuple_conv);
3558         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3559         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3560         CVec_u8Z_free(ret_var);
3561         return ret_arr;
3562 }
3563
3564 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
3565         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
3566         ret->a = a;
3567         LDKCVec_u8Z b_ref;
3568         b_ref.datalen = *((uint32_t*)b);
3569         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3570         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
3571         ret->b = b_ref;
3572         return (uint64_t)ret;
3573 }
3574 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
3575         return tuple->a;
3576 }
3577 int32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t tuple) {
3578         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
3579         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(tuple_conv);
3580         return ret_val;
3581 }
3582
3583 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
3584         return CVec_u8Z_clone(&tuple->b);
3585 }
3586 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t tuple) {
3587         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
3588         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(tuple_conv);
3589         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3590         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3591         CVec_u8Z_free(ret_var);
3592         return ret_arr;
3593 }
3594
3595 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32ScriptZZ_new(uint32_tArray elems) {
3596         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
3597         ret->datalen = *((uint32_t*)elems);
3598         if (ret->datalen == 0) {
3599                 ret->data = NULL;
3600         } else {
3601                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
3602                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3603                 for (size_t i = 0; i < ret->datalen; i++) {
3604                         uint32_t arr_elem = java_elems[i];
3605                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
3606                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
3607                         ret->data[i] = arr_elem_conv;
3608                 }
3609         }
3610         return (uint64_t)ret;
3611 }
3612 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
3613         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
3614         for (size_t i = 0; i < ret.datalen; i++) {
3615                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
3616         }
3617         return ret;
3618 }
3619 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
3620         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
3621         LDKThirtyTwoBytes a_ref;
3622         CHECK(*((uint32_t*)a) == 32);
3623         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3624         ret->a = a_ref;
3625         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
3626         b_constr.datalen = *((uint32_t*)b);
3627         if (b_constr.datalen > 0)
3628                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
3629         else
3630                 b_constr.data = NULL;
3631         uint32_t* b_vals = (uint32_t*)(b + 4);
3632         for (size_t v = 0; v < b_constr.datalen; v++) {
3633                 uint32_t b_conv_21 = b_vals[v];
3634                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1);
3635                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
3636                 b_constr.data[v] = b_conv_21_conv;
3637         }
3638         ret->b = b_constr;
3639         return (uint64_t)ret;
3640 }
3641 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
3642         return ThirtyTwoBytes_clone(&tuple->a);
3643 }
3644 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t tuple) {
3645         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
3646         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3647         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(tuple_conv).data, 32);
3648         return ret_arr;
3649 }
3650
3651 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
3652         return CVec_C2Tuple_u32ScriptZZ_clone(&tuple->b);
3653 }
3654 uint32_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t tuple) {
3655         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
3656         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
3657         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3658         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3659         for (size_t v = 0; v < ret_var.datalen; v++) {
3660                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
3661                 *ret_conv_21_conv = ret_var.data[v];
3662                 ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv);
3663         }
3664         FREE(ret_var.data);
3665         return ret_arr;
3666 }
3667
3668 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_new(uint32_tArray elems) {
3669         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
3670         ret->datalen = *((uint32_t*)elems);
3671         if (ret->datalen == 0) {
3672                 ret->data = NULL;
3673         } else {
3674                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
3675                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3676                 for (size_t i = 0; i < ret->datalen; i++) {
3677                         uint32_t arr_elem = java_elems[i];
3678                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
3679                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
3680                         ret->data[i] = arr_elem_conv;
3681                 }
3682         }
3683         return (uint64_t)ret;
3684 }
3685 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
3686         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 };
3687         for (size_t i = 0; i < ret.datalen; i++) {
3688                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
3689         }
3690         return ret;
3691 }
3692 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentPurpose_ref_from_ptr(uint32_t ptr) {
3693         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
3694         switch(obj->tag) {
3695                 case LDKPaymentPurpose_InvoicePayment: {
3696                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3697                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->invoice_payment.payment_preimage.data, 32);
3698                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3699                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->invoice_payment.payment_secret.data, 32);
3700                         return 0 /* LDKPaymentPurpose - InvoicePayment */; (void) payment_preimage_arr; (void) payment_secret_arr; (void) obj->invoice_payment.user_payment_id;
3701                 }
3702                 case LDKPaymentPurpose_SpontaneousPayment: {
3703                         int8_tArray spontaneous_payment_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3704                         memcpy((uint8_t*)(spontaneous_payment_arr + 4), obj->spontaneous_payment.data, 32);
3705                         return 0 /* LDKPaymentPurpose - SpontaneousPayment */; (void) spontaneous_payment_arr;
3706                 }
3707                 default: abort();
3708         }
3709 }
3710 uint32_t __attribute__((visibility("default"))) TS_LDKClosureReason_ref_from_ptr(uint32_t ptr) {
3711         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
3712         switch(obj->tag) {
3713                 case LDKClosureReason_CounterpartyForceClosed: {
3714                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
3715                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
3716                         return 0 /* LDKClosureReason - CounterpartyForceClosed */; (void) peer_msg_conv;
3717                 }
3718                 case LDKClosureReason_HolderForceClosed: {
3719                         return 0 /* LDKClosureReason - HolderForceClosed */;
3720                 }
3721                 case LDKClosureReason_CooperativeClosure: {
3722                         return 0 /* LDKClosureReason - CooperativeClosure */;
3723                 }
3724                 case LDKClosureReason_CommitmentTxConfirmed: {
3725                         return 0 /* LDKClosureReason - CommitmentTxConfirmed */;
3726                 }
3727                 case LDKClosureReason_ProcessingError: {
3728                         LDKStr err_str = obj->processing_error.err;
3729                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3730                         return 0 /* LDKClosureReason - ProcessingError */; (void) err_conv;
3731                 }
3732                 case LDKClosureReason_DisconnectedPeer: {
3733                         return 0 /* LDKClosureReason - DisconnectedPeer */;
3734                 }
3735                 case LDKClosureReason_OutdatedChannelManager: {
3736                         return 0 /* LDKClosureReason - OutdatedChannelManager */;
3737                 }
3738                 default: abort();
3739         }
3740 }
3741 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
3742         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
3743         switch(obj->tag) {
3744                 case LDKEvent_FundingGenerationReady: {
3745                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3746                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
3747                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
3748                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3749                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
3750                         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;
3751                 }
3752                 case LDKEvent_PaymentReceived: {
3753                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3754                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
3755                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
3756                         return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) obj->payment_received.amt; (void) purpose_ref;
3757                 }
3758                 case LDKEvent_PaymentSent: {
3759                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3760                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
3761                         return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr;
3762                 }
3763                 case LDKEvent_PaymentPathFailed: {
3764                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3765                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_path_failed.payment_hash.data, 32);
3766                         uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
3767                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
3768                         uint32_tArray path_arr = init_arr(path_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3769                         uint32_t *path_arr_ptr = (uint32_t*)(path_arr + 4);
3770                         for (size_t k = 0; k < path_var.datalen; k++) {
3771                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3772                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3773                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3774                                 uint64_t path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
3775                                 path_arr_ptr[k] = path_conv_10_ref;
3776                         }
3777                         return 0 /* LDKEvent - PaymentPathFailed */; (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;
3778                 }
3779                 case LDKEvent_PendingHTLCsForwardable: {
3780                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
3781                 }
3782                 case LDKEvent_SpendableOutputs: {
3783                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
3784                         uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3785                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
3786                         for (size_t b = 0; b < outputs_var.datalen; b++) {
3787                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
3788                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
3789                         }
3790                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
3791                 }
3792                 case LDKEvent_PaymentForwarded: {
3793                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
3794                         return 0 /* LDKEvent - PaymentForwarded */; (void) fee_earned_msat_ref; (void) obj->payment_forwarded.claim_from_onchain_tx;
3795                 }
3796                 case LDKEvent_ChannelClosed: {
3797                         int8_tArray channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3798                         memcpy((uint8_t*)(channel_id_arr + 4), obj->channel_closed.channel_id.data, 32);
3799                         uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
3800                         return 0 /* LDKEvent - ChannelClosed */; (void) channel_id_arr; (void) reason_ref;
3801                 }
3802                 default: abort();
3803         }
3804 }
3805 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
3806         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
3807         ret->datalen = *((uint32_t*)elems);
3808         if (ret->datalen == 0) {
3809                 ret->data = NULL;
3810         } else {
3811                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
3812                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3813                 for (size_t i = 0; i < ret->datalen; i++) {
3814                         uint32_t arr_elem = java_elems[i];
3815                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
3816                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
3817                         ret->data[i] = arr_elem_conv;
3818                 }
3819         }
3820         return (uint64_t)ret;
3821 }
3822 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
3823         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
3824         for (size_t i = 0; i < ret.datalen; i++) {
3825                 ret.data[i] = Event_clone(&orig->data[i]);
3826         }
3827         return ret;
3828 }
3829 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
3830         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
3831         ret->a = a;
3832         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
3833         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
3834         ret->b = b_conv;
3835         return (uint64_t)ret;
3836 }
3837 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
3838         return tuple->a;
3839 }
3840 int32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t tuple) {
3841         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
3842         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(tuple_conv);
3843         return ret_val;
3844 }
3845
3846 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
3847         return TxOut_clone(&tuple->b);
3848 }
3849 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t tuple) {
3850         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
3851         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3852         *ret_ref = C2Tuple_u32TxOutZ_get_b(tuple_conv);
3853         return (uint64_t)ret_ref;
3854 }
3855
3856 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
3857         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
3858         ret->datalen = *((uint32_t*)elems);
3859         if (ret->datalen == 0) {
3860                 ret->data = NULL;
3861         } else {
3862                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
3863                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3864                 for (size_t i = 0; i < ret->datalen; i++) {
3865                         uint32_t arr_elem = java_elems[i];
3866                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
3867                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
3868                         ret->data[i] = arr_elem_conv;
3869                 }
3870         }
3871         return (uint64_t)ret;
3872 }
3873 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
3874         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
3875         for (size_t i = 0; i < ret.datalen; i++) {
3876                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
3877         }
3878         return ret;
3879 }
3880 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
3881         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
3882         LDKThirtyTwoBytes a_ref;
3883         CHECK(*((uint32_t*)a) == 32);
3884         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
3885         ret->a = a_ref;
3886         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
3887         b_constr.datalen = *((uint32_t*)b);
3888         if (b_constr.datalen > 0)
3889                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
3890         else
3891                 b_constr.data = NULL;
3892         uint32_t* b_vals = (uint32_t*)(b + 4);
3893         for (size_t u = 0; u < b_constr.datalen; u++) {
3894                 uint32_t b_conv_20 = b_vals[u];
3895                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1);
3896                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
3897                 b_constr.data[u] = b_conv_20_conv;
3898         }
3899         ret->b = b_constr;
3900         return (uint64_t)ret;
3901 }
3902 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
3903         return ThirtyTwoBytes_clone(&tuple->a);
3904 }
3905 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t tuple) {
3906         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
3907         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3908         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(tuple_conv).data, 32);
3909         return ret_arr;
3910 }
3911
3912 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
3913         return CVec_C2Tuple_u32TxOutZZ_clone(&tuple->b);
3914 }
3915 uint32_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t tuple) {
3916         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
3917         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
3918         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3919         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3920         for (size_t u = 0; u < ret_var.datalen; u++) {
3921                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
3922                 *ret_conv_20_conv = ret_var.data[u];
3923                 ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
3924         }
3925         FREE(ret_var.data);
3926         return ret_arr;
3927 }
3928
3929 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
3930         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
3931         ret->datalen = *((uint32_t*)elems);
3932         if (ret->datalen == 0) {
3933                 ret->data = NULL;
3934         } else {
3935                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
3936                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3937                 for (size_t i = 0; i < ret->datalen; i++) {
3938                         uint32_t arr_elem = java_elems[i];
3939                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
3940                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
3941                         ret->data[i] = arr_elem_conv;
3942                 }
3943         }
3944         return (uint64_t)ret;
3945 }
3946 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
3947         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 };
3948         for (size_t i = 0; i < ret.datalen; i++) {
3949                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
3950         }
3951         return ret;
3952 }
3953 uint32_t __attribute__((visibility("default"))) TS_LDKBalance_ref_from_ptr(uint32_t ptr) {
3954         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
3955         switch(obj->tag) {
3956                 case LDKBalance_ClaimableOnChannelClose: {
3957                         return 0 /* LDKBalance - ClaimableOnChannelClose */; (void) obj->claimable_on_channel_close.claimable_amount_satoshis;
3958                 }
3959                 case LDKBalance_ClaimableAwaitingConfirmations: {
3960                         return 0 /* LDKBalance - ClaimableAwaitingConfirmations */; (void) obj->claimable_awaiting_confirmations.claimable_amount_satoshis; (void) obj->claimable_awaiting_confirmations.confirmation_height;
3961                 }
3962                 case LDKBalance_ContentiousClaimable: {
3963                         return 0 /* LDKBalance - ContentiousClaimable */; (void) obj->contentious_claimable.claimable_amount_satoshis; (void) obj->contentious_claimable.timeout_height;
3964                 }
3965                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
3966                         return 0 /* LDKBalance - MaybeClaimableHTLCAwaitingTimeout */; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
3967                 }
3968                 default: abort();
3969         }
3970 }
3971 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_BalanceZ_new(uint32_tArray elems) {
3972         LDKCVec_BalanceZ *ret = MALLOC(sizeof(LDKCVec_BalanceZ), "LDKCVec_BalanceZ");
3973         ret->datalen = *((uint32_t*)elems);
3974         if (ret->datalen == 0) {
3975                 ret->data = NULL;
3976         } else {
3977                 ret->data = MALLOC(sizeof(LDKBalance) * ret->datalen, "LDKCVec_BalanceZ Data");
3978                 uint32_t *java_elems = (uint32_t*)(elems + 4);
3979                 for (size_t i = 0; i < ret->datalen; i++) {
3980                         uint32_t arr_elem = java_elems[i];
3981                         LDKBalance arr_elem_conv = *(LDKBalance*)(((uint64_t)arr_elem) & ~1);
3982                         arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1));
3983                         ret->data[i] = arr_elem_conv;
3984                 }
3985         }
3986         return (uint64_t)ret;
3987 }
3988 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
3989         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
3990         for (size_t i = 0; i < ret.datalen; i++) {
3991                 ret.data[i] = Balance_clone(&orig->data[i]);
3992         }
3993         return ret;
3994 }
3995 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
3996         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
3997 }
3998 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
3999         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4000         CHECK(val->result_ok);
4001         LDKC2Tuple_BlockHashChannelMonitorZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
4002         *res_conv = (*val->contents.result);
4003         *res_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv);
4004         return ((uint64_t)res_conv);
4005 }
4006 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
4007         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4008         CHECK(!val->result_ok);
4009         LDKDecodeError err_var = (*val->contents.err);
4010         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4011         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4012         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4013         return err_ref;
4014 }
4015 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
4016         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
4017 }
4018 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
4019         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
4020         CHECK(val->result_ok);
4021         return *val->contents.result;
4022 }
4023 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
4024         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
4025         CHECK(!val->result_ok);
4026         LDKLightningError err_var = (*val->contents.err);
4027         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4028         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4029         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4030         return err_ref;
4031 }
4032 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
4033         LDKC2Tuple_PublicKeyTypeZ* ret = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
4034         LDKPublicKey a_ref;
4035         CHECK(*((uint32_t*)a) == 33);
4036         memcpy(a_ref.compressed_form, (uint8_t*)(a + 4), 33);
4037         ret->a = a_ref;
4038         LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1);
4039         b_conv = Type_clone(&b_conv);
4040         ret->b = b_conv;
4041         return (uint64_t)ret;
4042 }
4043 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
4044         return tuple->a;
4045 }
4046 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t tuple) {
4047         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
4048         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4049         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PublicKeyTypeZ_get_a(tuple_conv).compressed_form, 33);
4050         return ret_arr;
4051 }
4052
4053 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
4054         return Type_clone(&tuple->b);
4055 }
4056 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t tuple) {
4057         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
4058         LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType");
4059         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
4060         return (uint64_t)ret_ret;
4061 }
4062
4063 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_PublicKeyTypeZZ_new(uint32_tArray elems) {
4064         LDKCVec_C2Tuple_PublicKeyTypeZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_PublicKeyTypeZZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ");
4065         ret->datalen = *((uint32_t*)elems);
4066         if (ret->datalen == 0) {
4067                 ret->data = NULL;
4068         } else {
4069                 ret->data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * ret->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ Data");
4070                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4071                 for (size_t i = 0; i < ret->datalen; i++) {
4072                         uint32_t arr_elem = java_elems[i];
4073                         LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1);
4074                         arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1));
4075                         ret->data[i] = arr_elem_conv;
4076                 }
4077         }
4078         return (uint64_t)ret;
4079 }
4080 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
4081         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
4082         for (size_t i = 0; i < ret.datalen; i++) {
4083                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
4084         }
4085         return ret;
4086 }
4087 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) {
4088         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
4089 }
4090 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
4091         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4092         CHECK(val->result_ok);
4093         return *val->contents.result;
4094 }
4095 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
4096         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4097         CHECK(!val->result_ok);
4098         LDKLightningError err_var = (*val->contents.err);
4099         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4100         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4101         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4102         return err_ref;
4103 }
4104 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
4105         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4106         LDKChannelAnnouncement a_conv;
4107         a_conv.inner = (void*)(a & (~1));
4108         a_conv.is_owned = (a & 1) || (a == 0);
4109         a_conv = ChannelAnnouncement_clone(&a_conv);
4110         ret->a = a_conv;
4111         LDKChannelUpdate b_conv;
4112         b_conv.inner = (void*)(b & (~1));
4113         b_conv.is_owned = (b & 1) || (b == 0);
4114         b_conv = ChannelUpdate_clone(&b_conv);
4115         ret->b = b_conv;
4116         LDKChannelUpdate c_conv;
4117         c_conv.inner = (void*)(c & (~1));
4118         c_conv.is_owned = (c & 1) || (c == 0);
4119         c_conv = ChannelUpdate_clone(&c_conv);
4120         ret->c = c_conv;
4121         return (uint64_t)ret;
4122 }
4123 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
4124         return ChannelAnnouncement_clone(&tuple->a);
4125 }
4126 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t tuple) {
4127         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
4128         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
4129         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4130         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4131         uint64_t 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 struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
4139         return ChannelUpdate_clone(&tuple->b);
4140 }
4141 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t tuple) {
4142         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
4143         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
4144         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4145         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4146         uint64_t ret_ref = (uint64_t)ret_var.inner;
4147         if (ret_var.is_owned) {
4148                 ret_ref |= 1;
4149         }
4150         return ret_ref;
4151 }
4152
4153 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
4154         return ChannelUpdate_clone(&tuple->c);
4155 }
4156 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t tuple) {
4157         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
4158         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
4159         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4160         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4161         uint64_t ret_ref = (uint64_t)ret_var.inner;
4162         if (ret_var.is_owned) {
4163                 ret_ref |= 1;
4164         }
4165         return ret_ref;
4166 }
4167
4168 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(uint32_tArray elems) {
4169         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
4170         ret->datalen = *((uint32_t*)elems);
4171         if (ret->datalen == 0) {
4172                 ret->data = NULL;
4173         } else {
4174                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
4175                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4176                 for (size_t i = 0; i < ret->datalen; i++) {
4177                         uint32_t arr_elem = java_elems[i];
4178                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
4179                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
4180                         ret->data[i] = arr_elem_conv;
4181                 }
4182         }
4183         return (uint64_t)ret;
4184 }
4185 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
4186         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
4187         for (size_t i = 0; i < ret.datalen; i++) {
4188                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
4189         }
4190         return ret;
4191 }
4192 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NodeAnnouncementZ_new(uint32_tArray elems) {
4193         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
4194         ret->datalen = *((uint32_t*)elems);
4195         if (ret->datalen == 0) {
4196                 ret->data = NULL;
4197         } else {
4198                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
4199                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4200                 for (size_t i = 0; i < ret->datalen; i++) {
4201                         uint32_t arr_elem = java_elems[i];
4202                         LDKNodeAnnouncement arr_elem_conv;
4203                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4204                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4205                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
4206                         ret->data[i] = arr_elem_conv;
4207                 }
4208         }
4209         return (uint64_t)ret;
4210 }
4211 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
4212         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
4213         for (size_t i = 0; i < ret.datalen; i++) {
4214                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
4215         }
4216         return ret;
4217 }
4218 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) {
4219         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
4220 }
4221 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
4222         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4223         CHECK(val->result_ok);
4224         LDKCVec_u8Z res_var = (*val->contents.result);
4225         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4226         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
4227         return res_arr;
4228 }
4229 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
4230         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4231         CHECK(!val->result_ok);
4232         LDKPeerHandleError err_var = (*val->contents.err);
4233         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4234         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4235         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4236         return err_ref;
4237 }
4238 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
4239         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
4240 }
4241 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
4242         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4243         CHECK(val->result_ok);
4244         return *val->contents.result;
4245 }
4246 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
4247         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4248         CHECK(!val->result_ok);
4249         LDKPeerHandleError err_var = (*val->contents.err);
4250         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4251         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4252         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4253         return err_ref;
4254 }
4255 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
4256         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
4257 }
4258 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
4259         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4260         CHECK(val->result_ok);
4261         return *val->contents.result;
4262 }
4263 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
4264         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4265         CHECK(!val->result_ok);
4266         LDKPeerHandleError err_var = (*val->contents.err);
4267         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4268         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4269         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4270         return err_ref;
4271 }
4272 typedef struct LDKAccess_JCalls {
4273         atomic_size_t refcnt;
4274         uint32_t get_utxo_meth;
4275 } LDKAccess_JCalls;
4276 static void LDKAccess_JCalls_free(void* this_arg) {
4277         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4278         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4279                 js_free(j_calls->get_utxo_meth);
4280                 FREE(j_calls);
4281         }
4282 }
4283 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4284         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4285         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4286         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
4287         uint32_t ret = js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4288         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
4289         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
4290         return ret_conv;
4291 }
4292 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
4293         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
4294         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4295 }
4296 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
4297         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4298         atomic_init(&calls->refcnt, 1);
4299         //TODO: Assign calls->o from o
4300
4301         LDKAccess ret = {
4302                 .this_arg = (void*) calls,
4303                 .get_utxo = get_utxo_LDKAccess_jcall,
4304                 .free = LDKAccess_JCalls_free,
4305         };
4306         return ret;
4307 }
4308 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
4309         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4310         *res_ptr = LDKAccess_init(o);
4311         return (long)res_ptr;
4312 }
4313 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
4314         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
4315         unsigned char genesis_hash_arr[32];
4316         CHECK(*((uint32_t*)genesis_hash) == 32);
4317         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
4318         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4319         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4320         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4321         return (uint64_t)ret_conv;
4322 }
4323
4324 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_AccessZ_ref_from_ptr(uint32_t ptr) {
4325         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
4326         switch(obj->tag) {
4327                 case LDKCOption_AccessZ_Some: {
4328                         LDKAccess* some_ret =MALLOC(sizeof(LDKAccess), "LDKAccess");
4329                         *some_ret = obj->some;
4330                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
4331                         return 0 /* LDKCOption_AccessZ - Some */; (void) (uint64_t)some_ret;
4332                 }
4333                 case LDKCOption_AccessZ_None: {
4334                         return 0 /* LDKCOption_AccessZ - None */;
4335                 }
4336                 default: abort();
4337         }
4338 }
4339 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
4340         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
4341 }
4342 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
4343         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4344         CHECK(val->result_ok);
4345         LDKDirectionalChannelInfo res_var = (*val->contents.result);
4346         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4347         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4348         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4349         return res_ref;
4350 }
4351 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
4352         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4353         CHECK(!val->result_ok);
4354         LDKDecodeError err_var = (*val->contents.err);
4355         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4356         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4357         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4358         return err_ref;
4359 }
4360 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
4361         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
4362 }
4363 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
4364         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4365         CHECK(val->result_ok);
4366         LDKChannelInfo res_var = (*val->contents.result);
4367         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4368         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4369         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4370         return res_ref;
4371 }
4372 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
4373         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4374         CHECK(!val->result_ok);
4375         LDKDecodeError err_var = (*val->contents.err);
4376         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4377         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4378         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4379         return err_ref;
4380 }
4381 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
4382         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
4383 }
4384 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
4385         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4386         CHECK(val->result_ok);
4387         LDKRoutingFees res_var = (*val->contents.result);
4388         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4389         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4390         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4391         return res_ref;
4392 }
4393 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
4394         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4395         CHECK(!val->result_ok);
4396         LDKDecodeError err_var = (*val->contents.err);
4397         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4398         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4399         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4400         return err_ref;
4401 }
4402 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
4403         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
4404 }
4405 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
4406         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
4407         CHECK(val->result_ok);
4408         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
4409         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4410         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4411         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4412         return res_ref;
4413 }
4414 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
4415         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
4416         CHECK(!val->result_ok);
4417         LDKDecodeError err_var = (*val->contents.err);
4418         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4419         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4420         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4421         return err_ref;
4422 }
4423 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
4424         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
4425         ret->datalen = *((uint32_t*)elems);
4426         if (ret->datalen == 0) {
4427                 ret->data = NULL;
4428         } else {
4429                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
4430                 int64_t *java_elems = (int64_t*)(elems + 4);
4431                 for (size_t i = 0; i < ret->datalen; i++) {
4432                         ret->data[i] = java_elems[i];
4433                 }
4434         }
4435         return (uint64_t)ret;
4436 }
4437 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
4438         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
4439         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
4440         return ret;
4441 }
4442 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
4443         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
4444 }
4445 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
4446         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
4447         CHECK(val->result_ok);
4448         LDKNodeInfo res_var = (*val->contents.result);
4449         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4450         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4451         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4452         return res_ref;
4453 }
4454 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
4455         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
4456         CHECK(!val->result_ok);
4457         LDKDecodeError err_var = (*val->contents.err);
4458         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4459         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4460         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4461         return err_ref;
4462 }
4463 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
4464         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
4465 }
4466 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
4467         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
4468         CHECK(val->result_ok);
4469         LDKNetworkGraph res_var = (*val->contents.result);
4470         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4471         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4472         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4473         return res_ref;
4474 }
4475 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
4476         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
4477         CHECK(!val->result_ok);
4478         LDKDecodeError err_var = (*val->contents.err);
4479         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4480         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4481         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4482         return err_ref;
4483 }
4484 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_result_ok(uint32_t arg) {
4485         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
4486 }
4487 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
4488         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
4489         CHECK(val->result_ok);
4490         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
4491         return res_ref;
4492 }
4493 int8_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
4494         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
4495         CHECK(!val->result_ok);
4496         return *val->contents.err;
4497 }
4498 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
4499         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
4500 }
4501 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
4502         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
4503         CHECK(val->result_ok);
4504         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
4505         *res_conv = (*val->contents.result);
4506         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
4507         return (uint64_t)res_conv;
4508 }
4509 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
4510         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
4511         CHECK(!val->result_ok);
4512         LDKDecodeError err_var = (*val->contents.err);
4513         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4514         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4515         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4516         return err_ref;
4517 }
4518 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_result_ok(uint32_t arg) {
4519         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
4520 }
4521 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_ok(uint32_t arg) {
4522         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
4523         CHECK(val->result_ok);
4524         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
4525         return res_ref;
4526 }
4527 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_err(uint32_t arg) {
4528         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
4529         CHECK(!val->result_ok);
4530         LDKDecodeError err_var = (*val->contents.err);
4531         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4532         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4533         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4534         return err_ref;
4535 }
4536 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
4537         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
4538         ret->datalen = *((uint32_t*)elems);
4539         if (ret->datalen == 0) {
4540                 ret->data = NULL;
4541         } else {
4542                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
4543                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4544                 for (size_t i = 0; i < ret->datalen; i++) {
4545                         uint32_t arr_elem = java_elems[i];
4546                         LDKUpdateAddHTLC arr_elem_conv;
4547                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4548                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4549                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
4550                         ret->data[i] = arr_elem_conv;
4551                 }
4552         }
4553         return (uint64_t)ret;
4554 }
4555 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
4556         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
4557         for (size_t i = 0; i < ret.datalen; i++) {
4558                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
4559         }
4560         return ret;
4561 }
4562 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
4563         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
4564         ret->datalen = *((uint32_t*)elems);
4565         if (ret->datalen == 0) {
4566                 ret->data = NULL;
4567         } else {
4568                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
4569                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4570                 for (size_t i = 0; i < ret->datalen; i++) {
4571                         uint32_t arr_elem = java_elems[i];
4572                         LDKUpdateFulfillHTLC arr_elem_conv;
4573                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4574                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4575                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
4576                         ret->data[i] = arr_elem_conv;
4577                 }
4578         }
4579         return (uint64_t)ret;
4580 }
4581 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
4582         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
4583         for (size_t i = 0; i < ret.datalen; i++) {
4584                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
4585         }
4586         return ret;
4587 }
4588 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
4589         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
4590         ret->datalen = *((uint32_t*)elems);
4591         if (ret->datalen == 0) {
4592                 ret->data = NULL;
4593         } else {
4594                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
4595                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4596                 for (size_t i = 0; i < ret->datalen; i++) {
4597                         uint32_t arr_elem = java_elems[i];
4598                         LDKUpdateFailHTLC arr_elem_conv;
4599                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4600                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4601                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
4602                         ret->data[i] = arr_elem_conv;
4603                 }
4604         }
4605         return (uint64_t)ret;
4606 }
4607 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
4608         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
4609         for (size_t i = 0; i < ret.datalen; i++) {
4610                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
4611         }
4612         return ret;
4613 }
4614 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
4615         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
4616         ret->datalen = *((uint32_t*)elems);
4617         if (ret->datalen == 0) {
4618                 ret->data = NULL;
4619         } else {
4620                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
4621                 uint32_t *java_elems = (uint32_t*)(elems + 4);
4622                 for (size_t i = 0; i < ret->datalen; i++) {
4623                         uint32_t arr_elem = java_elems[i];
4624                         LDKUpdateFailMalformedHTLC arr_elem_conv;
4625                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4626                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4627                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
4628                         ret->data[i] = arr_elem_conv;
4629                 }
4630         }
4631         return (uint64_t)ret;
4632 }
4633 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
4634         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
4635         for (size_t i = 0; i < ret.datalen; i++) {
4636                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
4637         }
4638         return ret;
4639 }
4640 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_result_ok(uint32_t arg) {
4641         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
4642 }
4643 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t arg) {
4644         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
4645         CHECK(val->result_ok);
4646         LDKAcceptChannel res_var = (*val->contents.result);
4647         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4648         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4649         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4650         return res_ref;
4651 }
4652 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
4653         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
4654         CHECK(!val->result_ok);
4655         LDKDecodeError err_var = (*val->contents.err);
4656         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4657         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4658         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4659         return err_ref;
4660 }
4661 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_result_ok(uint32_t arg) {
4662         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
4663 }
4664 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t arg) {
4665         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
4666         CHECK(val->result_ok);
4667         LDKAnnouncementSignatures res_var = (*val->contents.result);
4668         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4669         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4670         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4671         return res_ref;
4672 }
4673 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
4674         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
4675         CHECK(!val->result_ok);
4676         LDKDecodeError err_var = (*val->contents.err);
4677         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4678         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4679         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4680         return err_ref;
4681 }
4682 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
4683         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
4684 }
4685 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
4686         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4687         CHECK(val->result_ok);
4688         LDKChannelReestablish res_var = (*val->contents.result);
4689         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4690         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4691         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4692         return res_ref;
4693 }
4694 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
4695         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4696         CHECK(!val->result_ok);
4697         LDKDecodeError err_var = (*val->contents.err);
4698         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4699         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4700         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4701         return err_ref;
4702 }
4703 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_result_ok(uint32_t arg) {
4704         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
4705 }
4706 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4707         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4708         CHECK(val->result_ok);
4709         LDKClosingSigned res_var = (*val->contents.result);
4710         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4711         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4712         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4713         return res_ref;
4714 }
4715 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
4716         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4717         CHECK(!val->result_ok);
4718         LDKDecodeError err_var = (*val->contents.err);
4719         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4720         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4721         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4722         return err_ref;
4723 }
4724 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_result_ok(uint32_t arg) {
4725         return ((LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)arg)->result_ok;
4726 }
4727 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t arg) {
4728         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
4729         CHECK(val->result_ok);
4730         LDKClosingSignedFeeRange res_var = (*val->contents.result);
4731         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4732         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4733         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4734         return res_ref;
4735 }
4736 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t arg) {
4737         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
4738         CHECK(!val->result_ok);
4739         LDKDecodeError err_var = (*val->contents.err);
4740         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4741         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4742         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4743         return err_ref;
4744 }
4745 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) {
4746         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
4747 }
4748 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t arg) {
4749         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4750         CHECK(val->result_ok);
4751         LDKCommitmentSigned res_var = (*val->contents.result);
4752         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4753         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4754         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4755         return res_ref;
4756 }
4757 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
4758         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4759         CHECK(!val->result_ok);
4760         LDKDecodeError err_var = (*val->contents.err);
4761         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4762         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4763         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4764         return err_ref;
4765 }
4766 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_result_ok(uint32_t arg) {
4767         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
4768 }
4769 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t arg) {
4770         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4771         CHECK(val->result_ok);
4772         LDKFundingCreated res_var = (*val->contents.result);
4773         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4774         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4775         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4776         return res_ref;
4777 }
4778 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
4779         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4780         CHECK(!val->result_ok);
4781         LDKDecodeError err_var = (*val->contents.err);
4782         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4783         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4784         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4785         return err_ref;
4786 }
4787 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_result_ok(uint32_t arg) {
4788         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
4789 }
4790 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4791         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4792         CHECK(val->result_ok);
4793         LDKFundingSigned res_var = (*val->contents.result);
4794         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4795         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4796         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4797         return res_ref;
4798 }
4799 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
4800         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4801         CHECK(!val->result_ok);
4802         LDKDecodeError err_var = (*val->contents.err);
4803         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4804         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4805         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4806         return err_ref;
4807 }
4808 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_result_ok(uint32_t arg) {
4809         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
4810 }
4811 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_ok(uint32_t arg) {
4812         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4813         CHECK(val->result_ok);
4814         LDKFundingLocked res_var = (*val->contents.result);
4815         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4816         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4817         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4818         return res_ref;
4819 }
4820 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
4821         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4822         CHECK(!val->result_ok);
4823         LDKDecodeError err_var = (*val->contents.err);
4824         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4825         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4826         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4827         return err_ref;
4828 }
4829 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
4830         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
4831 }
4832 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
4833         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4834         CHECK(val->result_ok);
4835         LDKInit res_var = (*val->contents.result);
4836         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4837         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4838         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4839         return res_ref;
4840 }
4841 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
4842         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4843         CHECK(!val->result_ok);
4844         LDKDecodeError err_var = (*val->contents.err);
4845         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4846         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4847         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4848         return err_ref;
4849 }
4850 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_result_ok(uint32_t arg) {
4851         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
4852 }
4853 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_ok(uint32_t arg) {
4854         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4855         CHECK(val->result_ok);
4856         LDKOpenChannel res_var = (*val->contents.result);
4857         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4858         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4859         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4860         return res_ref;
4861 }
4862 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
4863         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4864         CHECK(!val->result_ok);
4865         LDKDecodeError err_var = (*val->contents.err);
4866         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4867         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4868         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4869         return err_ref;
4870 }
4871 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_result_ok(uint32_t arg) {
4872         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
4873 }
4874 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t arg) {
4875         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4876         CHECK(val->result_ok);
4877         LDKRevokeAndACK res_var = (*val->contents.result);
4878         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4879         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4880         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4881         return res_ref;
4882 }
4883 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
4884         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4885         CHECK(!val->result_ok);
4886         LDKDecodeError err_var = (*val->contents.err);
4887         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4888         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4889         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4890         return err_ref;
4891 }
4892 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_result_ok(uint32_t arg) {
4893         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
4894 }
4895 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_ok(uint32_t arg) {
4896         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4897         CHECK(val->result_ok);
4898         LDKShutdown res_var = (*val->contents.result);
4899         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4900         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4901         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4902         return res_ref;
4903 }
4904 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
4905         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4906         CHECK(!val->result_ok);
4907         LDKDecodeError err_var = (*val->contents.err);
4908         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4909         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4910         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4911         return err_ref;
4912 }
4913 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4914         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
4915 }
4916 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4917         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4918         CHECK(val->result_ok);
4919         LDKUpdateFailHTLC res_var = (*val->contents.result);
4920         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4921         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4922         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4923         return res_ref;
4924 }
4925 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
4926         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4927         CHECK(!val->result_ok);
4928         LDKDecodeError err_var = (*val->contents.err);
4929         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4930         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4931         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4932         return err_ref;
4933 }
4934 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4935         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
4936 }
4937 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4938         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4939         CHECK(val->result_ok);
4940         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
4941         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4942         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4943         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4944         return res_ref;
4945 }
4946 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
4947         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4948         CHECK(!val->result_ok);
4949         LDKDecodeError err_var = (*val->contents.err);
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         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4953         return err_ref;
4954 }
4955 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_result_ok(uint32_t arg) {
4956         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
4957 }
4958 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t arg) {
4959         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4960         CHECK(val->result_ok);
4961         LDKUpdateFee res_var = (*val->contents.result);
4962         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4963         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4964         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4965         return res_ref;
4966 }
4967 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
4968         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4969         CHECK(!val->result_ok);
4970         LDKDecodeError err_var = (*val->contents.err);
4971         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4972         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4973         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4974         return err_ref;
4975 }
4976 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4977         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
4978 }
4979 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4980         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4981         CHECK(val->result_ok);
4982         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
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         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4986         return res_ref;
4987 }
4988 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
4989         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
4990         CHECK(!val->result_ok);
4991         LDKDecodeError err_var = (*val->contents.err);
4992         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4993         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4994         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4995         return err_ref;
4996 }
4997 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_result_ok(uint32_t arg) {
4998         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
4999 }
5000 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t arg) {
5001         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5002         CHECK(val->result_ok);
5003         LDKUpdateAddHTLC res_var = (*val->contents.result);
5004         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5005         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5006         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5007         return res_ref;
5008 }
5009 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
5010         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5011         CHECK(!val->result_ok);
5012         LDKDecodeError err_var = (*val->contents.err);
5013         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5014         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5015         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5016         return err_ref;
5017 }
5018 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
5019         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
5020 }
5021 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
5022         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5023         CHECK(val->result_ok);
5024         LDKPing res_var = (*val->contents.result);
5025         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5026         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5027         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5028         return res_ref;
5029 }
5030 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
5031         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5032         CHECK(!val->result_ok);
5033         LDKDecodeError err_var = (*val->contents.err);
5034         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5035         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5036         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5037         return err_ref;
5038 }
5039 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
5040         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
5041 }
5042 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
5043         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5044         CHECK(val->result_ok);
5045         LDKPong res_var = (*val->contents.result);
5046         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5047         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5048         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5049         return res_ref;
5050 }
5051 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
5052         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5053         CHECK(!val->result_ok);
5054         LDKDecodeError err_var = (*val->contents.err);
5055         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5056         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5057         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5058         return err_ref;
5059 }
5060 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
5061         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5062 }
5063 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5064         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5065         CHECK(val->result_ok);
5066         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
5067         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5068         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5069         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5070         return res_ref;
5071 }
5072 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5073         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5074         CHECK(!val->result_ok);
5075         LDKDecodeError err_var = (*val->contents.err);
5076         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5077         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5078         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5079         return err_ref;
5080 }
5081 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
5082         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5083 }
5084 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5085         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5086         CHECK(val->result_ok);
5087         LDKChannelAnnouncement res_var = (*val->contents.result);
5088         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5089         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5090         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5091         return res_ref;
5092 }
5093 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5094         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5095         CHECK(!val->result_ok);
5096         LDKDecodeError err_var = (*val->contents.err);
5097         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5098         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5099         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5100         return err_ref;
5101 }
5102 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
5103         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
5104 }
5105 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
5106         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5107         CHECK(val->result_ok);
5108         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
5109         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5110         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5111         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5112         return res_ref;
5113 }
5114 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
5115         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5116         CHECK(!val->result_ok);
5117         LDKDecodeError err_var = (*val->contents.err);
5118         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5119         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5120         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5121         return err_ref;
5122 }
5123 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
5124         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
5125 }
5126 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
5127         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5128         CHECK(val->result_ok);
5129         LDKChannelUpdate res_var = (*val->contents.result);
5130         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5131         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5132         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5133         return res_ref;
5134 }
5135 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
5136         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5137         CHECK(!val->result_ok);
5138         LDKDecodeError err_var = (*val->contents.err);
5139         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5140         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5141         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5142         return err_ref;
5143 }
5144 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
5145         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
5146 }
5147 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
5148         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5149         CHECK(val->result_ok);
5150         LDKErrorMessage res_var = (*val->contents.result);
5151         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5152         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5153         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5154         return res_ref;
5155 }
5156 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
5157         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5158         CHECK(!val->result_ok);
5159         LDKDecodeError err_var = (*val->contents.err);
5160         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5161         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5162         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5163         return err_ref;
5164 }
5165 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
5166         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5167 }
5168 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5169         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5170         CHECK(val->result_ok);
5171         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
5172         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5173         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5174         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5175         return res_ref;
5176 }
5177 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5178         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5179         CHECK(!val->result_ok);
5180         LDKDecodeError err_var = (*val->contents.err);
5181         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5182         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5183         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5184         return err_ref;
5185 }
5186 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
5187         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5188 }
5189 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5190         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5191         CHECK(val->result_ok);
5192         LDKNodeAnnouncement res_var = (*val->contents.result);
5193         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5194         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5195         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5196         return res_ref;
5197 }
5198 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5199         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5200         CHECK(!val->result_ok);
5201         LDKDecodeError err_var = (*val->contents.err);
5202         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5203         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5204         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5205         return err_ref;
5206 }
5207 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
5208         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
5209 }
5210 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
5211         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5212         CHECK(val->result_ok);
5213         LDKQueryShortChannelIds res_var = (*val->contents.result);
5214         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5215         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5216         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5217         return res_ref;
5218 }
5219 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
5220         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5221         CHECK(!val->result_ok);
5222         LDKDecodeError err_var = (*val->contents.err);
5223         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5224         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5225         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5226         return err_ref;
5227 }
5228 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
5229         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
5230 }
5231 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
5232         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5233         CHECK(val->result_ok);
5234         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
5235         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5236         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5237         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5238         return res_ref;
5239 }
5240 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
5241         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5242         CHECK(!val->result_ok);
5243         LDKDecodeError err_var = (*val->contents.err);
5244         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5245         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5246         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5247         return err_ref;
5248 }
5249 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
5250         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
5251 }
5252 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
5253         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5254         CHECK(val->result_ok);
5255         LDKQueryChannelRange res_var = (*val->contents.result);
5256         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5257         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5258         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5259         return res_ref;
5260 }
5261 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
5262         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5263         CHECK(!val->result_ok);
5264         LDKDecodeError err_var = (*val->contents.err);
5265         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5266         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5267         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5268         return err_ref;
5269 }
5270 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
5271         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
5272 }
5273 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
5274         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5275         CHECK(val->result_ok);
5276         LDKReplyChannelRange res_var = (*val->contents.result);
5277         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5278         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5279         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5280         return res_ref;
5281 }
5282 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
5283         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5284         CHECK(!val->result_ok);
5285         LDKDecodeError err_var = (*val->contents.err);
5286         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5287         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5288         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5289         return err_ref;
5290 }
5291 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
5292         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
5293 }
5294 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
5295         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5296         CHECK(val->result_ok);
5297         LDKGossipTimestampFilter res_var = (*val->contents.result);
5298         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5299         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5300         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5301         return res_ref;
5302 }
5303 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
5304         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5305         CHECK(!val->result_ok);
5306         LDKDecodeError err_var = (*val->contents.err);
5307         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5308         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5309         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5310         return err_ref;
5311 }
5312 uint32_t __attribute__((visibility("default"))) TS_LDKSignOrCreationError_ref_from_ptr(uint32_t ptr) {
5313         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
5314         switch(obj->tag) {
5315                 case LDKSignOrCreationError_SignError: {
5316                         return 0 /* LDKSignOrCreationError - SignError */;
5317                 }
5318                 case LDKSignOrCreationError_CreationError: {
5319                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
5320                         return 0 /* LDKSignOrCreationError - CreationError */; (void) creation_error_conv;
5321                 }
5322                 default: abort();
5323         }
5324 }
5325 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_result_ok(uint32_t arg) {
5326         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
5327 }
5328 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t arg) {
5329         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5330         CHECK(val->result_ok);
5331         LDKInvoice res_var = (*val->contents.result);
5332         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5333         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5334         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5335         return res_ref;
5336 }
5337 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t arg) {
5338         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5339         CHECK(!val->result_ok);
5340         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
5341         return err_ref;
5342 }
5343 typedef struct LDKFilter_JCalls {
5344         atomic_size_t refcnt;
5345         uint32_t register_tx_meth;
5346         uint32_t register_output_meth;
5347 } LDKFilter_JCalls;
5348 static void LDKFilter_JCalls_free(void* this_arg) {
5349         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5350         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5351                 js_free(j_calls->register_tx_meth);
5352                 js_free(j_calls->register_output_meth);
5353                 FREE(j_calls);
5354         }
5355 }
5356 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5357         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5358         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5359         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5360         LDKu8slice script_pubkey_var = script_pubkey;
5361         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5362         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
5363         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
5364 }
5365 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5366         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5367         LDKWatchedOutput output_var = output;
5368         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5369         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5370         uint64_t output_ref = (uint64_t)output_var.inner;
5371         if (output_var.is_owned) {
5372                 output_ref |= 1;
5373         }
5374         uint32_t ret = js_invoke_function_1(j_calls->register_output_meth, output_ref);
5375         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
5376         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
5377         return ret_conv;
5378 }
5379 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
5380         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
5381         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5382 }
5383 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
5384         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5385         atomic_init(&calls->refcnt, 1);
5386         //TODO: Assign calls->o from o
5387
5388         LDKFilter ret = {
5389                 .this_arg = (void*) calls,
5390                 .register_tx = register_tx_LDKFilter_jcall,
5391                 .register_output = register_output_LDKFilter_jcall,
5392                 .free = LDKFilter_JCalls_free,
5393         };
5394         return ret;
5395 }
5396 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
5397         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5398         *res_ptr = LDKFilter_init(o);
5399         return (long)res_ptr;
5400 }
5401 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
5402         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5403         unsigned char txid_arr[32];
5404         CHECK(*((uint32_t*)txid) == 32);
5405         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5406         unsigned char (*txid_ref)[32] = &txid_arr;
5407         LDKu8slice script_pubkey_ref;
5408         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
5409         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
5410         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5411 }
5412
5413 uint32_t  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
5414         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
5415         LDKWatchedOutput output_conv;
5416         output_conv.inner = (void*)(output & (~1));
5417         output_conv.is_owned = (output & 1) || (output == 0);
5418         output_conv = WatchedOutput_clone(&output_conv);
5419         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5420         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5421         uint64_t ret_ref = (uint64_t)ret_copy;
5422         return ret_ref;
5423 }
5424
5425 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_FilterZ_ref_from_ptr(uint32_t ptr) {
5426         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
5427         switch(obj->tag) {
5428                 case LDKCOption_FilterZ_Some: {
5429                         LDKFilter* some_ret =MALLOC(sizeof(LDKFilter), "LDKFilter");
5430                         *some_ret = obj->some;
5431                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
5432                         return 0 /* LDKCOption_FilterZ - Some */; (void) (uint64_t)some_ret;
5433                 }
5434                 case LDKCOption_FilterZ_None: {
5435                         return 0 /* LDKCOption_FilterZ - None */;
5436                 }
5437                 default: abort();
5438         }
5439 }
5440 typedef struct LDKMessageSendEventsProvider_JCalls {
5441         atomic_size_t refcnt;
5442         uint32_t get_and_clear_pending_msg_events_meth;
5443 } LDKMessageSendEventsProvider_JCalls;
5444 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
5445         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5446         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5447                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
5448                 FREE(j_calls);
5449         }
5450 }
5451 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
5452         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5453         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
5454         LDKCVec_MessageSendEventZ ret_constr;
5455         ret_constr.datalen = *((uint32_t*)ret);
5456         if (ret_constr.datalen > 0)
5457                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
5458         else
5459                 ret_constr.data = NULL;
5460         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5461         for (size_t s = 0; s < ret_constr.datalen; s++) {
5462                 uint32_t ret_conv_18 = ret_vals[s];
5463                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
5464                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
5465                 ret_constr.data[s] = ret_conv_18_conv;
5466         }
5467         return ret_constr;
5468 }
5469 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
5470         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
5471         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5472 }
5473 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
5474         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
5475         atomic_init(&calls->refcnt, 1);
5476         //TODO: Assign calls->o from o
5477
5478         LDKMessageSendEventsProvider ret = {
5479                 .this_arg = (void*) calls,
5480                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
5481                 .free = LDKMessageSendEventsProvider_JCalls_free,
5482         };
5483         return ret;
5484 }
5485 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
5486         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
5487         *res_ptr = LDKMessageSendEventsProvider_init(o);
5488         return (long)res_ptr;
5489 }
5490 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
5491         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
5492         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
5493         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5494         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
5495         for (size_t s = 0; s < ret_var.datalen; s++) {
5496                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
5497                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
5498                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
5499                 ret_arr_ptr[s] = ret_conv_18_ref;
5500         }
5501         FREE(ret_var.data);
5502         return ret_arr;
5503 }
5504
5505 typedef struct LDKEventHandler_JCalls {
5506         atomic_size_t refcnt;
5507         uint32_t handle_event_meth;
5508 } LDKEventHandler_JCalls;
5509 static void LDKEventHandler_JCalls_free(void* this_arg) {
5510         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
5511         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5512                 js_free(j_calls->handle_event_meth);
5513                 FREE(j_calls);
5514         }
5515 }
5516 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
5517         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
5518         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
5519         *ret_event = Event_clone(event);
5520         js_invoke_function_1(j_calls->handle_event_meth, (uint64_t)ret_event);
5521 }
5522 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
5523         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
5524         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5525 }
5526 static inline LDKEventHandler LDKEventHandler_init (/*TODO: JS Object Reference */void* o) {
5527         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
5528         atomic_init(&calls->refcnt, 1);
5529         //TODO: Assign calls->o from o
5530
5531         LDKEventHandler ret = {
5532                 .this_arg = (void*) calls,
5533                 .handle_event = handle_event_LDKEventHandler_jcall,
5534                 .free = LDKEventHandler_JCalls_free,
5535         };
5536         return ret;
5537 }
5538 long  __attribute__((visibility("default"))) TS_LDKEventHandler_new(/*TODO: JS Object Reference */void* o) {
5539         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
5540         *res_ptr = LDKEventHandler_init(o);
5541         return (long)res_ptr;
5542 }
5543 void  __attribute__((visibility("default"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
5544         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
5545         LDKEvent* event_conv = (LDKEvent*)event;
5546         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
5547 }
5548
5549 typedef struct LDKEventsProvider_JCalls {
5550         atomic_size_t refcnt;
5551         uint32_t process_pending_events_meth;
5552 } LDKEventsProvider_JCalls;
5553 static void LDKEventsProvider_JCalls_free(void* this_arg) {
5554         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
5555         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5556                 js_free(j_calls->process_pending_events_meth);
5557                 FREE(j_calls);
5558         }
5559 }
5560 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
5561         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
5562         LDKEventHandler* handler_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
5563         *handler_ret = handler;
5564         js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)handler_ret);
5565 }
5566 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
5567         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
5568         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5569 }
5570 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
5571         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
5572         atomic_init(&calls->refcnt, 1);
5573         //TODO: Assign calls->o from o
5574
5575         LDKEventsProvider ret = {
5576                 .this_arg = (void*) calls,
5577                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
5578                 .free = LDKEventsProvider_JCalls_free,
5579         };
5580         return ret;
5581 }
5582 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
5583         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
5584         *res_ptr = LDKEventsProvider_init(o);
5585         return (long)res_ptr;
5586 }
5587 void  __attribute__((visibility("default"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
5588         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
5589         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
5590         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
5591 }
5592
5593 typedef struct LDKListen_JCalls {
5594         atomic_size_t refcnt;
5595         uint32_t block_connected_meth;
5596         uint32_t block_disconnected_meth;
5597 } LDKListen_JCalls;
5598 static void LDKListen_JCalls_free(void* this_arg) {
5599         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5600         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5601                 js_free(j_calls->block_connected_meth);
5602                 js_free(j_calls->block_disconnected_meth);
5603                 FREE(j_calls);
5604         }
5605 }
5606 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
5607         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5608         LDKu8slice block_var = block;
5609         int8_tArray block_arr = init_arr(block_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5610         memcpy((uint8_t*)(block_arr + 4), block_var.data, block_var.datalen);
5611         js_invoke_function_2(j_calls->block_connected_meth, block_arr, height);
5612 }
5613 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
5614         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5615         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5616         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5617         js_invoke_function_2(j_calls->block_disconnected_meth, header_arr, height);
5618 }
5619 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
5620         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
5621         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5622 }
5623 static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) {
5624         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
5625         atomic_init(&calls->refcnt, 1);
5626         //TODO: Assign calls->o from o
5627
5628         LDKListen ret = {
5629                 .this_arg = (void*) calls,
5630                 .block_connected = block_connected_LDKListen_jcall,
5631                 .block_disconnected = block_disconnected_LDKListen_jcall,
5632                 .free = LDKListen_JCalls_free,
5633         };
5634         return ret;
5635 }
5636 long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object Reference */void* o) {
5637         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
5638         *res_ptr = LDKListen_init(o);
5639         return (long)res_ptr;
5640 }
5641 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
5642         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
5643         LDKu8slice block_ref;
5644         block_ref.datalen = *((uint32_t*)block);
5645         block_ref.data = (int8_t*)(block + 4);
5646         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
5647 }
5648
5649 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
5650         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
5651         unsigned char header_arr[80];
5652         CHECK(*((uint32_t*)header) == 80);
5653         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5654         unsigned char (*header_ref)[80] = &header_arr;
5655         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
5656 }
5657
5658 typedef struct LDKConfirm_JCalls {
5659         atomic_size_t refcnt;
5660         uint32_t transactions_confirmed_meth;
5661         uint32_t transaction_unconfirmed_meth;
5662         uint32_t best_block_updated_meth;
5663         uint32_t get_relevant_txids_meth;
5664 } LDKConfirm_JCalls;
5665 static void LDKConfirm_JCalls_free(void* this_arg) {
5666         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5667         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5668                 js_free(j_calls->transactions_confirmed_meth);
5669                 js_free(j_calls->transaction_unconfirmed_meth);
5670                 js_free(j_calls->best_block_updated_meth);
5671                 js_free(j_calls->get_relevant_txids_meth);
5672                 FREE(j_calls);
5673         }
5674 }
5675 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
5676         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5677         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5678         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5679         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
5680         uint32_tArray txdata_arr = init_arr(txdata_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5681         uint32_t *txdata_arr_ptr = (uint32_t*)(txdata_arr + 4);
5682         for (size_t c = 0; c < txdata_var.datalen; c++) {
5683                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
5684                 *txdata_conv_28_conv = txdata_var.data[c];
5685                 txdata_arr_ptr[c] = ((uint64_t)txdata_conv_28_conv);
5686         }
5687         FREE(txdata_var.data);
5688         js_invoke_function_3(j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
5689 }
5690 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
5691         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5692         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5693         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5694         js_invoke_function_1(j_calls->transaction_unconfirmed_meth, txid_arr);
5695 }
5696 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
5697         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5698         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5699         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5700         js_invoke_function_2(j_calls->best_block_updated_meth, header_arr, height);
5701 }
5702 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
5703         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5704         ptrArray ret = js_invoke_function_0(j_calls->get_relevant_txids_meth);
5705         LDKCVec_TxidZ ret_constr;
5706         ret_constr.datalen = *((uint32_t*)ret);
5707         if (ret_constr.datalen > 0)
5708                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
5709         else
5710                 ret_constr.data = NULL;
5711         int8_tArray* ret_vals = (int8_tArray*)(ret + 4);
5712         for (size_t m = 0; m < ret_constr.datalen; m++) {
5713                 int8_tArray ret_conv_12 = ret_vals[m];
5714                 LDKThirtyTwoBytes ret_conv_12_ref;
5715                 CHECK(*((uint32_t*)ret_conv_12) == 32);
5716                 memcpy(ret_conv_12_ref.data, (uint8_t*)(ret_conv_12 + 4), 32);
5717                 ret_constr.data[m] = ret_conv_12_ref;
5718         }
5719         return ret_constr;
5720 }
5721 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
5722         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
5723         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5724 }
5725 static inline LDKConfirm LDKConfirm_init (/*TODO: JS Object Reference */void* o) {
5726         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
5727         atomic_init(&calls->refcnt, 1);
5728         //TODO: Assign calls->o from o
5729
5730         LDKConfirm ret = {
5731                 .this_arg = (void*) calls,
5732                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
5733                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
5734                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
5735                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
5736                 .free = LDKConfirm_JCalls_free,
5737         };
5738         return ret;
5739 }
5740 long  __attribute__((visibility("default"))) TS_LDKConfirm_new(/*TODO: JS Object Reference */void* o) {
5741         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
5742         *res_ptr = LDKConfirm_init(o);
5743         return (long)res_ptr;
5744 }
5745 void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
5746         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5747         unsigned char header_arr[80];
5748         CHECK(*((uint32_t*)header) == 80);
5749         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5750         unsigned char (*header_ref)[80] = &header_arr;
5751         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
5752         txdata_constr.datalen = *((uint32_t*)txdata);
5753         if (txdata_constr.datalen > 0)
5754                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
5755         else
5756                 txdata_constr.data = NULL;
5757         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
5758         for (size_t c = 0; c < txdata_constr.datalen; c++) {
5759                 uint32_t txdata_conv_28 = txdata_vals[c];
5760                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
5761                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
5762                 txdata_constr.data[c] = txdata_conv_28_conv;
5763         }
5764         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
5765 }
5766
5767 void  __attribute__((visibility("default"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
5768         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5769         unsigned char txid_arr[32];
5770         CHECK(*((uint32_t*)txid) == 32);
5771         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5772         unsigned char (*txid_ref)[32] = &txid_arr;
5773         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
5774 }
5775
5776 void  __attribute__((visibility("default"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
5777         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5778         unsigned char header_arr[80];
5779         CHECK(*((uint32_t*)header) == 80);
5780         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5781         unsigned char (*header_ref)[80] = &header_arr;
5782         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
5783 }
5784
5785 ptrArray  __attribute__((visibility("default"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
5786         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
5787         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
5788         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
5789         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
5790         for (size_t m = 0; m < ret_var.datalen; m++) {
5791                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5792                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
5793                 ret_arr_ptr[m] = ret_conv_12_arr;
5794         }
5795         FREE(ret_var.data);
5796         return ret_arr;
5797 }
5798
5799 typedef struct LDKPersist_JCalls {
5800         atomic_size_t refcnt;
5801         uint32_t persist_new_channel_meth;
5802         uint32_t update_persisted_channel_meth;
5803 } LDKPersist_JCalls;
5804 static void LDKPersist_JCalls_free(void* this_arg) {
5805         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5806         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5807                 js_free(j_calls->persist_new_channel_meth);
5808                 js_free(j_calls->update_persisted_channel_meth);
5809                 FREE(j_calls);
5810         }
5811 }
5812 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
5813         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5814         LDKOutPoint id_var = id;
5815         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5816         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5817         uint64_t id_ref = (uint64_t)id_var.inner;
5818         if (id_var.is_owned) {
5819                 id_ref |= 1;
5820         }
5821         LDKChannelMonitor data_var = *data;
5822         data_var = ChannelMonitor_clone(data);
5823         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5824         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5825         uint64_t data_ref = (uint64_t)data_var.inner;
5826         if (data_var.is_owned) {
5827                 data_ref |= 1;
5828         }
5829         uint32_t ret = js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
5830         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5831         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5832         return ret_conv;
5833 }
5834 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
5835         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5836         LDKOutPoint id_var = id;
5837         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5838         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5839         uint64_t id_ref = (uint64_t)id_var.inner;
5840         if (id_var.is_owned) {
5841                 id_ref |= 1;
5842         }
5843         LDKChannelMonitorUpdate update_var = *update;
5844         update_var = ChannelMonitorUpdate_clone(update);
5845         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5846         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5847         uint64_t update_ref = (uint64_t)update_var.inner;
5848         if (update_var.is_owned) {
5849                 update_ref |= 1;
5850         }
5851         LDKChannelMonitor data_var = *data;
5852         data_var = ChannelMonitor_clone(data);
5853         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5854         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5855         uint64_t data_ref = (uint64_t)data_var.inner;
5856         if (data_var.is_owned) {
5857                 data_ref |= 1;
5858         }
5859         uint32_t ret = js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
5860         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
5861         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
5862         return ret_conv;
5863 }
5864 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
5865         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
5866         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5867 }
5868 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
5869         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
5870         atomic_init(&calls->refcnt, 1);
5871         //TODO: Assign calls->o from o
5872
5873         LDKPersist ret = {
5874                 .this_arg = (void*) calls,
5875                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
5876                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
5877                 .free = LDKPersist_JCalls_free,
5878         };
5879         return ret;
5880 }
5881 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
5882         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
5883         *res_ptr = LDKPersist_init(o);
5884         return (long)res_ptr;
5885 }
5886 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
5887         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5888         LDKOutPoint id_conv;
5889         id_conv.inner = (void*)(id & (~1));
5890         id_conv.is_owned = (id & 1) || (id == 0);
5891         id_conv = OutPoint_clone(&id_conv);
5892         LDKChannelMonitor data_conv;
5893         data_conv.inner = (void*)(data & (~1));
5894         data_conv.is_owned = false;
5895         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5896         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
5897         return (uint64_t)ret_conv;
5898 }
5899
5900 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
5901         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
5902         LDKOutPoint id_conv;
5903         id_conv.inner = (void*)(id & (~1));
5904         id_conv.is_owned = (id & 1) || (id == 0);
5905         id_conv = OutPoint_clone(&id_conv);
5906         LDKChannelMonitorUpdate update_conv;
5907         update_conv.inner = (void*)(update & (~1));
5908         update_conv.is_owned = false;
5909         LDKChannelMonitor data_conv;
5910         data_conv.inner = (void*)(data & (~1));
5911         data_conv.is_owned = false;
5912         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5913         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
5914         return (uint64_t)ret_conv;
5915 }
5916
5917 typedef struct LDKChannelMessageHandler_JCalls {
5918         atomic_size_t refcnt;
5919         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
5920         uint32_t handle_open_channel_meth;
5921         uint32_t handle_accept_channel_meth;
5922         uint32_t handle_funding_created_meth;
5923         uint32_t handle_funding_signed_meth;
5924         uint32_t handle_funding_locked_meth;
5925         uint32_t handle_shutdown_meth;
5926         uint32_t handle_closing_signed_meth;
5927         uint32_t handle_update_add_htlc_meth;
5928         uint32_t handle_update_fulfill_htlc_meth;
5929         uint32_t handle_update_fail_htlc_meth;
5930         uint32_t handle_update_fail_malformed_htlc_meth;
5931         uint32_t handle_commitment_signed_meth;
5932         uint32_t handle_revoke_and_ack_meth;
5933         uint32_t handle_update_fee_meth;
5934         uint32_t handle_announcement_signatures_meth;
5935         uint32_t peer_disconnected_meth;
5936         uint32_t peer_connected_meth;
5937         uint32_t handle_channel_reestablish_meth;
5938         uint32_t handle_channel_update_meth;
5939         uint32_t handle_error_meth;
5940 } LDKChannelMessageHandler_JCalls;
5941 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
5942         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5943         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5944                 js_free(j_calls->handle_open_channel_meth);
5945                 js_free(j_calls->handle_accept_channel_meth);
5946                 js_free(j_calls->handle_funding_created_meth);
5947                 js_free(j_calls->handle_funding_signed_meth);
5948                 js_free(j_calls->handle_funding_locked_meth);
5949                 js_free(j_calls->handle_shutdown_meth);
5950                 js_free(j_calls->handle_closing_signed_meth);
5951                 js_free(j_calls->handle_update_add_htlc_meth);
5952                 js_free(j_calls->handle_update_fulfill_htlc_meth);
5953                 js_free(j_calls->handle_update_fail_htlc_meth);
5954                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
5955                 js_free(j_calls->handle_commitment_signed_meth);
5956                 js_free(j_calls->handle_revoke_and_ack_meth);
5957                 js_free(j_calls->handle_update_fee_meth);
5958                 js_free(j_calls->handle_announcement_signatures_meth);
5959                 js_free(j_calls->peer_disconnected_meth);
5960                 js_free(j_calls->peer_connected_meth);
5961                 js_free(j_calls->handle_channel_reestablish_meth);
5962                 js_free(j_calls->handle_channel_update_meth);
5963                 js_free(j_calls->handle_error_meth);
5964                 FREE(j_calls);
5965         }
5966 }
5967 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
5968         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5969         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5970         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5971         LDKInitFeatures their_features_var = their_features;
5972         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5973         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5974         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5975         if (their_features_var.is_owned) {
5976                 their_features_ref |= 1;
5977         }
5978         LDKOpenChannel msg_var = *msg;
5979         msg_var = OpenChannel_clone(msg);
5980         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5981         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5982         uint64_t msg_ref = (uint64_t)msg_var.inner;
5983         if (msg_var.is_owned) {
5984                 msg_ref |= 1;
5985         }
5986         js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
5987 }
5988 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
5989         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
5990         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
5991         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
5992         LDKInitFeatures their_features_var = their_features;
5993         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5994         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5995         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
5996         if (their_features_var.is_owned) {
5997                 their_features_ref |= 1;
5998         }
5999         LDKAcceptChannel msg_var = *msg;
6000         msg_var = AcceptChannel_clone(msg);
6001         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6002         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6003         uint64_t msg_ref = (uint64_t)msg_var.inner;
6004         if (msg_var.is_owned) {
6005                 msg_ref |= 1;
6006         }
6007         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
6008 }
6009 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
6010         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6011         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6012         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6013         LDKFundingCreated msg_var = *msg;
6014         msg_var = FundingCreated_clone(msg);
6015         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6016         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6017         uint64_t msg_ref = (uint64_t)msg_var.inner;
6018         if (msg_var.is_owned) {
6019                 msg_ref |= 1;
6020         }
6021         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
6022 }
6023 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
6024         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6025         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6026         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6027         LDKFundingSigned msg_var = *msg;
6028         msg_var = FundingSigned_clone(msg);
6029         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6030         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6031         uint64_t msg_ref = (uint64_t)msg_var.inner;
6032         if (msg_var.is_owned) {
6033                 msg_ref |= 1;
6034         }
6035         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
6036 }
6037 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
6038         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6039         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6040         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6041         LDKFundingLocked msg_var = *msg;
6042         msg_var = FundingLocked_clone(msg);
6043         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6044         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6045         uint64_t msg_ref = (uint64_t)msg_var.inner;
6046         if (msg_var.is_owned) {
6047                 msg_ref |= 1;
6048         }
6049         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
6050 }
6051 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
6052         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6053         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6054         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6055         LDKInitFeatures their_features_var = *their_features;
6056         their_features_var = InitFeatures_clone(their_features);
6057         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6058         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6059         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
6060         if (their_features_var.is_owned) {
6061                 their_features_ref |= 1;
6062         }
6063         LDKShutdown msg_var = *msg;
6064         msg_var = Shutdown_clone(msg);
6065         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6066         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6067         uint64_t msg_ref = (uint64_t)msg_var.inner;
6068         if (msg_var.is_owned) {
6069                 msg_ref |= 1;
6070         }
6071         js_invoke_function_3(j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
6072 }
6073 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
6074         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6075         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6076         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6077         LDKClosingSigned msg_var = *msg;
6078         msg_var = ClosingSigned_clone(msg);
6079         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6080         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6081         uint64_t 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_closing_signed_meth, their_node_id_arr, msg_ref);
6086 }
6087 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * 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         LDKUpdateAddHTLC msg_var = *msg;
6092         msg_var = UpdateAddHTLC_clone(msg);
6093         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6094         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6095         uint64_t msg_ref = (uint64_t)msg_var.inner;
6096         if (msg_var.is_owned) {
6097                 msg_ref |= 1;
6098         }
6099         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
6100 }
6101 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
6102         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6103         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6104         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6105         LDKUpdateFulfillHTLC msg_var = *msg;
6106         msg_var = UpdateFulfillHTLC_clone(msg);
6107         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6108         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6109         uint64_t msg_ref = (uint64_t)msg_var.inner;
6110         if (msg_var.is_owned) {
6111                 msg_ref |= 1;
6112         }
6113         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
6114 }
6115 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
6116         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6117         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6118         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6119         LDKUpdateFailHTLC msg_var = *msg;
6120         msg_var = UpdateFailHTLC_clone(msg);
6121         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6122         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6123         uint64_t 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_update_fail_htlc_meth, their_node_id_arr, msg_ref);
6128 }
6129 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * 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         LDKUpdateFailMalformedHTLC msg_var = *msg;
6134         msg_var = UpdateFailMalformedHTLC_clone(msg);
6135         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6136         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6137         uint64_t msg_ref = (uint64_t)msg_var.inner;
6138         if (msg_var.is_owned) {
6139                 msg_ref |= 1;
6140         }
6141         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
6142 }
6143 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
6144         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6145         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6146         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6147         LDKCommitmentSigned msg_var = *msg;
6148         msg_var = CommitmentSigned_clone(msg);
6149         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6150         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6151         uint64_t msg_ref = (uint64_t)msg_var.inner;
6152         if (msg_var.is_owned) {
6153                 msg_ref |= 1;
6154         }
6155         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
6156 }
6157 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
6158         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6159         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6160         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6161         LDKRevokeAndACK msg_var = *msg;
6162         msg_var = RevokeAndACK_clone(msg);
6163         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6164         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6165         uint64_t msg_ref = (uint64_t)msg_var.inner;
6166         if (msg_var.is_owned) {
6167                 msg_ref |= 1;
6168         }
6169         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
6170 }
6171 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
6172         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6173         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6174         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6175         LDKUpdateFee msg_var = *msg;
6176         msg_var = UpdateFee_clone(msg);
6177         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6178         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6179         uint64_t msg_ref = (uint64_t)msg_var.inner;
6180         if (msg_var.is_owned) {
6181                 msg_ref |= 1;
6182         }
6183         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
6184 }
6185 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
6186         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6187         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6188         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6189         LDKAnnouncementSignatures msg_var = *msg;
6190         msg_var = AnnouncementSignatures_clone(msg);
6191         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6192         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6193         uint64_t msg_ref = (uint64_t)msg_var.inner;
6194         if (msg_var.is_owned) {
6195                 msg_ref |= 1;
6196         }
6197         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
6198 }
6199 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
6200         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6201         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6202         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6203         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
6204 }
6205 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
6206         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6207         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6208         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6209         LDKInit msg_var = *msg;
6210         msg_var = Init_clone(msg);
6211         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6212         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6213         uint64_t msg_ref = (uint64_t)msg_var.inner;
6214         if (msg_var.is_owned) {
6215                 msg_ref |= 1;
6216         }
6217         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
6218 }
6219 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
6220         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6221         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6222         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6223         LDKChannelReestablish msg_var = *msg;
6224         msg_var = ChannelReestablish_clone(msg);
6225         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6226         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6227         uint64_t msg_ref = (uint64_t)msg_var.inner;
6228         if (msg_var.is_owned) {
6229                 msg_ref |= 1;
6230         }
6231         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
6232 }
6233 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
6234         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6235         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6236         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6237         LDKChannelUpdate msg_var = *msg;
6238         msg_var = ChannelUpdate_clone(msg);
6239         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6240         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6241         uint64_t msg_ref = (uint64_t)msg_var.inner;
6242         if (msg_var.is_owned) {
6243                 msg_ref |= 1;
6244         }
6245         js_invoke_function_2(j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
6246 }
6247 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
6248         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6249         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6250         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6251         LDKErrorMessage msg_var = *msg;
6252         msg_var = ErrorMessage_clone(msg);
6253         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6254         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6255         uint64_t msg_ref = (uint64_t)msg_var.inner;
6256         if (msg_var.is_owned) {
6257                 msg_ref |= 1;
6258         }
6259         js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
6260 }
6261 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
6262         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
6263         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6264         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6265 }
6266 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
6267         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
6268         atomic_init(&calls->refcnt, 1);
6269         //TODO: Assign calls->o from o
6270
6271         LDKChannelMessageHandler ret = {
6272                 .this_arg = (void*) calls,
6273                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
6274                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
6275                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
6276                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
6277                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
6278                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
6279                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
6280                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
6281                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
6282                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
6283                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
6284                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
6285                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
6286                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
6287                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
6288                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
6289                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
6290                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
6291                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
6292                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
6293                 .free = LDKChannelMessageHandler_JCalls_free,
6294                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
6295         };
6296         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6297         return ret;
6298 }
6299 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
6300         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
6301         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
6302         return (long)res_ptr;
6303 }
6304 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) {
6305         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6306         LDKPublicKey their_node_id_ref;
6307         CHECK(*((uint32_t*)their_node_id) == 33);
6308         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6309         LDKInitFeatures their_features_conv;
6310         their_features_conv.inner = (void*)(their_features & (~1));
6311         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
6312         their_features_conv = InitFeatures_clone(&their_features_conv);
6313         LDKOpenChannel msg_conv;
6314         msg_conv.inner = (void*)(msg & (~1));
6315         msg_conv.is_owned = false;
6316         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
6317 }
6318
6319 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) {
6320         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6321         LDKPublicKey their_node_id_ref;
6322         CHECK(*((uint32_t*)their_node_id) == 33);
6323         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6324         LDKInitFeatures their_features_conv;
6325         their_features_conv.inner = (void*)(their_features & (~1));
6326         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
6327         their_features_conv = InitFeatures_clone(&their_features_conv);
6328         LDKAcceptChannel msg_conv;
6329         msg_conv.inner = (void*)(msg & (~1));
6330         msg_conv.is_owned = false;
6331         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
6332 }
6333
6334 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6335         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6336         LDKPublicKey their_node_id_ref;
6337         CHECK(*((uint32_t*)their_node_id) == 33);
6338         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6339         LDKFundingCreated msg_conv;
6340         msg_conv.inner = (void*)(msg & (~1));
6341         msg_conv.is_owned = false;
6342         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6343 }
6344
6345 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6346         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6347         LDKPublicKey their_node_id_ref;
6348         CHECK(*((uint32_t*)their_node_id) == 33);
6349         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6350         LDKFundingSigned msg_conv;
6351         msg_conv.inner = (void*)(msg & (~1));
6352         msg_conv.is_owned = false;
6353         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6354 }
6355
6356 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6357         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6358         LDKPublicKey their_node_id_ref;
6359         CHECK(*((uint32_t*)their_node_id) == 33);
6360         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6361         LDKFundingLocked msg_conv;
6362         msg_conv.inner = (void*)(msg & (~1));
6363         msg_conv.is_owned = false;
6364         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6365 }
6366
6367 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
6368         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6369         LDKPublicKey their_node_id_ref;
6370         CHECK(*((uint32_t*)their_node_id) == 33);
6371         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6372         LDKInitFeatures their_features_conv;
6373         their_features_conv.inner = (void*)(their_features & (~1));
6374         their_features_conv.is_owned = false;
6375         LDKShutdown msg_conv;
6376         msg_conv.inner = (void*)(msg & (~1));
6377         msg_conv.is_owned = false;
6378         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
6379 }
6380
6381 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6382         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6383         LDKPublicKey their_node_id_ref;
6384         CHECK(*((uint32_t*)their_node_id) == 33);
6385         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6386         LDKClosingSigned msg_conv;
6387         msg_conv.inner = (void*)(msg & (~1));
6388         msg_conv.is_owned = false;
6389         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6390 }
6391
6392 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6393         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6394         LDKPublicKey their_node_id_ref;
6395         CHECK(*((uint32_t*)their_node_id) == 33);
6396         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6397         LDKUpdateAddHTLC msg_conv;
6398         msg_conv.inner = (void*)(msg & (~1));
6399         msg_conv.is_owned = false;
6400         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6401 }
6402
6403 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6404         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6405         LDKPublicKey their_node_id_ref;
6406         CHECK(*((uint32_t*)their_node_id) == 33);
6407         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6408         LDKUpdateFulfillHTLC msg_conv;
6409         msg_conv.inner = (void*)(msg & (~1));
6410         msg_conv.is_owned = false;
6411         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6412 }
6413
6414 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6415         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6416         LDKPublicKey their_node_id_ref;
6417         CHECK(*((uint32_t*)their_node_id) == 33);
6418         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6419         LDKUpdateFailHTLC msg_conv;
6420         msg_conv.inner = (void*)(msg & (~1));
6421         msg_conv.is_owned = false;
6422         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6423 }
6424
6425 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6426         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6427         LDKPublicKey their_node_id_ref;
6428         CHECK(*((uint32_t*)their_node_id) == 33);
6429         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6430         LDKUpdateFailMalformedHTLC msg_conv;
6431         msg_conv.inner = (void*)(msg & (~1));
6432         msg_conv.is_owned = false;
6433         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6434 }
6435
6436 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6437         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6438         LDKPublicKey their_node_id_ref;
6439         CHECK(*((uint32_t*)their_node_id) == 33);
6440         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6441         LDKCommitmentSigned msg_conv;
6442         msg_conv.inner = (void*)(msg & (~1));
6443         msg_conv.is_owned = false;
6444         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6445 }
6446
6447 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6448         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6449         LDKPublicKey their_node_id_ref;
6450         CHECK(*((uint32_t*)their_node_id) == 33);
6451         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6452         LDKRevokeAndACK msg_conv;
6453         msg_conv.inner = (void*)(msg & (~1));
6454         msg_conv.is_owned = false;
6455         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6456 }
6457
6458 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6459         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6460         LDKPublicKey their_node_id_ref;
6461         CHECK(*((uint32_t*)their_node_id) == 33);
6462         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6463         LDKUpdateFee msg_conv;
6464         msg_conv.inner = (void*)(msg & (~1));
6465         msg_conv.is_owned = false;
6466         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6467 }
6468
6469 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6470         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6471         LDKPublicKey their_node_id_ref;
6472         CHECK(*((uint32_t*)their_node_id) == 33);
6473         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6474         LDKAnnouncementSignatures msg_conv;
6475         msg_conv.inner = (void*)(msg & (~1));
6476         msg_conv.is_owned = false;
6477         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6478 }
6479
6480 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
6481         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6482         LDKPublicKey their_node_id_ref;
6483         CHECK(*((uint32_t*)their_node_id) == 33);
6484         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6485         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
6486 }
6487
6488 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6489         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6490         LDKPublicKey their_node_id_ref;
6491         CHECK(*((uint32_t*)their_node_id) == 33);
6492         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6493         LDKInit msg_conv;
6494         msg_conv.inner = (void*)(msg & (~1));
6495         msg_conv.is_owned = false;
6496         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6497 }
6498
6499 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6500         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6501         LDKPublicKey their_node_id_ref;
6502         CHECK(*((uint32_t*)their_node_id) == 33);
6503         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6504         LDKChannelReestablish msg_conv;
6505         msg_conv.inner = (void*)(msg & (~1));
6506         msg_conv.is_owned = false;
6507         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6508 }
6509
6510 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6511         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6512         LDKPublicKey their_node_id_ref;
6513         CHECK(*((uint32_t*)their_node_id) == 33);
6514         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6515         LDKChannelUpdate msg_conv;
6516         msg_conv.inner = (void*)(msg & (~1));
6517         msg_conv.is_owned = false;
6518         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6519 }
6520
6521 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6522         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
6523         LDKPublicKey their_node_id_ref;
6524         CHECK(*((uint32_t*)their_node_id) == 33);
6525         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6526         LDKErrorMessage msg_conv;
6527         msg_conv.inner = (void*)(msg & (~1));
6528         msg_conv.is_owned = false;
6529         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6530 }
6531
6532 typedef struct LDKRoutingMessageHandler_JCalls {
6533         atomic_size_t refcnt;
6534         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
6535         uint32_t handle_node_announcement_meth;
6536         uint32_t handle_channel_announcement_meth;
6537         uint32_t handle_channel_update_meth;
6538         uint32_t get_next_channel_announcements_meth;
6539         uint32_t get_next_node_announcements_meth;
6540         uint32_t sync_routing_table_meth;
6541         uint32_t handle_reply_channel_range_meth;
6542         uint32_t handle_reply_short_channel_ids_end_meth;
6543         uint32_t handle_query_channel_range_meth;
6544         uint32_t handle_query_short_channel_ids_meth;
6545 } LDKRoutingMessageHandler_JCalls;
6546 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
6547         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6548         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6549                 js_free(j_calls->handle_node_announcement_meth);
6550                 js_free(j_calls->handle_channel_announcement_meth);
6551                 js_free(j_calls->handle_channel_update_meth);
6552                 js_free(j_calls->get_next_channel_announcements_meth);
6553                 js_free(j_calls->get_next_node_announcements_meth);
6554                 js_free(j_calls->sync_routing_table_meth);
6555                 js_free(j_calls->handle_reply_channel_range_meth);
6556                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
6557                 js_free(j_calls->handle_query_channel_range_meth);
6558                 js_free(j_calls->handle_query_short_channel_ids_meth);
6559                 FREE(j_calls);
6560         }
6561 }
6562 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
6563         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6564         LDKNodeAnnouncement msg_var = *msg;
6565         msg_var = NodeAnnouncement_clone(msg);
6566         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6567         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6568         uint64_t msg_ref = (uint64_t)msg_var.inner;
6569         if (msg_var.is_owned) {
6570                 msg_ref |= 1;
6571         }
6572         uint32_t ret = js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
6573         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6574         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6575         return ret_conv;
6576 }
6577 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
6578         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6579         LDKChannelAnnouncement msg_var = *msg;
6580         msg_var = ChannelAnnouncement_clone(msg);
6581         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6582         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6583         uint64_t msg_ref = (uint64_t)msg_var.inner;
6584         if (msg_var.is_owned) {
6585                 msg_ref |= 1;
6586         }
6587         uint32_t ret = js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
6588         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6589         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6590         return ret_conv;
6591 }
6592 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
6593         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6594         LDKChannelUpdate msg_var = *msg;
6595         msg_var = ChannelUpdate_clone(msg);
6596         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6597         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6598         uint64_t msg_ref = (uint64_t)msg_var.inner;
6599         if (msg_var.is_owned) {
6600                 msg_ref |= 1;
6601         }
6602         uint32_t ret = js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
6603         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
6604         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
6605         return ret_conv;
6606 }
6607 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
6608         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6609         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
6610         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
6611         ret_constr.datalen = *((uint32_t*)ret);
6612         if (ret_constr.datalen > 0)
6613                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
6614         else
6615                 ret_constr.data = NULL;
6616         uint32_t* ret_vals = (uint32_t*)(ret + 4);
6617         for (size_t h = 0; h < ret_constr.datalen; h++) {
6618                 uint32_t ret_conv_59 = ret_vals[h];
6619                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1);
6620                 ret_conv_59_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_59) & ~1));
6621                 ret_constr.data[h] = ret_conv_59_conv;
6622         }
6623         return ret_constr;
6624 }
6625 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
6626         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6627         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6628         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
6629         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
6630         LDKCVec_NodeAnnouncementZ ret_constr;
6631         ret_constr.datalen = *((uint32_t*)ret);
6632         if (ret_constr.datalen > 0)
6633                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
6634         else
6635                 ret_constr.data = NULL;
6636         uint32_t* ret_vals = (uint32_t*)(ret + 4);
6637         for (size_t s = 0; s < ret_constr.datalen; s++) {
6638                 uint32_t ret_conv_18 = ret_vals[s];
6639                 LDKNodeAnnouncement ret_conv_18_conv;
6640                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
6641                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
6642                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
6643                 ret_constr.data[s] = ret_conv_18_conv;
6644         }
6645         return ret_constr;
6646 }
6647 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
6648         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6649         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6650         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6651         LDKInit init_var = *init;
6652         init_var = Init_clone(init);
6653         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6654         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6655         uint64_t init_ref = (uint64_t)init_var.inner;
6656         if (init_var.is_owned) {
6657                 init_ref |= 1;
6658         }
6659         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
6660 }
6661 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
6662         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6663         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6664         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6665         LDKReplyChannelRange msg_var = msg;
6666         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6667         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6668         uint64_t msg_ref = (uint64_t)msg_var.inner;
6669         if (msg_var.is_owned) {
6670                 msg_ref |= 1;
6671         }
6672         uint32_t ret = js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
6673         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6674         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6675         return ret_conv;
6676 }
6677 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
6678         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6679         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6680         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6681         LDKReplyShortChannelIdsEnd msg_var = msg;
6682         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6683         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6684         uint64_t msg_ref = (uint64_t)msg_var.inner;
6685         if (msg_var.is_owned) {
6686                 msg_ref |= 1;
6687         }
6688         uint32_t ret = js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
6689         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6690         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6691         return ret_conv;
6692 }
6693 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
6694         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6695         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6696         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6697         LDKQueryChannelRange msg_var = msg;
6698         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6699         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6700         uint64_t msg_ref = (uint64_t)msg_var.inner;
6701         if (msg_var.is_owned) {
6702                 msg_ref |= 1;
6703         }
6704         uint32_t ret = js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
6705         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6706         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6707         return ret_conv;
6708 }
6709 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
6710         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6711         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6712         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6713         LDKQueryShortChannelIds msg_var = 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         uint64_t msg_ref = (uint64_t)msg_var.inner;
6717         if (msg_var.is_owned) {
6718                 msg_ref |= 1;
6719         }
6720         uint32_t ret = js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
6721         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6722         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6723         return ret_conv;
6724 }
6725 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
6726         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
6727         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6728         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6729 }
6730 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
6731         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
6732         atomic_init(&calls->refcnt, 1);
6733         //TODO: Assign calls->o from o
6734
6735         LDKRoutingMessageHandler ret = {
6736                 .this_arg = (void*) calls,
6737                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
6738                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
6739                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
6740                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
6741                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
6742                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
6743                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
6744                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
6745                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
6746                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
6747                 .free = LDKRoutingMessageHandler_JCalls_free,
6748                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
6749         };
6750         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6751         return ret;
6752 }
6753 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
6754         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
6755         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
6756         return (long)res_ptr;
6757 }
6758 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
6759         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6760         LDKNodeAnnouncement msg_conv;
6761         msg_conv.inner = (void*)(msg & (~1));
6762         msg_conv.is_owned = false;
6763         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6764         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
6765         return (uint64_t)ret_conv;
6766 }
6767
6768 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
6769         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6770         LDKChannelAnnouncement msg_conv;
6771         msg_conv.inner = (void*)(msg & (~1));
6772         msg_conv.is_owned = false;
6773         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6774         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
6775         return (uint64_t)ret_conv;
6776 }
6777
6778 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
6779         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6780         LDKChannelUpdate msg_conv;
6781         msg_conv.inner = (void*)(msg & (~1));
6782         msg_conv.is_owned = false;
6783         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
6784         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
6785         return (uint64_t)ret_conv;
6786 }
6787
6788 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
6789         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6790         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
6791         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6792         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6793         for (size_t h = 0; h < ret_var.datalen; h++) {
6794                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
6795                 *ret_conv_59_conv = ret_var.data[h];
6796                 ret_arr_ptr[h] = ((uint64_t)ret_conv_59_conv);
6797         }
6798         FREE(ret_var.data);
6799         return ret_arr;
6800 }
6801
6802 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
6803         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6804         LDKPublicKey starting_point_ref;
6805         CHECK(*((uint32_t*)starting_point) == 33);
6806         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
6807         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
6808         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
6809         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
6810         for (size_t s = 0; s < ret_var.datalen; s++) {
6811                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
6812                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6813                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6814                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
6815                 if (ret_conv_18_var.is_owned) {
6816                         ret_conv_18_ref |= 1;
6817                 }
6818                 ret_arr_ptr[s] = ret_conv_18_ref;
6819         }
6820         FREE(ret_var.data);
6821         return ret_arr;
6822 }
6823
6824 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
6825         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6826         LDKPublicKey their_node_id_ref;
6827         CHECK(*((uint32_t*)their_node_id) == 33);
6828         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6829         LDKInit init_conv;
6830         init_conv.inner = (void*)(init & (~1));
6831         init_conv.is_owned = false;
6832         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
6833 }
6834
6835 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6836         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6837         LDKPublicKey their_node_id_ref;
6838         CHECK(*((uint32_t*)their_node_id) == 33);
6839         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6840         LDKReplyChannelRange msg_conv;
6841         msg_conv.inner = (void*)(msg & (~1));
6842         msg_conv.is_owned = (msg & 1) || (msg == 0);
6843         msg_conv = ReplyChannelRange_clone(&msg_conv);
6844         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6845         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6846         return (uint64_t)ret_conv;
6847 }
6848
6849 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) {
6850         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6851         LDKPublicKey their_node_id_ref;
6852         CHECK(*((uint32_t*)their_node_id) == 33);
6853         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6854         LDKReplyShortChannelIdsEnd msg_conv;
6855         msg_conv.inner = (void*)(msg & (~1));
6856         msg_conv.is_owned = (msg & 1) || (msg == 0);
6857         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
6858         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6859         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6860         return (uint64_t)ret_conv;
6861 }
6862
6863 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6864         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6865         LDKPublicKey their_node_id_ref;
6866         CHECK(*((uint32_t*)their_node_id) == 33);
6867         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6868         LDKQueryChannelRange msg_conv;
6869         msg_conv.inner = (void*)(msg & (~1));
6870         msg_conv.is_owned = (msg & 1) || (msg == 0);
6871         msg_conv = QueryChannelRange_clone(&msg_conv);
6872         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6873         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6874         return (uint64_t)ret_conv;
6875 }
6876
6877 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6878         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
6879         LDKPublicKey their_node_id_ref;
6880         CHECK(*((uint32_t*)their_node_id) == 33);
6881         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6882         LDKQueryShortChannelIds msg_conv;
6883         msg_conv.inner = (void*)(msg & (~1));
6884         msg_conv.is_owned = (msg & 1) || (msg == 0);
6885         msg_conv = QueryShortChannelIds_clone(&msg_conv);
6886         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
6887         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
6888         return (uint64_t)ret_conv;
6889 }
6890
6891 typedef struct LDKCustomMessageReader_JCalls {
6892         atomic_size_t refcnt;
6893         uint32_t read_meth;
6894 } LDKCustomMessageReader_JCalls;
6895 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
6896         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
6897         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6898                 js_free(j_calls->read_meth);
6899                 FREE(j_calls);
6900         }
6901 }
6902 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
6903         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
6904         LDKu8slice buffer_var = buffer;
6905         int8_tArray buffer_arr = init_arr(buffer_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6906         memcpy((uint8_t*)(buffer_arr + 4), buffer_var.data, buffer_var.datalen);
6907         uint32_t ret = js_invoke_function_2(j_calls->read_meth, message_type, buffer_arr);
6908         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1);
6909         ret_conv = CResult_COption_TypeZDecodeErrorZ_clone((LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)ret) & ~1));
6910         return ret_conv;
6911 }
6912 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
6913         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
6914         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6915 }
6916 static inline LDKCustomMessageReader LDKCustomMessageReader_init (/*TODO: JS Object Reference */void* o) {
6917         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
6918         atomic_init(&calls->refcnt, 1);
6919         //TODO: Assign calls->o from o
6920
6921         LDKCustomMessageReader ret = {
6922                 .this_arg = (void*) calls,
6923                 .read = read_LDKCustomMessageReader_jcall,
6924                 .free = LDKCustomMessageReader_JCalls_free,
6925         };
6926         return ret;
6927 }
6928 long  __attribute__((visibility("default"))) TS_LDKCustomMessageReader_new(/*TODO: JS Object Reference */void* o) {
6929         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
6930         *res_ptr = LDKCustomMessageReader_init(o);
6931         return (long)res_ptr;
6932 }
6933 uint32_t  __attribute__((visibility("default"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
6934         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)(((uint64_t)this_arg) & ~1);
6935         LDKu8slice buffer_ref;
6936         buffer_ref.datalen = *((uint32_t*)buffer);
6937         buffer_ref.data = (int8_t*)(buffer + 4);
6938         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
6939         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
6940         return (uint64_t)ret_conv;
6941 }
6942
6943 typedef struct LDKCustomMessageHandler_JCalls {
6944         atomic_size_t refcnt;
6945         LDKCustomMessageReader_JCalls* CustomMessageReader;
6946         uint32_t handle_custom_message_meth;
6947         uint32_t get_and_clear_pending_msg_meth;
6948 } LDKCustomMessageHandler_JCalls;
6949 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
6950         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
6951         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6952                 js_free(j_calls->handle_custom_message_meth);
6953                 js_free(j_calls->get_and_clear_pending_msg_meth);
6954                 FREE(j_calls);
6955         }
6956 }
6957 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
6958         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
6959         LDKType* msg_ret =MALLOC(sizeof(LDKType), "LDKType");
6960         *msg_ret = msg;
6961         int8_tArray sender_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6962         memcpy((uint8_t*)(sender_node_id_arr + 4), sender_node_id.compressed_form, 33);
6963         uint32_t ret = js_invoke_function_2(j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr);
6964         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
6965         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
6966         return ret_conv;
6967 }
6968 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
6969         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
6970         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_meth);
6971         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
6972         ret_constr.datalen = *((uint32_t*)ret);
6973         if (ret_constr.datalen > 0)
6974                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
6975         else
6976                 ret_constr.data = NULL;
6977         uint32_t* ret_vals = (uint32_t*)(ret + 4);
6978         for (size_t z = 0; z < ret_constr.datalen; z++) {
6979                 uint32_t ret_conv_25 = ret_vals[z];
6980                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1);
6981                 ret_conv_25_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)ret_conv_25) & ~1));
6982                 ret_constr.data[z] = ret_conv_25_conv;
6983         }
6984         return ret_constr;
6985 }
6986 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
6987         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
6988         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6989         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
6990 }
6991 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* CustomMessageReader) {
6992         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
6993         atomic_init(&calls->refcnt, 1);
6994         //TODO: Assign calls->o from o
6995
6996         LDKCustomMessageHandler ret = {
6997                 .this_arg = (void*) calls,
6998                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
6999                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
7000                 .free = LDKCustomMessageHandler_JCalls_free,
7001                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
7002         };
7003         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
7004         return ret;
7005 }
7006 long  __attribute__((visibility("default"))) TS_LDKCustomMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* CustomMessageReader) {
7007         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
7008         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
7009         return (long)res_ptr;
7010 }
7011 uint32_t  __attribute__((visibility("default"))) TS_CustomMessageHandler_handle_custom_message(uint32_t this_arg, uint32_t msg, int8_tArray sender_node_id) {
7012         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1);
7013         LDKType msg_conv = *(LDKType*)(((uint64_t)msg) & ~1);
7014         LDKPublicKey sender_node_id_ref;
7015         CHECK(*((uint32_t*)sender_node_id) == 33);
7016         memcpy(sender_node_id_ref.compressed_form, (uint8_t*)(sender_node_id + 4), 33);
7017         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7018         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
7019         return (uint64_t)ret_conv;
7020 }
7021
7022 uint32_tArray  __attribute__((visibility("default"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
7023         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)(((uint64_t)this_arg) & ~1);
7024         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
7025         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7026         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7027         for (size_t z = 0; z < ret_var.datalen; z++) {
7028                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
7029                 *ret_conv_25_conv = ret_var.data[z];
7030                 ret_arr_ptr[z] = ((uint64_t)ret_conv_25_conv);
7031         }
7032         FREE(ret_var.data);
7033         return ret_arr;
7034 }
7035
7036 typedef struct LDKSocketDescriptor_JCalls {
7037         atomic_size_t refcnt;
7038         uint32_t send_data_meth;
7039         uint32_t disconnect_socket_meth;
7040         uint32_t eq_meth;
7041         uint32_t hash_meth;
7042 } LDKSocketDescriptor_JCalls;
7043 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
7044         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7045         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7046                 js_free(j_calls->send_data_meth);
7047                 js_free(j_calls->disconnect_socket_meth);
7048                 js_free(j_calls->eq_meth);
7049                 js_free(j_calls->hash_meth);
7050                 FREE(j_calls);
7051         }
7052 }
7053 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
7054         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7055         LDKu8slice data_var = data;
7056         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7057         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
7058         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
7059 }
7060 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
7061         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7062         js_invoke_function_0(j_calls->disconnect_socket_meth);
7063 }
7064 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
7065         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7066         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
7067         *other_arg_clone = SocketDescriptor_clone(other_arg);
7068         return js_invoke_function_1(j_calls->eq_meth, (uint64_t)other_arg_clone);
7069 }
7070 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
7071         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7072         return js_invoke_function_0(j_calls->hash_meth);
7073 }
7074 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
7075         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
7076         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7077 }
7078 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
7079         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
7080         atomic_init(&calls->refcnt, 1);
7081         //TODO: Assign calls->o from o
7082
7083         LDKSocketDescriptor ret = {
7084                 .this_arg = (void*) calls,
7085                 .send_data = send_data_LDKSocketDescriptor_jcall,
7086                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
7087                 .eq = eq_LDKSocketDescriptor_jcall,
7088                 .hash = hash_LDKSocketDescriptor_jcall,
7089                 .cloned = LDKSocketDescriptor_JCalls_cloned,
7090                 .free = LDKSocketDescriptor_JCalls_free,
7091         };
7092         return ret;
7093 }
7094 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
7095         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
7096         *res_ptr = LDKSocketDescriptor_init(o);
7097         return (long)res_ptr;
7098 }
7099 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
7100         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
7101         LDKu8slice data_ref;
7102         data_ref.datalen = *((uint32_t*)data);
7103         data_ref.data = (int8_t*)(data + 4);
7104         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
7105         return ret_val;
7106 }
7107
7108 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
7109         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
7110         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
7111 }
7112
7113 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
7114         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
7115         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
7116         return ret_val;
7117 }
7118
7119 typedef struct LDKChannelManagerPersister_JCalls {
7120         atomic_size_t refcnt;
7121         uint32_t persist_manager_meth;
7122 } LDKChannelManagerPersister_JCalls;
7123 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
7124         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
7125         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7126                 js_free(j_calls->persist_manager_meth);
7127                 FREE(j_calls);
7128         }
7129 }
7130 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
7131         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
7132         LDKChannelManager channel_manager_var = *channel_manager;
7133         // Warning: we may need a move here but no clone is available for LDKChannelManager
7134         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7135         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7136         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
7137         if (channel_manager_var.is_owned) {
7138                 channel_manager_ref |= 1;
7139         }
7140         uint32_t ret = js_invoke_function_1(j_calls->persist_manager_meth, channel_manager_ref);
7141         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
7142         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
7143         return ret_conv;
7144 }
7145 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
7146         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
7147         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7148 }
7149 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (/*TODO: JS Object Reference */void* o) {
7150         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
7151         atomic_init(&calls->refcnt, 1);
7152         //TODO: Assign calls->o from o
7153
7154         LDKChannelManagerPersister ret = {
7155                 .this_arg = (void*) calls,
7156                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
7157                 .free = LDKChannelManagerPersister_JCalls_free,
7158         };
7159         return ret;
7160 }
7161 long  __attribute__((visibility("default"))) TS_LDKChannelManagerPersister_new(/*TODO: JS Object Reference */void* o) {
7162         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
7163         *res_ptr = LDKChannelManagerPersister_init(o);
7164         return (long)res_ptr;
7165 }
7166 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerPersister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
7167         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
7168         LDKChannelManager channel_manager_conv;
7169         channel_manager_conv.inner = (void*)(channel_manager & (~1));
7170         channel_manager_conv.is_owned = false;
7171         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
7172         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
7173         return (uint64_t)ret_conv;
7174 }
7175
7176 uint32_t __attribute__((visibility("default"))) TS_LDKFallback_ref_from_ptr(uint32_t ptr) {
7177         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
7178         switch(obj->tag) {
7179                 case LDKFallback_SegWitProgram: {
7180                         uint8_t version_val = obj->seg_wit_program.version._0;
7181                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
7182                         int8_tArray program_arr = init_arr(program_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7183                         memcpy((uint8_t*)(program_arr + 4), program_var.data, program_var.datalen);
7184                         return 0 /* LDKFallback - SegWitProgram */; (void) version_val; (void) program_arr;
7185                 }
7186                 case LDKFallback_PubKeyHash: {
7187                         int8_tArray pub_key_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
7188                         memcpy((uint8_t*)(pub_key_hash_arr + 4), obj->pub_key_hash.data, 20);
7189                         return 0 /* LDKFallback - PubKeyHash */; (void) pub_key_hash_arr;
7190                 }
7191                 case LDKFallback_ScriptHash: {
7192                         int8_tArray script_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
7193                         memcpy((uint8_t*)(script_hash_arr + 4), obj->script_hash.data, 20);
7194                         return 0 /* LDKFallback - ScriptHash */; (void) script_hash_arr;
7195                 }
7196                 default: abort();
7197         }
7198 }
7199 jstring  __attribute__((visibility("default"))) TS__ldk_get_compiled_version() {
7200         LDKStr ret_str = _ldk_get_compiled_version();
7201         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
7202         Str_free(ret_str);
7203         return ret_conv;
7204 }
7205
7206 jstring  __attribute__((visibility("default"))) TS__ldk_c_bindings_get_compiled_version() {
7207         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
7208         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
7209         Str_free(ret_str);
7210         return ret_conv;
7211 }
7212
7213 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
7214         LDKTransaction _res_ref;
7215         _res_ref.datalen = *((uint32_t*)_res);
7216         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
7217         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
7218         _res_ref.data_is_owned = true;
7219         Transaction_free(_res_ref);
7220 }
7221
7222 uint32_t  __attribute__((visibility("default"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
7223         LDKCVec_u8Z script_pubkey_ref;
7224         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
7225         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
7226         memcpy(script_pubkey_ref.data, (uint8_t*)(script_pubkey + 4), script_pubkey_ref.datalen);
7227         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7228         *ret_ref = TxOut_new(script_pubkey_ref, value);
7229         return (uint64_t)ret_ref;
7230 }
7231
7232 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
7233         if ((_res & 1) != 0) return;
7234         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
7235         FREE((void*)_res);
7236         TxOut_free(_res_conv);
7237 }
7238
7239 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
7240         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
7241         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7242         *ret_ref = TxOut_clone(orig_conv);
7243         return (uint64_t)ret_ref;
7244 }
7245
7246 void  __attribute__((visibility("default"))) TS_Str_free(jstring _res) {
7247         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
7248         Str_free(dummy);
7249 }
7250
7251 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
7252         LDKSecretKey o_ref;
7253         CHECK(*((uint32_t*)o) == 32);
7254         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
7255         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
7256         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
7257         return (uint64_t)ret_conv;
7258 }
7259
7260 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
7261         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
7262         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
7263         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
7264         return (uint64_t)ret_conv;
7265 }
7266
7267 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
7268         if ((_res & 1) != 0) return;
7269         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
7270         FREE((void*)_res);
7271         CResult_SecretKeyErrorZ_free(_res_conv);
7272 }
7273
7274 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
7275         LDKPublicKey o_ref;
7276         CHECK(*((uint32_t*)o) == 33);
7277         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
7278         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
7279         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
7280         return (uint64_t)ret_conv;
7281 }
7282
7283 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
7284         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
7285         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
7286         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
7287         return (uint64_t)ret_conv;
7288 }
7289
7290 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
7291         if ((_res & 1) != 0) return;
7292         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
7293         FREE((void*)_res);
7294         CResult_PublicKeyErrorZ_free(_res_conv);
7295 }
7296
7297 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
7298         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
7299         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
7300         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
7301         return (uint64_t)ret_conv;
7302 }
7303
7304 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
7305         LDKTxCreationKeys o_conv;
7306         o_conv.inner = (void*)(o & (~1));
7307         o_conv.is_owned = (o & 1) || (o == 0);
7308         o_conv = TxCreationKeys_clone(&o_conv);
7309         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
7310         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
7311         return (uint64_t)ret_conv;
7312 }
7313
7314 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
7315         LDKDecodeError e_conv;
7316         e_conv.inner = (void*)(e & (~1));
7317         e_conv.is_owned = (e & 1) || (e == 0);
7318         e_conv = DecodeError_clone(&e_conv);
7319         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
7320         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
7321         return (uint64_t)ret_conv;
7322 }
7323
7324 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
7325         if ((_res & 1) != 0) return;
7326         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
7327         FREE((void*)_res);
7328         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
7329 }
7330
7331 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
7332         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
7333         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
7334         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
7335         return (uint64_t)ret_conv;
7336 }
7337
7338 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
7339         LDKChannelPublicKeys o_conv;
7340         o_conv.inner = (void*)(o & (~1));
7341         o_conv.is_owned = (o & 1) || (o == 0);
7342         o_conv = ChannelPublicKeys_clone(&o_conv);
7343         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
7344         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
7345         return (uint64_t)ret_conv;
7346 }
7347
7348 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
7349         LDKDecodeError e_conv;
7350         e_conv.inner = (void*)(e & (~1));
7351         e_conv.is_owned = (e & 1) || (e == 0);
7352         e_conv = DecodeError_clone(&e_conv);
7353         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
7354         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
7355         return (uint64_t)ret_conv;
7356 }
7357
7358 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
7359         if ((_res & 1) != 0) return;
7360         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
7361         FREE((void*)_res);
7362         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
7363 }
7364
7365 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
7366         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
7367         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
7368         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
7369         return (uint64_t)ret_conv;
7370 }
7371
7372 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
7373         LDKTxCreationKeys o_conv;
7374         o_conv.inner = (void*)(o & (~1));
7375         o_conv.is_owned = (o & 1) || (o == 0);
7376         o_conv = TxCreationKeys_clone(&o_conv);
7377         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
7378         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
7379         return (uint64_t)ret_conv;
7380 }
7381
7382 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
7383         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
7384         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
7385         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
7386         return (uint64_t)ret_conv;
7387 }
7388
7389 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
7390         if ((_res & 1) != 0) return;
7391         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
7392         FREE((void*)_res);
7393         CResult_TxCreationKeysErrorZ_free(_res_conv);
7394 }
7395
7396 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
7397         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
7398         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
7399         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
7400         return (uint64_t)ret_conv;
7401 }
7402
7403 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_some(int32_t o) {
7404         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
7405         *ret_copy = COption_u32Z_some(o);
7406         uint64_t ret_ref = (uint64_t)ret_copy;
7407         return ret_ref;
7408 }
7409
7410 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_none() {
7411         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
7412         *ret_copy = COption_u32Z_none();
7413         uint64_t ret_ref = (uint64_t)ret_copy;
7414         return ret_ref;
7415 }
7416
7417 void  __attribute__((visibility("default"))) TS_COption_u32Z_free(uint32_t _res) {
7418         if ((_res & 1) != 0) return;
7419         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
7420         FREE((void*)_res);
7421         COption_u32Z_free(_res_conv);
7422 }
7423
7424 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_clone(uint32_t orig) {
7425         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
7426         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
7427         *ret_copy = COption_u32Z_clone(orig_conv);
7428         uint64_t ret_ref = (uint64_t)ret_copy;
7429         return ret_ref;
7430 }
7431
7432 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
7433         LDKHTLCOutputInCommitment o_conv;
7434         o_conv.inner = (void*)(o & (~1));
7435         o_conv.is_owned = (o & 1) || (o == 0);
7436         o_conv = HTLCOutputInCommitment_clone(&o_conv);
7437         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
7438         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
7439         return (uint64_t)ret_conv;
7440 }
7441
7442 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
7443         LDKDecodeError e_conv;
7444         e_conv.inner = (void*)(e & (~1));
7445         e_conv.is_owned = (e & 1) || (e == 0);
7446         e_conv = DecodeError_clone(&e_conv);
7447         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
7448         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
7449         return (uint64_t)ret_conv;
7450 }
7451
7452 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
7453         if ((_res & 1) != 0) return;
7454         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
7455         FREE((void*)_res);
7456         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
7457 }
7458
7459 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
7460         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
7461         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
7462         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
7463         return (uint64_t)ret_conv;
7464 }
7465
7466 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
7467         LDKCounterpartyChannelTransactionParameters o_conv;
7468         o_conv.inner = (void*)(o & (~1));
7469         o_conv.is_owned = (o & 1) || (o == 0);
7470         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
7471         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
7472         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
7473         return (uint64_t)ret_conv;
7474 }
7475
7476 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
7477         LDKDecodeError e_conv;
7478         e_conv.inner = (void*)(e & (~1));
7479         e_conv.is_owned = (e & 1) || (e == 0);
7480         e_conv = DecodeError_clone(&e_conv);
7481         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
7482         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
7483         return (uint64_t)ret_conv;
7484 }
7485
7486 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
7487         if ((_res & 1) != 0) return;
7488         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
7489         FREE((void*)_res);
7490         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
7491 }
7492
7493 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
7494         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
7495         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
7496         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
7497         return (uint64_t)ret_conv;
7498 }
7499
7500 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
7501         LDKChannelTransactionParameters o_conv;
7502         o_conv.inner = (void*)(o & (~1));
7503         o_conv.is_owned = (o & 1) || (o == 0);
7504         o_conv = ChannelTransactionParameters_clone(&o_conv);
7505         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
7506         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
7507         return (uint64_t)ret_conv;
7508 }
7509
7510 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
7511         LDKDecodeError e_conv;
7512         e_conv.inner = (void*)(e & (~1));
7513         e_conv.is_owned = (e & 1) || (e == 0);
7514         e_conv = DecodeError_clone(&e_conv);
7515         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
7516         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
7517         return (uint64_t)ret_conv;
7518 }
7519
7520 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
7521         if ((_res & 1) != 0) return;
7522         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
7523         FREE((void*)_res);
7524         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
7525 }
7526
7527 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
7528         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
7529         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
7530         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
7531         return (uint64_t)ret_conv;
7532 }
7533
7534 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
7535         LDKCVec_SignatureZ _res_constr;
7536         _res_constr.datalen = *((uint32_t*)_res);
7537         if (_res_constr.datalen > 0)
7538                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7539         else
7540                 _res_constr.data = NULL;
7541         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
7542         for (size_t m = 0; m < _res_constr.datalen; m++) {
7543                 int8_tArray _res_conv_12 = _res_vals[m];
7544                 LDKSignature _res_conv_12_ref;
7545                 CHECK(*((uint32_t*)_res_conv_12) == 64);
7546                 memcpy(_res_conv_12_ref.compact_form, (uint8_t*)(_res_conv_12 + 4), 64);
7547                 _res_constr.data[m] = _res_conv_12_ref;
7548         }
7549         CVec_SignatureZ_free(_res_constr);
7550 }
7551
7552 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
7553         LDKHolderCommitmentTransaction o_conv;
7554         o_conv.inner = (void*)(o & (~1));
7555         o_conv.is_owned = (o & 1) || (o == 0);
7556         o_conv = HolderCommitmentTransaction_clone(&o_conv);
7557         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
7558         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
7559         return (uint64_t)ret_conv;
7560 }
7561
7562 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
7563         LDKDecodeError e_conv;
7564         e_conv.inner = (void*)(e & (~1));
7565         e_conv.is_owned = (e & 1) || (e == 0);
7566         e_conv = DecodeError_clone(&e_conv);
7567         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
7568         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
7569         return (uint64_t)ret_conv;
7570 }
7571
7572 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
7573         if ((_res & 1) != 0) return;
7574         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
7575         FREE((void*)_res);
7576         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
7577 }
7578
7579 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
7580         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
7581         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
7582         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
7583         return (uint64_t)ret_conv;
7584 }
7585
7586 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
7587         LDKBuiltCommitmentTransaction o_conv;
7588         o_conv.inner = (void*)(o & (~1));
7589         o_conv.is_owned = (o & 1) || (o == 0);
7590         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
7591         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
7592         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
7593         return (uint64_t)ret_conv;
7594 }
7595
7596 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
7597         LDKDecodeError e_conv;
7598         e_conv.inner = (void*)(e & (~1));
7599         e_conv.is_owned = (e & 1) || (e == 0);
7600         e_conv = DecodeError_clone(&e_conv);
7601         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
7602         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
7603         return (uint64_t)ret_conv;
7604 }
7605
7606 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
7607         if ((_res & 1) != 0) return;
7608         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
7609         FREE((void*)_res);
7610         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
7611 }
7612
7613 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
7614         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
7615         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
7616         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
7617         return (uint64_t)ret_conv;
7618 }
7619
7620 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
7621         LDKTrustedClosingTransaction o_conv;
7622         o_conv.inner = (void*)(o & (~1));
7623         o_conv.is_owned = (o & 1) || (o == 0);
7624         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
7625         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
7626         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
7627         return (uint64_t)ret_conv;
7628 }
7629
7630 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
7631         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
7632         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
7633         return (uint64_t)ret_conv;
7634 }
7635
7636 void  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
7637         if ((_res & 1) != 0) return;
7638         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(((uint64_t)_res) & ~1);
7639         FREE((void*)_res);
7640         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
7641 }
7642
7643 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
7644         LDKCommitmentTransaction o_conv;
7645         o_conv.inner = (void*)(o & (~1));
7646         o_conv.is_owned = (o & 1) || (o == 0);
7647         o_conv = CommitmentTransaction_clone(&o_conv);
7648         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
7649         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
7650         return (uint64_t)ret_conv;
7651 }
7652
7653 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
7654         LDKDecodeError e_conv;
7655         e_conv.inner = (void*)(e & (~1));
7656         e_conv.is_owned = (e & 1) || (e == 0);
7657         e_conv = DecodeError_clone(&e_conv);
7658         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
7659         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
7660         return (uint64_t)ret_conv;
7661 }
7662
7663 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
7664         if ((_res & 1) != 0) return;
7665         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
7666         FREE((void*)_res);
7667         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
7668 }
7669
7670 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
7671         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
7672         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
7673         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
7674         return (uint64_t)ret_conv;
7675 }
7676
7677 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
7678         LDKTrustedCommitmentTransaction o_conv;
7679         o_conv.inner = (void*)(o & (~1));
7680         o_conv.is_owned = (o & 1) || (o == 0);
7681         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
7682         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
7683         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
7684         return (uint64_t)ret_conv;
7685 }
7686
7687 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
7688         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
7689         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
7690         return (uint64_t)ret_conv;
7691 }
7692
7693 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
7694         if ((_res & 1) != 0) return;
7695         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
7696         FREE((void*)_res);
7697         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
7698 }
7699
7700 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
7701         LDKCVec_SignatureZ o_constr;
7702         o_constr.datalen = *((uint32_t*)o);
7703         if (o_constr.datalen > 0)
7704                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
7705         else
7706                 o_constr.data = NULL;
7707         int8_tArray* o_vals = (int8_tArray*)(o + 4);
7708         for (size_t m = 0; m < o_constr.datalen; m++) {
7709                 int8_tArray o_conv_12 = o_vals[m];
7710                 LDKSignature o_conv_12_ref;
7711                 CHECK(*((uint32_t*)o_conv_12) == 64);
7712                 memcpy(o_conv_12_ref.compact_form, (uint8_t*)(o_conv_12 + 4), 64);
7713                 o_constr.data[m] = o_conv_12_ref;
7714         }
7715         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7716         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
7717         return (uint64_t)ret_conv;
7718 }
7719
7720 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
7721         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7722         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
7723         return (uint64_t)ret_conv;
7724 }
7725
7726 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
7727         if ((_res & 1) != 0) return;
7728         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
7729         FREE((void*)_res);
7730         CResult_CVec_SignatureZNoneZ_free(_res_conv);
7731 }
7732
7733 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
7734         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
7735         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
7736         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
7737         return (uint64_t)ret_conv;
7738 }
7739
7740 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
7741         LDKShutdownScript o_conv;
7742         o_conv.inner = (void*)(o & (~1));
7743         o_conv.is_owned = (o & 1) || (o == 0);
7744         o_conv = ShutdownScript_clone(&o_conv);
7745         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
7746         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
7747         return (uint64_t)ret_conv;
7748 }
7749
7750 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
7751         LDKDecodeError e_conv;
7752         e_conv.inner = (void*)(e & (~1));
7753         e_conv.is_owned = (e & 1) || (e == 0);
7754         e_conv = DecodeError_clone(&e_conv);
7755         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
7756         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
7757         return (uint64_t)ret_conv;
7758 }
7759
7760 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
7761         if ((_res & 1) != 0) return;
7762         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(((uint64_t)_res) & ~1);
7763         FREE((void*)_res);
7764         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
7765 }
7766
7767 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
7768         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
7769         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
7770         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
7771         return (uint64_t)ret_conv;
7772 }
7773
7774 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
7775         LDKShutdownScript o_conv;
7776         o_conv.inner = (void*)(o & (~1));
7777         o_conv.is_owned = (o & 1) || (o == 0);
7778         o_conv = ShutdownScript_clone(&o_conv);
7779         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
7780         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
7781         return (uint64_t)ret_conv;
7782 }
7783
7784 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
7785         LDKInvalidShutdownScript e_conv;
7786         e_conv.inner = (void*)(e & (~1));
7787         e_conv.is_owned = (e & 1) || (e == 0);
7788         // Warning: we need a move here but no clone is available for LDKInvalidShutdownScript
7789         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
7790         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
7791         return (uint64_t)ret_conv;
7792 }
7793
7794 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
7795         if ((_res & 1) != 0) return;
7796         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(((uint64_t)_res) & ~1);
7797         FREE((void*)_res);
7798         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
7799 }
7800
7801 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() {
7802         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
7803         *ret_conv = CResult_NoneErrorZ_ok();
7804         return (uint64_t)ret_conv;
7805 }
7806
7807 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
7808         LDKIOError e_conv = LDKIOError_from_js(e);
7809         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
7810         *ret_conv = CResult_NoneErrorZ_err(e_conv);
7811         return (uint64_t)ret_conv;
7812 }
7813
7814 void  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
7815         if ((_res & 1) != 0) return;
7816         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
7817         FREE((void*)_res);
7818         CResult_NoneErrorZ_free(_res_conv);
7819 }
7820
7821 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
7822         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
7823         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
7824         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
7825         return (uint64_t)ret_conv;
7826 }
7827
7828 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
7829         LDKRouteHop o_conv;
7830         o_conv.inner = (void*)(o & (~1));
7831         o_conv.is_owned = (o & 1) || (o == 0);
7832         o_conv = RouteHop_clone(&o_conv);
7833         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
7834         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
7835         return (uint64_t)ret_conv;
7836 }
7837
7838 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
7839         LDKDecodeError e_conv;
7840         e_conv.inner = (void*)(e & (~1));
7841         e_conv.is_owned = (e & 1) || (e == 0);
7842         e_conv = DecodeError_clone(&e_conv);
7843         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
7844         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
7845         return (uint64_t)ret_conv;
7846 }
7847
7848 void  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
7849         if ((_res & 1) != 0) return;
7850         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
7851         FREE((void*)_res);
7852         CResult_RouteHopDecodeErrorZ_free(_res_conv);
7853 }
7854
7855 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
7856         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
7857         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
7858         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
7859         return (uint64_t)ret_conv;
7860 }
7861
7862 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
7863         LDKCVec_RouteHopZ _res_constr;
7864         _res_constr.datalen = *((uint32_t*)_res);
7865         if (_res_constr.datalen > 0)
7866                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7867         else
7868                 _res_constr.data = NULL;
7869         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7870         for (size_t k = 0; k < _res_constr.datalen; k++) {
7871                 uint32_t _res_conv_10 = _res_vals[k];
7872                 LDKRouteHop _res_conv_10_conv;
7873                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
7874                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
7875                 _res_constr.data[k] = _res_conv_10_conv;
7876         }
7877         CVec_RouteHopZ_free(_res_constr);
7878 }
7879
7880 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
7881         LDKCVec_CVec_RouteHopZZ _res_constr;
7882         _res_constr.datalen = *((uint32_t*)_res);
7883         if (_res_constr.datalen > 0)
7884                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
7885         else
7886                 _res_constr.data = NULL;
7887         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
7888         for (size_t m = 0; m < _res_constr.datalen; m++) {
7889                 uint32_tArray _res_conv_12 = _res_vals[m];
7890                 LDKCVec_RouteHopZ _res_conv_12_constr;
7891                 _res_conv_12_constr.datalen = *((uint32_t*)_res_conv_12);
7892                 if (_res_conv_12_constr.datalen > 0)
7893                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7894                 else
7895                         _res_conv_12_constr.data = NULL;
7896                 uint32_t* _res_conv_12_vals = (uint32_t*)(_res_conv_12 + 4);
7897                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
7898                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
7899                         LDKRouteHop _res_conv_12_conv_10_conv;
7900                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
7901                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
7902                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
7903                 }
7904                 _res_constr.data[m] = _res_conv_12_constr;
7905         }
7906         CVec_CVec_RouteHopZZ_free(_res_constr);
7907 }
7908
7909 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
7910         LDKRoute o_conv;
7911         o_conv.inner = (void*)(o & (~1));
7912         o_conv.is_owned = (o & 1) || (o == 0);
7913         o_conv = Route_clone(&o_conv);
7914         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7915         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
7916         return (uint64_t)ret_conv;
7917 }
7918
7919 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
7920         LDKDecodeError e_conv;
7921         e_conv.inner = (void*)(e & (~1));
7922         e_conv.is_owned = (e & 1) || (e == 0);
7923         e_conv = DecodeError_clone(&e_conv);
7924         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7925         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
7926         return (uint64_t)ret_conv;
7927 }
7928
7929 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
7930         if ((_res & 1) != 0) return;
7931         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
7932         FREE((void*)_res);
7933         CResult_RouteDecodeErrorZ_free(_res_conv);
7934 }
7935
7936 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
7937         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
7938         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
7939         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
7940         return (uint64_t)ret_conv;
7941 }
7942
7943 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_some(int64_t o) {
7944         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7945         *ret_copy = COption_u64Z_some(o);
7946         uint64_t ret_ref = (uint64_t)ret_copy;
7947         return ret_ref;
7948 }
7949
7950 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_none() {
7951         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7952         *ret_copy = COption_u64Z_none();
7953         uint64_t ret_ref = (uint64_t)ret_copy;
7954         return ret_ref;
7955 }
7956
7957 void  __attribute__((visibility("default"))) TS_COption_u64Z_free(uint32_t _res) {
7958         if ((_res & 1) != 0) return;
7959         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
7960         FREE((void*)_res);
7961         COption_u64Z_free(_res_conv);
7962 }
7963
7964 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone(uint32_t orig) {
7965         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
7966         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7967         *ret_copy = COption_u64Z_clone(orig_conv);
7968         uint64_t ret_ref = (uint64_t)ret_copy;
7969         return ret_ref;
7970 }
7971
7972 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
7973         LDKCVec_ChannelDetailsZ _res_constr;
7974         _res_constr.datalen = *((uint32_t*)_res);
7975         if (_res_constr.datalen > 0)
7976                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
7977         else
7978                 _res_constr.data = NULL;
7979         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7980         for (size_t q = 0; q < _res_constr.datalen; q++) {
7981                 uint32_t _res_conv_16 = _res_vals[q];
7982                 LDKChannelDetails _res_conv_16_conv;
7983                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
7984                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
7985                 _res_constr.data[q] = _res_conv_16_conv;
7986         }
7987         CVec_ChannelDetailsZ_free(_res_constr);
7988 }
7989
7990 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
7991         LDKCVec_RouteHintZ _res_constr;
7992         _res_constr.datalen = *((uint32_t*)_res);
7993         if (_res_constr.datalen > 0)
7994                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
7995         else
7996                 _res_constr.data = NULL;
7997         uint32_t* _res_vals = (uint32_t*)(_res + 4);
7998         for (size_t l = 0; l < _res_constr.datalen; l++) {
7999                 uint32_t _res_conv_11 = _res_vals[l];
8000                 LDKRouteHint _res_conv_11_conv;
8001                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
8002                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
8003                 _res_constr.data[l] = _res_conv_11_conv;
8004         }
8005         CVec_RouteHintZ_free(_res_constr);
8006 }
8007
8008 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
8009         LDKRoute o_conv;
8010         o_conv.inner = (void*)(o & (~1));
8011         o_conv.is_owned = (o & 1) || (o == 0);
8012         o_conv = Route_clone(&o_conv);
8013         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8014         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
8015         return (uint64_t)ret_conv;
8016 }
8017
8018 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
8019         LDKLightningError e_conv;
8020         e_conv.inner = (void*)(e & (~1));
8021         e_conv.is_owned = (e & 1) || (e == 0);
8022         e_conv = LightningError_clone(&e_conv);
8023         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8024         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
8025         return (uint64_t)ret_conv;
8026 }
8027
8028 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
8029         if ((_res & 1) != 0) return;
8030         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
8031         FREE((void*)_res);
8032         CResult_RouteLightningErrorZ_free(_res_conv);
8033 }
8034
8035 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
8036         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
8037         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8038         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
8039         return (uint64_t)ret_conv;
8040 }
8041
8042 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
8043         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
8044         o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1));
8045         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8046         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
8047         return (uint64_t)ret_conv;
8048 }
8049
8050 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
8051         LDKAccessError e_conv = LDKAccessError_from_js(e);
8052         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8053         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
8054         return (uint64_t)ret_conv;
8055 }
8056
8057 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
8058         if ((_res & 1) != 0) return;
8059         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
8060         FREE((void*)_res);
8061         CResult_TxOutAccessErrorZ_free(_res_conv);
8062 }
8063
8064 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
8065         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
8066         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8067         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
8068         return (uint64_t)ret_conv;
8069 }
8070
8071 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
8072         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
8073         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8074         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
8075         return ((uint64_t)ret_conv);
8076 }
8077
8078 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
8079         LDKTransaction b_ref;
8080         b_ref.datalen = *((uint32_t*)b);
8081         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
8082         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
8083         b_ref.data_is_owned = true;
8084         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8085         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
8086         return ((uint64_t)ret_conv);
8087 }
8088
8089 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
8090         if ((_res & 1) != 0) return;
8091         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
8092         FREE((void*)_res);
8093         C2Tuple_usizeTransactionZ_free(_res_conv);
8094 }
8095
8096 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
8097         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
8098         _res_constr.datalen = *((uint32_t*)_res);
8099         if (_res_constr.datalen > 0)
8100                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8101         else
8102                 _res_constr.data = NULL;
8103         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8104         for (size_t c = 0; c < _res_constr.datalen; c++) {
8105                 uint32_t _res_conv_28 = _res_vals[c];
8106                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_28) & ~1);
8107                 FREE((void*)_res_conv_28);
8108                 _res_constr.data[c] = _res_conv_28_conv;
8109         }
8110         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
8111 }
8112
8113 void  __attribute__((visibility("default"))) TS_CVec_TxidZ_free(ptrArray _res) {
8114         LDKCVec_TxidZ _res_constr;
8115         _res_constr.datalen = *((uint32_t*)_res);
8116         if (_res_constr.datalen > 0)
8117                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
8118         else
8119                 _res_constr.data = NULL;
8120         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
8121         for (size_t m = 0; m < _res_constr.datalen; m++) {
8122                 int8_tArray _res_conv_12 = _res_vals[m];
8123                 LDKThirtyTwoBytes _res_conv_12_ref;
8124                 CHECK(*((uint32_t*)_res_conv_12) == 32);
8125                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), 32);
8126                 _res_constr.data[m] = _res_conv_12_ref;
8127         }
8128         CVec_TxidZ_free(_res_constr);
8129 }
8130
8131 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
8132         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8133         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
8134         return (uint64_t)ret_conv;
8135 }
8136
8137 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
8138         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
8139         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8140         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
8141         return (uint64_t)ret_conv;
8142 }
8143
8144 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
8145         if ((_res & 1) != 0) return;
8146         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
8147         FREE((void*)_res);
8148         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
8149 }
8150
8151 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
8152         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
8153         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8154         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
8155         return (uint64_t)ret_conv;
8156 }
8157
8158 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
8159         LDKCVec_MonitorEventZ _res_constr;
8160         _res_constr.datalen = *((uint32_t*)_res);
8161         if (_res_constr.datalen > 0)
8162                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
8163         else
8164                 _res_constr.data = NULL;
8165         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8166         for (size_t o = 0; o < _res_constr.datalen; o++) {
8167                 uint32_t _res_conv_14 = _res_vals[o];
8168                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
8169                 FREE((void*)_res_conv_14);
8170                 _res_constr.data[o] = _res_conv_14_conv;
8171         }
8172         CVec_MonitorEventZ_free(_res_constr);
8173 }
8174
8175 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
8176         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
8177         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1));
8178         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8179         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
8180         uint64_t ret_ref = (uint64_t)ret_copy;
8181         return ret_ref;
8182 }
8183
8184 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
8185         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8186         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
8187         uint64_t ret_ref = (uint64_t)ret_copy;
8188         return ret_ref;
8189 }
8190
8191 void  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
8192         if ((_res & 1) != 0) return;
8193         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
8194         FREE((void*)_res);
8195         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
8196 }
8197
8198 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
8199         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
8200         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8201         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
8202         uint64_t ret_ref = (uint64_t)ret_copy;
8203         return ret_ref;
8204 }
8205
8206 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
8207         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(((uint64_t)o) & ~1);
8208         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1));
8209         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
8210         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
8211         uint64_t ret_ref = (uint64_t)ret_copy;
8212         return ret_ref;
8213 }
8214
8215 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_none() {
8216         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
8217         *ret_copy = COption_NetworkUpdateZ_none();
8218         uint64_t ret_ref = (uint64_t)ret_copy;
8219         return ret_ref;
8220 }
8221
8222 void  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
8223         if ((_res & 1) != 0) return;
8224         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)_res) & ~1);
8225         FREE((void*)_res);
8226         COption_NetworkUpdateZ_free(_res_conv);
8227 }
8228
8229 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
8230         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
8231         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
8232         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
8233         uint64_t ret_ref = (uint64_t)ret_copy;
8234         return ret_ref;
8235 }
8236
8237 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
8238         LDKCVec_SpendableOutputDescriptorZ _res_constr;
8239         _res_constr.datalen = *((uint32_t*)_res);
8240         if (_res_constr.datalen > 0)
8241                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
8242         else
8243                 _res_constr.data = NULL;
8244         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8245         for (size_t b = 0; b < _res_constr.datalen; b++) {
8246                 uint32_t _res_conv_27 = _res_vals[b];
8247                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
8248                 FREE((void*)_res_conv_27);
8249                 _res_constr.data[b] = _res_conv_27_conv;
8250         }
8251         CVec_SpendableOutputDescriptorZ_free(_res_constr);
8252 }
8253
8254 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
8255         LDKCVec_MessageSendEventZ _res_constr;
8256         _res_constr.datalen = *((uint32_t*)_res);
8257         if (_res_constr.datalen > 0)
8258                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
8259         else
8260                 _res_constr.data = NULL;
8261         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8262         for (size_t s = 0; s < _res_constr.datalen; s++) {
8263                 uint32_t _res_conv_18 = _res_vals[s];
8264                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
8265                 FREE((void*)_res_conv_18);
8266                 _res_constr.data[s] = _res_conv_18_conv;
8267         }
8268         CVec_MessageSendEventZ_free(_res_constr);
8269 }
8270
8271 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
8272         LDKInitFeatures o_conv;
8273         o_conv.inner = (void*)(o & (~1));
8274         o_conv.is_owned = (o & 1) || (o == 0);
8275         o_conv = InitFeatures_clone(&o_conv);
8276         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
8277         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
8278         return (uint64_t)ret_conv;
8279 }
8280
8281 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
8282         LDKDecodeError e_conv;
8283         e_conv.inner = (void*)(e & (~1));
8284         e_conv.is_owned = (e & 1) || (e == 0);
8285         e_conv = DecodeError_clone(&e_conv);
8286         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
8287         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
8288         return (uint64_t)ret_conv;
8289 }
8290
8291 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
8292         if ((_res & 1) != 0) return;
8293         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8294         FREE((void*)_res);
8295         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
8296 }
8297
8298 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
8299         LDKNodeFeatures o_conv;
8300         o_conv.inner = (void*)(o & (~1));
8301         o_conv.is_owned = (o & 1) || (o == 0);
8302         o_conv = NodeFeatures_clone(&o_conv);
8303         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
8304         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
8305         return (uint64_t)ret_conv;
8306 }
8307
8308 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
8309         LDKDecodeError e_conv;
8310         e_conv.inner = (void*)(e & (~1));
8311         e_conv.is_owned = (e & 1) || (e == 0);
8312         e_conv = DecodeError_clone(&e_conv);
8313         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
8314         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
8315         return (uint64_t)ret_conv;
8316 }
8317
8318 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
8319         if ((_res & 1) != 0) return;
8320         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8321         FREE((void*)_res);
8322         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
8323 }
8324
8325 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
8326         LDKChannelFeatures o_conv;
8327         o_conv.inner = (void*)(o & (~1));
8328         o_conv.is_owned = (o & 1) || (o == 0);
8329         o_conv = ChannelFeatures_clone(&o_conv);
8330         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
8331         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
8332         return (uint64_t)ret_conv;
8333 }
8334
8335 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
8336         LDKDecodeError e_conv;
8337         e_conv.inner = (void*)(e & (~1));
8338         e_conv.is_owned = (e & 1) || (e == 0);
8339         e_conv = DecodeError_clone(&e_conv);
8340         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
8341         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
8342         return (uint64_t)ret_conv;
8343 }
8344
8345 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
8346         if ((_res & 1) != 0) return;
8347         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8348         FREE((void*)_res);
8349         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
8350 }
8351
8352 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
8353         LDKInvoiceFeatures o_conv;
8354         o_conv.inner = (void*)(o & (~1));
8355         o_conv.is_owned = (o & 1) || (o == 0);
8356         o_conv = InvoiceFeatures_clone(&o_conv);
8357         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
8358         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
8359         return (uint64_t)ret_conv;
8360 }
8361
8362 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
8363         LDKDecodeError e_conv;
8364         e_conv.inner = (void*)(e & (~1));
8365         e_conv.is_owned = (e & 1) || (e == 0);
8366         e_conv = DecodeError_clone(&e_conv);
8367         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
8368         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
8369         return (uint64_t)ret_conv;
8370 }
8371
8372 void  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
8373         if ((_res & 1) != 0) return;
8374         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
8375         FREE((void*)_res);
8376         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
8377 }
8378
8379 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
8380         LDKDelayedPaymentOutputDescriptor o_conv;
8381         o_conv.inner = (void*)(o & (~1));
8382         o_conv.is_owned = (o & 1) || (o == 0);
8383         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
8384         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
8385         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
8386         return (uint64_t)ret_conv;
8387 }
8388
8389 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
8390         LDKDecodeError e_conv;
8391         e_conv.inner = (void*)(e & (~1));
8392         e_conv.is_owned = (e & 1) || (e == 0);
8393         e_conv = DecodeError_clone(&e_conv);
8394         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
8395         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
8396         return (uint64_t)ret_conv;
8397 }
8398
8399 void  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
8400         if ((_res & 1) != 0) return;
8401         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
8402         FREE((void*)_res);
8403         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
8404 }
8405
8406 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
8407         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
8408         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
8409         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
8410         return (uint64_t)ret_conv;
8411 }
8412
8413 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
8414         LDKStaticPaymentOutputDescriptor o_conv;
8415         o_conv.inner = (void*)(o & (~1));
8416         o_conv.is_owned = (o & 1) || (o == 0);
8417         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
8418         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
8419         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
8420         return (uint64_t)ret_conv;
8421 }
8422
8423 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
8424         LDKDecodeError e_conv;
8425         e_conv.inner = (void*)(e & (~1));
8426         e_conv.is_owned = (e & 1) || (e == 0);
8427         e_conv = DecodeError_clone(&e_conv);
8428         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
8429         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
8430         return (uint64_t)ret_conv;
8431 }
8432
8433 void  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
8434         if ((_res & 1) != 0) return;
8435         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
8436         FREE((void*)_res);
8437         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
8438 }
8439
8440 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
8441         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
8442         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
8443         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
8444         return (uint64_t)ret_conv;
8445 }
8446
8447 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
8448         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
8449         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1));
8450         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8451         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
8452         return (uint64_t)ret_conv;
8453 }
8454
8455 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
8456         LDKDecodeError e_conv;
8457         e_conv.inner = (void*)(e & (~1));
8458         e_conv.is_owned = (e & 1) || (e == 0);
8459         e_conv = DecodeError_clone(&e_conv);
8460         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8461         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
8462         return (uint64_t)ret_conv;
8463 }
8464
8465 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
8466         if ((_res & 1) != 0) return;
8467         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
8468         FREE((void*)_res);
8469         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
8470 }
8471
8472 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
8473         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
8474         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
8475         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
8476         return (uint64_t)ret_conv;
8477 }
8478
8479 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_ok() {
8480         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
8481         *ret_conv = CResult_NoneNoneZ_ok();
8482         return (uint64_t)ret_conv;
8483 }
8484
8485 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_err() {
8486         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
8487         *ret_conv = CResult_NoneNoneZ_err();
8488         return (uint64_t)ret_conv;
8489 }
8490
8491 void  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
8492         if ((_res & 1) != 0) return;
8493         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(((uint64_t)_res) & ~1);
8494         FREE((void*)_res);
8495         CResult_NoneNoneZ_free(_res_conv);
8496 }
8497
8498 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
8499         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
8500         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
8501         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
8502         return (uint64_t)ret_conv;
8503 }
8504
8505 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
8506         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
8507         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
8508         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
8509         return ((uint64_t)ret_conv);
8510 }
8511
8512 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
8513         LDKSignature a_ref;
8514         CHECK(*((uint32_t*)a) == 64);
8515         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
8516         LDKCVec_SignatureZ b_constr;
8517         b_constr.datalen = *((uint32_t*)b);
8518         if (b_constr.datalen > 0)
8519                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8520         else
8521                 b_constr.data = NULL;
8522         int8_tArray* b_vals = (int8_tArray*)(b + 4);
8523         for (size_t m = 0; m < b_constr.datalen; m++) {
8524                 int8_tArray b_conv_12 = b_vals[m];
8525                 LDKSignature b_conv_12_ref;
8526                 CHECK(*((uint32_t*)b_conv_12) == 64);
8527                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
8528                 b_constr.data[m] = b_conv_12_ref;
8529         }
8530         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
8531         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
8532         return ((uint64_t)ret_conv);
8533 }
8534
8535 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
8536         if ((_res & 1) != 0) return;
8537         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
8538         FREE((void*)_res);
8539         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
8540 }
8541
8542 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
8543         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
8544         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1));
8545         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8546         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
8547         return (uint64_t)ret_conv;
8548 }
8549
8550 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
8551         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8552         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
8553         return (uint64_t)ret_conv;
8554 }
8555
8556 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
8557         if ((_res & 1) != 0) return;
8558         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
8559         FREE((void*)_res);
8560         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
8561 }
8562
8563 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
8564         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
8565         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
8566         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
8567         return (uint64_t)ret_conv;
8568 }
8569
8570 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
8571         LDKSignature o_ref;
8572         CHECK(*((uint32_t*)o) == 64);
8573         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
8574         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8575         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
8576         return (uint64_t)ret_conv;
8577 }
8578
8579 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
8580         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8581         *ret_conv = CResult_SignatureNoneZ_err();
8582         return (uint64_t)ret_conv;
8583 }
8584
8585 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
8586         if ((_res & 1) != 0) return;
8587         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
8588         FREE((void*)_res);
8589         CResult_SignatureNoneZ_free(_res_conv);
8590 }
8591
8592 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
8593         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
8594         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
8595         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
8596         return (uint64_t)ret_conv;
8597 }
8598
8599 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
8600         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
8601         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8602         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
8603         return (uint64_t)ret_conv;
8604 }
8605
8606 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
8607         LDKDecodeError e_conv;
8608         e_conv.inner = (void*)(e & (~1));
8609         e_conv.is_owned = (e & 1) || (e == 0);
8610         e_conv = DecodeError_clone(&e_conv);
8611         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8612         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
8613         return (uint64_t)ret_conv;
8614 }
8615
8616 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
8617         if ((_res & 1) != 0) return;
8618         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
8619         FREE((void*)_res);
8620         CResult_SignDecodeErrorZ_free(_res_conv);
8621 }
8622
8623 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
8624         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
8625         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
8626         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
8627         return (uint64_t)ret_conv;
8628 }
8629
8630 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
8631         LDKCVec_u8Z _res_ref;
8632         _res_ref.datalen = *((uint32_t*)_res);
8633         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
8634         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
8635         CVec_u8Z_free(_res_ref);
8636 }
8637
8638 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray arg) {
8639         LDKRecoverableSignature arg_ref;
8640         CHECK(*((uint32_t*)arg) == 68);
8641         memcpy(arg_ref.serialized_form, (uint8_t*)(arg + 4), 68);
8642         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
8643         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
8644         return (uint64_t)ret_conv;
8645 }
8646
8647 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_err() {
8648         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
8649         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
8650         return (uint64_t)ret_conv;
8651 }
8652
8653 void  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
8654         if ((_res & 1) != 0) return;
8655         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
8656         FREE((void*)_res);
8657         CResult_RecoverableSignatureNoneZ_free(_res_conv);
8658 }
8659
8660 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
8661         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
8662         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
8663         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
8664         return (uint64_t)ret_conv;
8665 }
8666
8667 void  __attribute__((visibility("default"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
8668         LDKCVec_CVec_u8ZZ _res_constr;
8669         _res_constr.datalen = *((uint32_t*)_res);
8670         if (_res_constr.datalen > 0)
8671                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
8672         else
8673                 _res_constr.data = NULL;
8674         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
8675         for (size_t m = 0; m < _res_constr.datalen; m++) {
8676                 int8_tArray _res_conv_12 = _res_vals[m];
8677                 LDKCVec_u8Z _res_conv_12_ref;
8678                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
8679                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
8680                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
8681                 _res_constr.data[m] = _res_conv_12_ref;
8682         }
8683         CVec_CVec_u8ZZ_free(_res_constr);
8684 }
8685
8686 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
8687         LDKCVec_CVec_u8ZZ o_constr;
8688         o_constr.datalen = *((uint32_t*)o);
8689         if (o_constr.datalen > 0)
8690                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
8691         else
8692                 o_constr.data = NULL;
8693         int8_tArray* o_vals = (int8_tArray*)(o + 4);
8694         for (size_t m = 0; m < o_constr.datalen; m++) {
8695                 int8_tArray o_conv_12 = o_vals[m];
8696                 LDKCVec_u8Z o_conv_12_ref;
8697                 o_conv_12_ref.datalen = *((uint32_t*)o_conv_12);
8698                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
8699                 memcpy(o_conv_12_ref.data, (uint8_t*)(o_conv_12 + 4), o_conv_12_ref.datalen);
8700                 o_constr.data[m] = o_conv_12_ref;
8701         }
8702         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8703         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
8704         return (uint64_t)ret_conv;
8705 }
8706
8707 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
8708         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8709         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
8710         return (uint64_t)ret_conv;
8711 }
8712
8713 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
8714         if ((_res & 1) != 0) return;
8715         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
8716         FREE((void*)_res);
8717         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
8718 }
8719
8720 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
8721         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
8722         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
8723         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
8724         return (uint64_t)ret_conv;
8725 }
8726
8727 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
8728         LDKInMemorySigner o_conv;
8729         o_conv.inner = (void*)(o & (~1));
8730         o_conv.is_owned = (o & 1) || (o == 0);
8731         o_conv = InMemorySigner_clone(&o_conv);
8732         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8733         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
8734         return (uint64_t)ret_conv;
8735 }
8736
8737 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
8738         LDKDecodeError e_conv;
8739         e_conv.inner = (void*)(e & (~1));
8740         e_conv.is_owned = (e & 1) || (e == 0);
8741         e_conv = DecodeError_clone(&e_conv);
8742         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8743         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
8744         return (uint64_t)ret_conv;
8745 }
8746
8747 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
8748         if ((_res & 1) != 0) return;
8749         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
8750         FREE((void*)_res);
8751         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
8752 }
8753
8754 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
8755         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
8756         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
8757         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
8758         return (uint64_t)ret_conv;
8759 }
8760
8761 void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
8762         LDKCVec_TxOutZ _res_constr;
8763         _res_constr.datalen = *((uint32_t*)_res);
8764         if (_res_constr.datalen > 0)
8765                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
8766         else
8767                 _res_constr.data = NULL;
8768         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8769         for (size_t h = 0; h < _res_constr.datalen; h++) {
8770                 uint32_t _res_conv_7 = _res_vals[h];
8771                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
8772                 FREE((void*)_res_conv_7);
8773                 _res_constr.data[h] = _res_conv_7_conv;
8774         }
8775         CVec_TxOutZ_free(_res_constr);
8776 }
8777
8778 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
8779         LDKTransaction o_ref;
8780         o_ref.datalen = *((uint32_t*)o);
8781         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
8782         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
8783         o_ref.data_is_owned = true;
8784         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8785         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
8786         return (uint64_t)ret_conv;
8787 }
8788
8789 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err() {
8790         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8791         *ret_conv = CResult_TransactionNoneZ_err();
8792         return (uint64_t)ret_conv;
8793 }
8794
8795 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
8796         if ((_res & 1) != 0) return;
8797         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
8798         FREE((void*)_res);
8799         CResult_TransactionNoneZ_free(_res_conv);
8800 }
8801
8802 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
8803         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
8804         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
8805         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
8806         return (uint64_t)ret_conv;
8807 }
8808
8809 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
8810         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
8811         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
8812         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
8813         return ((uint64_t)ret_conv);
8814 }
8815
8816 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
8817         LDKThirtyTwoBytes a_ref;
8818         CHECK(*((uint32_t*)a) == 32);
8819         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
8820         LDKChannelMonitor b_conv;
8821         b_conv.inner = (void*)(b & (~1));
8822         b_conv.is_owned = (b & 1) || (b == 0);
8823         b_conv = ChannelMonitor_clone(&b_conv);
8824         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
8825         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
8826         return ((uint64_t)ret_conv);
8827 }
8828
8829 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
8830         if ((_res & 1) != 0) return;
8831         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
8832         FREE((void*)_res);
8833         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
8834 }
8835
8836 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_BlockHashChannelMonitorZZ_free(uint32_tArray _res) {
8837         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
8838         _res_constr.datalen = *((uint32_t*)_res);
8839         if (_res_constr.datalen > 0)
8840                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
8841         else
8842                 _res_constr.data = NULL;
8843         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8844         for (size_t j = 0; j < _res_constr.datalen; j++) {
8845                 uint32_t _res_conv_35 = _res_vals[j];
8846                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_35) & ~1);
8847                 FREE((void*)_res_conv_35);
8848                 _res_constr.data[j] = _res_conv_35_conv;
8849         }
8850         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
8851 }
8852
8853 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(uint32_tArray o) {
8854         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
8855         o_constr.datalen = *((uint32_t*)o);
8856         if (o_constr.datalen > 0)
8857                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
8858         else
8859                 o_constr.data = NULL;
8860         uint32_t* o_vals = (uint32_t*)(o + 4);
8861         for (size_t j = 0; j < o_constr.datalen; j++) {
8862                 uint32_t o_conv_35 = o_vals[j];
8863                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1);
8864                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1));
8865                 o_constr.data[j] = o_conv_35_conv;
8866         }
8867         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
8868         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
8869         return (uint64_t)ret_conv;
8870 }
8871
8872 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(uint32_t e) {
8873         LDKIOError e_conv = LDKIOError_from_js(e);
8874         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
8875         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
8876         return (uint64_t)ret_conv;
8877 }
8878
8879 void  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(uint32_t _res) {
8880         if ((_res & 1) != 0) return;
8881         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
8882         FREE((void*)_res);
8883         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
8884 }
8885
8886 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(uint32_t orig) {
8887         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
8888         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
8889         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
8890         return (uint64_t)ret_conv;
8891 }
8892
8893 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_some(int16_t o) {
8894         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
8895         *ret_copy = COption_u16Z_some(o);
8896         uint64_t ret_ref = (uint64_t)ret_copy;
8897         return ret_ref;
8898 }
8899
8900 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_none() {
8901         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
8902         *ret_copy = COption_u16Z_none();
8903         uint64_t ret_ref = (uint64_t)ret_copy;
8904         return ret_ref;
8905 }
8906
8907 void  __attribute__((visibility("default"))) TS_COption_u16Z_free(uint32_t _res) {
8908         if ((_res & 1) != 0) return;
8909         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
8910         FREE((void*)_res);
8911         COption_u16Z_free(_res_conv);
8912 }
8913
8914 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_clone(uint32_t orig) {
8915         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
8916         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
8917         *ret_copy = COption_u16Z_clone(orig_conv);
8918         uint64_t ret_ref = (uint64_t)ret_copy;
8919         return ret_ref;
8920 }
8921
8922 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
8923         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8924         *ret_conv = CResult_NoneAPIErrorZ_ok();
8925         return (uint64_t)ret_conv;
8926 }
8927
8928 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
8929         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
8930         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
8931         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8932         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
8933         return (uint64_t)ret_conv;
8934 }
8935
8936 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
8937         if ((_res & 1) != 0) return;
8938         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
8939         FREE((void*)_res);
8940         CResult_NoneAPIErrorZ_free(_res_conv);
8941 }
8942
8943 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
8944         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
8945         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
8946         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
8947         return (uint64_t)ret_conv;
8948 }
8949
8950 void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
8951         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
8952         _res_constr.datalen = *((uint32_t*)_res);
8953         if (_res_constr.datalen > 0)
8954                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
8955         else
8956                 _res_constr.data = NULL;
8957         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8958         for (size_t w = 0; w < _res_constr.datalen; w++) {
8959                 uint32_t _res_conv_22 = _res_vals[w];
8960                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
8961                 FREE((void*)_res_conv_22);
8962                 _res_constr.data[w] = _res_conv_22_conv;
8963         }
8964         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
8965 }
8966
8967 void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
8968         LDKCVec_APIErrorZ _res_constr;
8969         _res_constr.datalen = *((uint32_t*)_res);
8970         if (_res_constr.datalen > 0)
8971                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
8972         else
8973                 _res_constr.data = NULL;
8974         uint32_t* _res_vals = (uint32_t*)(_res + 4);
8975         for (size_t k = 0; k < _res_constr.datalen; k++) {
8976                 uint32_t _res_conv_10 = _res_vals[k];
8977                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
8978                 FREE((void*)_res_conv_10);
8979                 _res_constr.data[k] = _res_conv_10_conv;
8980         }
8981         CVec_APIErrorZ_free(_res_constr);
8982 }
8983
8984 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
8985         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8986         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
8987         return (uint64_t)ret_conv;
8988 }
8989
8990 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
8991         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
8992         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
8993         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8994         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
8995         return (uint64_t)ret_conv;
8996 }
8997
8998 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
8999         if ((_res & 1) != 0) return;
9000         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
9001         FREE((void*)_res);
9002         CResult_NonePaymentSendFailureZ_free(_res_conv);
9003 }
9004
9005 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
9006         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
9007         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
9008         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
9009         return (uint64_t)ret_conv;
9010 }
9011
9012 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_ok(int8_tArray o) {
9013         LDKThirtyTwoBytes o_ref;
9014         CHECK(*((uint32_t*)o) == 32);
9015         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
9016         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
9017         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_ok(o_ref);
9018         return (uint64_t)ret_conv;
9019 }
9020
9021 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_err(uint32_t e) {
9022         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
9023         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
9024         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
9025         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv);
9026         return (uint64_t)ret_conv;
9027 }
9028
9029 void  __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_free(uint32_t _res) {
9030         if ((_res & 1) != 0) return;
9031         LDKCResult_PaymentHashPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentHashPaymentSendFailureZ*)(((uint64_t)_res) & ~1);
9032         FREE((void*)_res);
9033         CResult_PaymentHashPaymentSendFailureZ_free(_res_conv);
9034 }
9035
9036 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentHashPaymentSendFailureZ_clone(uint32_t orig) {
9037         LDKCResult_PaymentHashPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)(orig & ~1);
9038         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
9039         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(orig_conv);
9040         return (uint64_t)ret_conv;
9041 }
9042
9043 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
9044         LDKCVec_NetAddressZ _res_constr;
9045         _res_constr.datalen = *((uint32_t*)_res);
9046         if (_res_constr.datalen > 0)
9047                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
9048         else
9049                 _res_constr.data = NULL;
9050         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9051         for (size_t m = 0; m < _res_constr.datalen; m++) {
9052                 uint32_t _res_conv_12 = _res_vals[m];
9053                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
9054                 FREE((void*)_res_conv_12);
9055                 _res_constr.data[m] = _res_conv_12_conv;
9056         }
9057         CVec_NetAddressZ_free(_res_constr);
9058 }
9059
9060 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
9061         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
9062         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
9063         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
9064         return ((uint64_t)ret_conv);
9065 }
9066
9067 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
9068         LDKThirtyTwoBytes a_ref;
9069         CHECK(*((uint32_t*)a) == 32);
9070         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
9071         LDKThirtyTwoBytes b_ref;
9072         CHECK(*((uint32_t*)b) == 32);
9073         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
9074         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
9075         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
9076         return ((uint64_t)ret_conv);
9077 }
9078
9079 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
9080         if ((_res & 1) != 0) return;
9081         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
9082         FREE((void*)_res);
9083         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
9084 }
9085
9086 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
9087         LDKThirtyTwoBytes o_ref;
9088         CHECK(*((uint32_t*)o) == 32);
9089         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
9090         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
9091         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
9092         return (uint64_t)ret_conv;
9093 }
9094
9095 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
9096         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
9097         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
9098         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
9099         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
9100         return (uint64_t)ret_conv;
9101 }
9102
9103 void  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
9104         if ((_res & 1) != 0) return;
9105         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
9106         FREE((void*)_res);
9107         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
9108 }
9109
9110 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
9111         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
9112         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
9113         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
9114         return (uint64_t)ret_conv;
9115 }
9116
9117 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
9118         LDKCVec_ChannelMonitorZ _res_constr;
9119         _res_constr.datalen = *((uint32_t*)_res);
9120         if (_res_constr.datalen > 0)
9121                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
9122         else
9123                 _res_constr.data = NULL;
9124         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9125         for (size_t q = 0; q < _res_constr.datalen; q++) {
9126                 uint32_t _res_conv_16 = _res_vals[q];
9127                 LDKChannelMonitor _res_conv_16_conv;
9128                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9129                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9130                 _res_constr.data[q] = _res_conv_16_conv;
9131         }
9132         CVec_ChannelMonitorZ_free(_res_constr);
9133 }
9134
9135 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
9136         LDKThirtyTwoBytes a_ref;
9137         CHECK(*((uint32_t*)a) == 32);
9138         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
9139         LDKChannelManager b_conv;
9140         b_conv.inner = (void*)(b & (~1));
9141         b_conv.is_owned = (b & 1) || (b == 0);
9142         // Warning: we need a move here but no clone is available for LDKChannelManager
9143         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
9144         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
9145         return ((uint64_t)ret_conv);
9146 }
9147
9148 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
9149         if ((_res & 1) != 0) return;
9150         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
9151         FREE((void*)_res);
9152         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
9153 }
9154
9155 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
9156         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
9157         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
9158         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
9159         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
9160         return (uint64_t)ret_conv;
9161 }
9162
9163 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
9164         LDKDecodeError e_conv;
9165         e_conv.inner = (void*)(e & (~1));
9166         e_conv.is_owned = (e & 1) || (e == 0);
9167         e_conv = DecodeError_clone(&e_conv);
9168         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
9169         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
9170         return (uint64_t)ret_conv;
9171 }
9172
9173 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
9174         if ((_res & 1) != 0) return;
9175         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
9176         FREE((void*)_res);
9177         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
9178 }
9179
9180 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
9181         LDKChannelConfig o_conv;
9182         o_conv.inner = (void*)(o & (~1));
9183         o_conv.is_owned = (o & 1) || (o == 0);
9184         o_conv = ChannelConfig_clone(&o_conv);
9185         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9186         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
9187         return (uint64_t)ret_conv;
9188 }
9189
9190 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
9191         LDKDecodeError e_conv;
9192         e_conv.inner = (void*)(e & (~1));
9193         e_conv.is_owned = (e & 1) || (e == 0);
9194         e_conv = DecodeError_clone(&e_conv);
9195         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9196         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
9197         return (uint64_t)ret_conv;
9198 }
9199
9200 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
9201         if ((_res & 1) != 0) return;
9202         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
9203         FREE((void*)_res);
9204         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
9205 }
9206
9207 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
9208         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
9209         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9210         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
9211         return (uint64_t)ret_conv;
9212 }
9213
9214 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
9215         LDKOutPoint o_conv;
9216         o_conv.inner = (void*)(o & (~1));
9217         o_conv.is_owned = (o & 1) || (o == 0);
9218         o_conv = OutPoint_clone(&o_conv);
9219         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9220         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
9221         return (uint64_t)ret_conv;
9222 }
9223
9224 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
9225         LDKDecodeError e_conv;
9226         e_conv.inner = (void*)(e & (~1));
9227         e_conv.is_owned = (e & 1) || (e == 0);
9228         e_conv = DecodeError_clone(&e_conv);
9229         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9230         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
9231         return (uint64_t)ret_conv;
9232 }
9233
9234 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
9235         if ((_res & 1) != 0) return;
9236         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
9237         FREE((void*)_res);
9238         CResult_OutPointDecodeErrorZ_free(_res_conv);
9239 }
9240
9241 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
9242         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
9243         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9244         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
9245         return (uint64_t)ret_conv;
9246 }
9247
9248 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_some(uint32_t o) {
9249         LDKType o_conv = *(LDKType*)(((uint64_t)o) & ~1);
9250         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9251         *ret_copy = COption_TypeZ_some(o_conv);
9252         uint64_t ret_ref = (uint64_t)ret_copy;
9253         return ret_ref;
9254 }
9255
9256 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_none() {
9257         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9258         *ret_copy = COption_TypeZ_none();
9259         uint64_t ret_ref = (uint64_t)ret_copy;
9260         return ret_ref;
9261 }
9262
9263 void  __attribute__((visibility("default"))) TS_COption_TypeZ_free(uint32_t _res) {
9264         if ((_res & 1) != 0) return;
9265         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(((uint64_t)_res) & ~1);
9266         FREE((void*)_res);
9267         COption_TypeZ_free(_res_conv);
9268 }
9269
9270 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_clone(uint32_t orig) {
9271         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
9272         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9273         *ret_copy = COption_TypeZ_clone(orig_conv);
9274         uint64_t ret_ref = (uint64_t)ret_copy;
9275         return ret_ref;
9276 }
9277
9278 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
9279         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(((uint64_t)o) & ~1);
9280         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1));
9281         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9282         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
9283         return (uint64_t)ret_conv;
9284 }
9285
9286 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
9287         LDKDecodeError e_conv;
9288         e_conv.inner = (void*)(e & (~1));
9289         e_conv.is_owned = (e & 1) || (e == 0);
9290         e_conv = DecodeError_clone(&e_conv);
9291         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9292         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
9293         return (uint64_t)ret_conv;
9294 }
9295
9296 void  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
9297         if ((_res & 1) != 0) return;
9298         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(((uint64_t)_res) & ~1);
9299         FREE((void*)_res);
9300         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
9301 }
9302
9303 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
9304         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
9305         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9306         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
9307         return (uint64_t)ret_conv;
9308 }
9309
9310 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_ok(uint32_t o) {
9311         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
9312         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
9313         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
9314         return (uint64_t)ret_conv;
9315 }
9316
9317 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_err() {
9318         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
9319         *ret_conv = CResult_SiPrefixNoneZ_err();
9320         return (uint64_t)ret_conv;
9321 }
9322
9323 void  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_free(uint32_t _res) {
9324         if ((_res & 1) != 0) return;
9325         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
9326         FREE((void*)_res);
9327         CResult_SiPrefixNoneZ_free(_res_conv);
9328 }
9329
9330 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_clone(uint32_t orig) {
9331         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
9332         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
9333         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
9334         return (uint64_t)ret_conv;
9335 }
9336
9337 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_ok(uint32_t o) {
9338         LDKInvoice o_conv;
9339         o_conv.inner = (void*)(o & (~1));
9340         o_conv.is_owned = (o & 1) || (o == 0);
9341         o_conv = Invoice_clone(&o_conv);
9342         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
9343         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
9344         return (uint64_t)ret_conv;
9345 }
9346
9347 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_err() {
9348         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
9349         *ret_conv = CResult_InvoiceNoneZ_err();
9350         return (uint64_t)ret_conv;
9351 }
9352
9353 void  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_free(uint32_t _res) {
9354         if ((_res & 1) != 0) return;
9355         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
9356         FREE((void*)_res);
9357         CResult_InvoiceNoneZ_free(_res_conv);
9358 }
9359
9360 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_clone(uint32_t orig) {
9361         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
9362         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
9363         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
9364         return (uint64_t)ret_conv;
9365 }
9366
9367 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_ok(uint32_t o) {
9368         LDKSignedRawInvoice o_conv;
9369         o_conv.inner = (void*)(o & (~1));
9370         o_conv.is_owned = (o & 1) || (o == 0);
9371         o_conv = SignedRawInvoice_clone(&o_conv);
9372         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
9373         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
9374         return (uint64_t)ret_conv;
9375 }
9376
9377 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_err() {
9378         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
9379         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
9380         return (uint64_t)ret_conv;
9381 }
9382
9383 void  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_free(uint32_t _res) {
9384         if ((_res & 1) != 0) return;
9385         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
9386         FREE((void*)_res);
9387         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
9388 }
9389
9390 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_clone(uint32_t orig) {
9391         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
9392         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
9393         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
9394         return (uint64_t)ret_conv;
9395 }
9396
9397 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
9398         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
9399         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
9400         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
9401         return ((uint64_t)ret_conv);
9402 }
9403
9404 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
9405         LDKRawInvoice a_conv;
9406         a_conv.inner = (void*)(a & (~1));
9407         a_conv.is_owned = (a & 1) || (a == 0);
9408         a_conv = RawInvoice_clone(&a_conv);
9409         LDKThirtyTwoBytes b_ref;
9410         CHECK(*((uint32_t*)b) == 32);
9411         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
9412         LDKInvoiceSignature c_conv;
9413         c_conv.inner = (void*)(c & (~1));
9414         c_conv.is_owned = (c & 1) || (c == 0);
9415         c_conv = InvoiceSignature_clone(&c_conv);
9416         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
9417         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
9418         return ((uint64_t)ret_conv);
9419 }
9420
9421 void  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
9422         if ((_res & 1) != 0) return;
9423         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
9424         FREE((void*)_res);
9425         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
9426 }
9427
9428 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
9429         LDKPayeePubKey o_conv;
9430         o_conv.inner = (void*)(o & (~1));
9431         o_conv.is_owned = (o & 1) || (o == 0);
9432         o_conv = PayeePubKey_clone(&o_conv);
9433         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
9434         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
9435         return (uint64_t)ret_conv;
9436 }
9437
9438 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
9439         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
9440         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
9441         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
9442         return (uint64_t)ret_conv;
9443 }
9444
9445 void  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
9446         if ((_res & 1) != 0) return;
9447         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
9448         FREE((void*)_res);
9449         CResult_PayeePubKeyErrorZ_free(_res_conv);
9450 }
9451
9452 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
9453         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
9454         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
9455         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
9456         return (uint64_t)ret_conv;
9457 }
9458
9459 void  __attribute__((visibility("default"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
9460         LDKCVec_PrivateRouteZ _res_constr;
9461         _res_constr.datalen = *((uint32_t*)_res);
9462         if (_res_constr.datalen > 0)
9463                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
9464         else
9465                 _res_constr.data = NULL;
9466         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9467         for (size_t o = 0; o < _res_constr.datalen; o++) {
9468                 uint32_t _res_conv_14 = _res_vals[o];
9469                 LDKPrivateRoute _res_conv_14_conv;
9470                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
9471                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
9472                 _res_constr.data[o] = _res_conv_14_conv;
9473         }
9474         CVec_PrivateRouteZ_free(_res_constr);
9475 }
9476
9477 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
9478         LDKPositiveTimestamp o_conv;
9479         o_conv.inner = (void*)(o & (~1));
9480         o_conv.is_owned = (o & 1) || (o == 0);
9481         o_conv = PositiveTimestamp_clone(&o_conv);
9482         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
9483         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
9484         return (uint64_t)ret_conv;
9485 }
9486
9487 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
9488         LDKCreationError e_conv = LDKCreationError_from_js(e);
9489         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
9490         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
9491         return (uint64_t)ret_conv;
9492 }
9493
9494 void  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
9495         if ((_res & 1) != 0) return;
9496         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
9497         FREE((void*)_res);
9498         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
9499 }
9500
9501 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
9502         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
9503         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
9504         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
9505         return (uint64_t)ret_conv;
9506 }
9507
9508 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_ok() {
9509         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
9510         *ret_conv = CResult_NoneSemanticErrorZ_ok();
9511         return (uint64_t)ret_conv;
9512 }
9513
9514 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
9515         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
9516         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
9517         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
9518         return (uint64_t)ret_conv;
9519 }
9520
9521 void  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
9522         if ((_res & 1) != 0) return;
9523         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
9524         FREE((void*)_res);
9525         CResult_NoneSemanticErrorZ_free(_res_conv);
9526 }
9527
9528 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
9529         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
9530         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
9531         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
9532         return (uint64_t)ret_conv;
9533 }
9534
9535 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
9536         LDKInvoice o_conv;
9537         o_conv.inner = (void*)(o & (~1));
9538         o_conv.is_owned = (o & 1) || (o == 0);
9539         o_conv = Invoice_clone(&o_conv);
9540         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
9541         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
9542         return (uint64_t)ret_conv;
9543 }
9544
9545 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
9546         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
9547         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
9548         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
9549         return (uint64_t)ret_conv;
9550 }
9551
9552 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
9553         if ((_res & 1) != 0) return;
9554         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
9555         FREE((void*)_res);
9556         CResult_InvoiceSemanticErrorZ_free(_res_conv);
9557 }
9558
9559 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
9560         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
9561         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
9562         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
9563         return (uint64_t)ret_conv;
9564 }
9565
9566 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
9567         LDKDescription o_conv;
9568         o_conv.inner = (void*)(o & (~1));
9569         o_conv.is_owned = (o & 1) || (o == 0);
9570         o_conv = Description_clone(&o_conv);
9571         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
9572         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
9573         return (uint64_t)ret_conv;
9574 }
9575
9576 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
9577         LDKCreationError e_conv = LDKCreationError_from_js(e);
9578         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
9579         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
9580         return (uint64_t)ret_conv;
9581 }
9582
9583 void  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
9584         if ((_res & 1) != 0) return;
9585         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
9586         FREE((void*)_res);
9587         CResult_DescriptionCreationErrorZ_free(_res_conv);
9588 }
9589
9590 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
9591         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
9592         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
9593         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
9594         return (uint64_t)ret_conv;
9595 }
9596
9597 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_ok(uint32_t o) {
9598         LDKExpiryTime o_conv;
9599         o_conv.inner = (void*)(o & (~1));
9600         o_conv.is_owned = (o & 1) || (o == 0);
9601         o_conv = ExpiryTime_clone(&o_conv);
9602         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
9603         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
9604         return (uint64_t)ret_conv;
9605 }
9606
9607 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_err(uint32_t e) {
9608         LDKCreationError e_conv = LDKCreationError_from_js(e);
9609         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
9610         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
9611         return (uint64_t)ret_conv;
9612 }
9613
9614 void  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_free(uint32_t _res) {
9615         if ((_res & 1) != 0) return;
9616         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
9617         FREE((void*)_res);
9618         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
9619 }
9620
9621 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_clone(uint32_t orig) {
9622         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
9623         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
9624         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
9625         return (uint64_t)ret_conv;
9626 }
9627
9628 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
9629         LDKPrivateRoute o_conv;
9630         o_conv.inner = (void*)(o & (~1));
9631         o_conv.is_owned = (o & 1) || (o == 0);
9632         o_conv = PrivateRoute_clone(&o_conv);
9633         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
9634         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
9635         return (uint64_t)ret_conv;
9636 }
9637
9638 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
9639         LDKCreationError e_conv = LDKCreationError_from_js(e);
9640         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
9641         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
9642         return (uint64_t)ret_conv;
9643 }
9644
9645 void  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
9646         if ((_res & 1) != 0) return;
9647         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
9648         FREE((void*)_res);
9649         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
9650 }
9651
9652 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
9653         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
9654         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
9655         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
9656         return (uint64_t)ret_conv;
9657 }
9658
9659 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_ok(jstring o) {
9660         LDKStr o_conv = str_ref_to_owned_c(o);
9661         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
9662         *ret_conv = CResult_StringErrorZ_ok(o_conv);
9663         return (uint64_t)ret_conv;
9664 }
9665
9666 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_err(uint32_t e) {
9667         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
9668         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
9669         *ret_conv = CResult_StringErrorZ_err(e_conv);
9670         return (uint64_t)ret_conv;
9671 }
9672
9673 void  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
9674         if ((_res & 1) != 0) return;
9675         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
9676         FREE((void*)_res);
9677         CResult_StringErrorZ_free(_res_conv);
9678 }
9679
9680 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
9681         LDKChannelMonitorUpdate o_conv;
9682         o_conv.inner = (void*)(o & (~1));
9683         o_conv.is_owned = (o & 1) || (o == 0);
9684         o_conv = ChannelMonitorUpdate_clone(&o_conv);
9685         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
9686         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
9687         return (uint64_t)ret_conv;
9688 }
9689
9690 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
9691         LDKDecodeError e_conv;
9692         e_conv.inner = (void*)(e & (~1));
9693         e_conv.is_owned = (e & 1) || (e == 0);
9694         e_conv = DecodeError_clone(&e_conv);
9695         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
9696         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
9697         return (uint64_t)ret_conv;
9698 }
9699
9700 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
9701         if ((_res & 1) != 0) return;
9702         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
9703         FREE((void*)_res);
9704         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
9705 }
9706
9707 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
9708         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
9709         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
9710         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
9711         return (uint64_t)ret_conv;
9712 }
9713
9714 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
9715         LDKHTLCUpdate o_conv;
9716         o_conv.inner = (void*)(o & (~1));
9717         o_conv.is_owned = (o & 1) || (o == 0);
9718         o_conv = HTLCUpdate_clone(&o_conv);
9719         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
9720         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
9721         return (uint64_t)ret_conv;
9722 }
9723
9724 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
9725         LDKDecodeError e_conv;
9726         e_conv.inner = (void*)(e & (~1));
9727         e_conv.is_owned = (e & 1) || (e == 0);
9728         e_conv = DecodeError_clone(&e_conv);
9729         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
9730         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
9731         return (uint64_t)ret_conv;
9732 }
9733
9734 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
9735         if ((_res & 1) != 0) return;
9736         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
9737         FREE((void*)_res);
9738         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
9739 }
9740
9741 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
9742         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
9743         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
9744         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
9745         return (uint64_t)ret_conv;
9746 }
9747
9748 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
9749         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
9750         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
9751         return (uint64_t)ret_conv;
9752 }
9753
9754 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
9755         LDKMonitorUpdateError e_conv;
9756         e_conv.inner = (void*)(e & (~1));
9757         e_conv.is_owned = (e & 1) || (e == 0);
9758         e_conv = MonitorUpdateError_clone(&e_conv);
9759         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
9760         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
9761         return (uint64_t)ret_conv;
9762 }
9763
9764 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
9765         if ((_res & 1) != 0) return;
9766         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
9767         FREE((void*)_res);
9768         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
9769 }
9770
9771 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_clone(uint32_t orig) {
9772         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
9773         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
9774         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
9775         return (uint64_t)ret_conv;
9776 }
9777
9778 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
9779         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
9780         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
9781         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
9782         return ((uint64_t)ret_conv);
9783 }
9784
9785 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
9786         LDKOutPoint a_conv;
9787         a_conv.inner = (void*)(a & (~1));
9788         a_conv.is_owned = (a & 1) || (a == 0);
9789         a_conv = OutPoint_clone(&a_conv);
9790         LDKCVec_u8Z b_ref;
9791         b_ref.datalen = *((uint32_t*)b);
9792         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
9793         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
9794         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
9795         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
9796         return ((uint64_t)ret_conv);
9797 }
9798
9799 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
9800         if ((_res & 1) != 0) return;
9801         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
9802         FREE((void*)_res);
9803         C2Tuple_OutPointScriptZ_free(_res_conv);
9804 }
9805
9806 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
9807         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
9808         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
9809         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
9810         return ((uint64_t)ret_conv);
9811 }
9812
9813 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
9814         LDKCVec_u8Z b_ref;
9815         b_ref.datalen = *((uint32_t*)b);
9816         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
9817         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
9818         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
9819         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
9820         return ((uint64_t)ret_conv);
9821 }
9822
9823 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
9824         if ((_res & 1) != 0) return;
9825         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
9826         FREE((void*)_res);
9827         C2Tuple_u32ScriptZ_free(_res_conv);
9828 }
9829
9830 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
9831         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
9832         _res_constr.datalen = *((uint32_t*)_res);
9833         if (_res_constr.datalen > 0)
9834                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
9835         else
9836                 _res_constr.data = NULL;
9837         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9838         for (size_t v = 0; v < _res_constr.datalen; v++) {
9839                 uint32_t _res_conv_21 = _res_vals[v];
9840                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_21) & ~1);
9841                 FREE((void*)_res_conv_21);
9842                 _res_constr.data[v] = _res_conv_21_conv;
9843         }
9844         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
9845 }
9846
9847 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
9848         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
9849         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
9850         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
9851         return ((uint64_t)ret_conv);
9852 }
9853
9854 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
9855         LDKThirtyTwoBytes a_ref;
9856         CHECK(*((uint32_t*)a) == 32);
9857         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
9858         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
9859         b_constr.datalen = *((uint32_t*)b);
9860         if (b_constr.datalen > 0)
9861                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
9862         else
9863                 b_constr.data = NULL;
9864         uint32_t* b_vals = (uint32_t*)(b + 4);
9865         for (size_t v = 0; v < b_constr.datalen; v++) {
9866                 uint32_t b_conv_21 = b_vals[v];
9867                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1);
9868                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
9869                 b_constr.data[v] = b_conv_21_conv;
9870         }
9871         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
9872         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
9873         return ((uint64_t)ret_conv);
9874 }
9875
9876 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
9877         if ((_res & 1) != 0) return;
9878         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
9879         FREE((void*)_res);
9880         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
9881 }
9882
9883 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
9884         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
9885         _res_constr.datalen = *((uint32_t*)_res);
9886         if (_res_constr.datalen > 0)
9887                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
9888         else
9889                 _res_constr.data = NULL;
9890         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9891         for (size_t o = 0; o < _res_constr.datalen; o++) {
9892                 uint32_t _res_conv_40 = _res_vals[o];
9893                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_40) & ~1);
9894                 FREE((void*)_res_conv_40);
9895                 _res_constr.data[o] = _res_conv_40_conv;
9896         }
9897         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
9898 }
9899
9900 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
9901         LDKCVec_EventZ _res_constr;
9902         _res_constr.datalen = *((uint32_t*)_res);
9903         if (_res_constr.datalen > 0)
9904                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
9905         else
9906                 _res_constr.data = NULL;
9907         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9908         for (size_t h = 0; h < _res_constr.datalen; h++) {
9909                 uint32_t _res_conv_7 = _res_vals[h];
9910                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
9911                 FREE((void*)_res_conv_7);
9912                 _res_constr.data[h] = _res_conv_7_conv;
9913         }
9914         CVec_EventZ_free(_res_constr);
9915 }
9916
9917 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
9918         LDKCVec_TransactionZ _res_constr;
9919         _res_constr.datalen = *((uint32_t*)_res);
9920         if (_res_constr.datalen > 0)
9921                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
9922         else
9923                 _res_constr.data = NULL;
9924         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
9925         for (size_t m = 0; m < _res_constr.datalen; m++) {
9926                 int8_tArray _res_conv_12 = _res_vals[m];
9927                 LDKTransaction _res_conv_12_ref;
9928                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
9929                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
9930                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
9931                 _res_conv_12_ref.data_is_owned = true;
9932                 _res_constr.data[m] = _res_conv_12_ref;
9933         }
9934         CVec_TransactionZ_free(_res_constr);
9935 }
9936
9937 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
9938         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
9939         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
9940         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
9941         return ((uint64_t)ret_conv);
9942 }
9943
9944 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
9945         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
9946         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
9947         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
9948         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
9949         return ((uint64_t)ret_conv);
9950 }
9951
9952 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
9953         if ((_res & 1) != 0) return;
9954         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
9955         FREE((void*)_res);
9956         C2Tuple_u32TxOutZ_free(_res_conv);
9957 }
9958
9959 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
9960         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
9961         _res_constr.datalen = *((uint32_t*)_res);
9962         if (_res_constr.datalen > 0)
9963                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
9964         else
9965                 _res_constr.data = NULL;
9966         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9967         for (size_t u = 0; u < _res_constr.datalen; u++) {
9968                 uint32_t _res_conv_20 = _res_vals[u];
9969                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_20) & ~1);
9970                 FREE((void*)_res_conv_20);
9971                 _res_constr.data[u] = _res_conv_20_conv;
9972         }
9973         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
9974 }
9975
9976 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
9977         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
9978         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
9979         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
9980         return ((uint64_t)ret_conv);
9981 }
9982
9983 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
9984         LDKThirtyTwoBytes a_ref;
9985         CHECK(*((uint32_t*)a) == 32);
9986         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
9987         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
9988         b_constr.datalen = *((uint32_t*)b);
9989         if (b_constr.datalen > 0)
9990                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
9991         else
9992                 b_constr.data = NULL;
9993         uint32_t* b_vals = (uint32_t*)(b + 4);
9994         for (size_t u = 0; u < b_constr.datalen; u++) {
9995                 uint32_t b_conv_20 = b_vals[u];
9996                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1);
9997                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
9998                 b_constr.data[u] = b_conv_20_conv;
9999         }
10000         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10001         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
10002         return ((uint64_t)ret_conv);
10003 }
10004
10005 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
10006         if ((_res & 1) != 0) return;
10007         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
10008         FREE((void*)_res);
10009         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
10010 }
10011
10012 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
10013         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
10014         _res_constr.datalen = *((uint32_t*)_res);
10015         if (_res_constr.datalen > 0)
10016                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
10017         else
10018                 _res_constr.data = NULL;
10019         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10020         for (size_t n = 0; n < _res_constr.datalen; n++) {
10021                 uint32_t _res_conv_39 = _res_vals[n];
10022                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_39) & ~1);
10023                 FREE((void*)_res_conv_39);
10024                 _res_constr.data[n] = _res_conv_39_conv;
10025         }
10026         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
10027 }
10028
10029 void  __attribute__((visibility("default"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
10030         LDKCVec_BalanceZ _res_constr;
10031         _res_constr.datalen = *((uint32_t*)_res);
10032         if (_res_constr.datalen > 0)
10033                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
10034         else
10035                 _res_constr.data = NULL;
10036         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10037         for (size_t j = 0; j < _res_constr.datalen; j++) {
10038                 uint32_t _res_conv_9 = _res_vals[j];
10039                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(((uint64_t)_res_conv_9) & ~1);
10040                 FREE((void*)_res_conv_9);
10041                 _res_constr.data[j] = _res_conv_9_conv;
10042         }
10043         CVec_BalanceZ_free(_res_constr);
10044 }
10045
10046 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
10047         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
10048         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
10049         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10050         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
10051         return (uint64_t)ret_conv;
10052 }
10053
10054 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_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         e_conv = DecodeError_clone(&e_conv);
10059         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10060         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
10061         return (uint64_t)ret_conv;
10062 }
10063
10064 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
10065         if ((_res & 1) != 0) return;
10066         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10067         FREE((void*)_res);
10068         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
10069 }
10070
10071 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
10072         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
10073         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10074         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
10075         return (uint64_t)ret_conv;
10076 }
10077
10078 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
10079         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10080         *ret_conv = CResult_NoneLightningErrorZ_ok();
10081         return (uint64_t)ret_conv;
10082 }
10083
10084 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
10085         LDKLightningError e_conv;
10086         e_conv.inner = (void*)(e & (~1));
10087         e_conv.is_owned = (e & 1) || (e == 0);
10088         e_conv = LightningError_clone(&e_conv);
10089         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10090         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
10091         return (uint64_t)ret_conv;
10092 }
10093
10094 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
10095         if ((_res & 1) != 0) return;
10096         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
10097         FREE((void*)_res);
10098         CResult_NoneLightningErrorZ_free(_res_conv);
10099 }
10100
10101 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
10102         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
10103         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10104         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
10105         return (uint64_t)ret_conv;
10106 }
10107
10108 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
10109         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
10110         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10111         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
10112         return ((uint64_t)ret_conv);
10113 }
10114
10115 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
10116         LDKPublicKey a_ref;
10117         CHECK(*((uint32_t*)a) == 33);
10118         memcpy(a_ref.compressed_form, (uint8_t*)(a + 4), 33);
10119         LDKType b_conv = *(LDKType*)(((uint64_t)b) & ~1);
10120         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10121         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
10122         return ((uint64_t)ret_conv);
10123 }
10124
10125 void  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
10126         if ((_res & 1) != 0) return;
10127         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res) & ~1);
10128         FREE((void*)_res);
10129         C2Tuple_PublicKeyTypeZ_free(_res_conv);
10130 }
10131
10132 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
10133         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
10134         _res_constr.datalen = *((uint32_t*)_res);
10135         if (_res_constr.datalen > 0)
10136                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
10137         else
10138                 _res_constr.data = NULL;
10139         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10140         for (size_t z = 0; z < _res_constr.datalen; z++) {
10141                 uint32_t _res_conv_25 = _res_vals[z];
10142                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)_res_conv_25) & ~1);
10143                 FREE((void*)_res_conv_25);
10144                 _res_constr.data[z] = _res_conv_25_conv;
10145         }
10146         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
10147 }
10148
10149 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
10150         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10151         *ret_conv = CResult_boolLightningErrorZ_ok(o);
10152         return (uint64_t)ret_conv;
10153 }
10154
10155 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
10156         LDKLightningError e_conv;
10157         e_conv.inner = (void*)(e & (~1));
10158         e_conv.is_owned = (e & 1) || (e == 0);
10159         e_conv = LightningError_clone(&e_conv);
10160         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10161         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
10162         return (uint64_t)ret_conv;
10163 }
10164
10165 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
10166         if ((_res & 1) != 0) return;
10167         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
10168         FREE((void*)_res);
10169         CResult_boolLightningErrorZ_free(_res_conv);
10170 }
10171
10172 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
10173         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
10174         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10175         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
10176         return (uint64_t)ret_conv;
10177 }
10178
10179 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
10180         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
10181         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
10182         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
10183         return ((uint64_t)ret_conv);
10184 }
10185
10186 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
10187         LDKChannelAnnouncement a_conv;
10188         a_conv.inner = (void*)(a & (~1));
10189         a_conv.is_owned = (a & 1) || (a == 0);
10190         a_conv = ChannelAnnouncement_clone(&a_conv);
10191         LDKChannelUpdate b_conv;
10192         b_conv.inner = (void*)(b & (~1));
10193         b_conv.is_owned = (b & 1) || (b == 0);
10194         b_conv = ChannelUpdate_clone(&b_conv);
10195         LDKChannelUpdate c_conv;
10196         c_conv.inner = (void*)(c & (~1));
10197         c_conv.is_owned = (c & 1) || (c == 0);
10198         c_conv = ChannelUpdate_clone(&c_conv);
10199         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
10200         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
10201         return ((uint64_t)ret_conv);
10202 }
10203
10204 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
10205         if ((_res & 1) != 0) return;
10206         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
10207         FREE((void*)_res);
10208         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
10209 }
10210
10211 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
10212         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
10213         _res_constr.datalen = *((uint32_t*)_res);
10214         if (_res_constr.datalen > 0)
10215                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
10216         else
10217                 _res_constr.data = NULL;
10218         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10219         for (size_t h = 0; h < _res_constr.datalen; h++) {
10220                 uint32_t _res_conv_59 = _res_vals[h];
10221                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_59) & ~1);
10222                 FREE((void*)_res_conv_59);
10223                 _res_constr.data[h] = _res_conv_59_conv;
10224         }
10225         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
10226 }
10227
10228 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
10229         LDKCVec_NodeAnnouncementZ _res_constr;
10230         _res_constr.datalen = *((uint32_t*)_res);
10231         if (_res_constr.datalen > 0)
10232                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
10233         else
10234                 _res_constr.data = NULL;
10235         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10236         for (size_t s = 0; s < _res_constr.datalen; s++) {
10237                 uint32_t _res_conv_18 = _res_vals[s];
10238                 LDKNodeAnnouncement _res_conv_18_conv;
10239                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
10240                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
10241                 _res_constr.data[s] = _res_conv_18_conv;
10242         }
10243         CVec_NodeAnnouncementZ_free(_res_constr);
10244 }
10245
10246 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
10247         LDKCVec_PublicKeyZ _res_constr;
10248         _res_constr.datalen = *((uint32_t*)_res);
10249         if (_res_constr.datalen > 0)
10250                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
10251         else
10252                 _res_constr.data = NULL;
10253         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
10254         for (size_t m = 0; m < _res_constr.datalen; m++) {
10255                 int8_tArray _res_conv_12 = _res_vals[m];
10256                 LDKPublicKey _res_conv_12_ref;
10257                 CHECK(*((uint32_t*)_res_conv_12) == 33);
10258                 memcpy(_res_conv_12_ref.compressed_form, (uint8_t*)(_res_conv_12 + 4), 33);
10259                 _res_constr.data[m] = _res_conv_12_ref;
10260         }
10261         CVec_PublicKeyZ_free(_res_constr);
10262 }
10263
10264 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
10265         LDKCVec_u8Z o_ref;
10266         o_ref.datalen = *((uint32_t*)o);
10267         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
10268         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
10269         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
10270         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
10271         return (uint64_t)ret_conv;
10272 }
10273
10274 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
10275         LDKPeerHandleError e_conv;
10276         e_conv.inner = (void*)(e & (~1));
10277         e_conv.is_owned = (e & 1) || (e == 0);
10278         e_conv = PeerHandleError_clone(&e_conv);
10279         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
10280         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
10281         return (uint64_t)ret_conv;
10282 }
10283
10284 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
10285         if ((_res & 1) != 0) return;
10286         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
10287         FREE((void*)_res);
10288         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
10289 }
10290
10291 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
10292         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
10293         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
10294         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
10295         return (uint64_t)ret_conv;
10296 }
10297
10298 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
10299         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
10300         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
10301         return (uint64_t)ret_conv;
10302 }
10303
10304 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
10305         LDKPeerHandleError e_conv;
10306         e_conv.inner = (void*)(e & (~1));
10307         e_conv.is_owned = (e & 1) || (e == 0);
10308         e_conv = PeerHandleError_clone(&e_conv);
10309         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
10310         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
10311         return (uint64_t)ret_conv;
10312 }
10313
10314 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
10315         if ((_res & 1) != 0) return;
10316         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
10317         FREE((void*)_res);
10318         CResult_NonePeerHandleErrorZ_free(_res_conv);
10319 }
10320
10321 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
10322         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
10323         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
10324         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
10325         return (uint64_t)ret_conv;
10326 }
10327
10328 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
10329         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
10330         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
10331         return (uint64_t)ret_conv;
10332 }
10333
10334 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
10335         LDKPeerHandleError e_conv;
10336         e_conv.inner = (void*)(e & (~1));
10337         e_conv.is_owned = (e & 1) || (e == 0);
10338         e_conv = PeerHandleError_clone(&e_conv);
10339         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
10340         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
10341         return (uint64_t)ret_conv;
10342 }
10343
10344 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
10345         if ((_res & 1) != 0) return;
10346         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
10347         FREE((void*)_res);
10348         CResult_boolPeerHandleErrorZ_free(_res_conv);
10349 }
10350
10351 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
10352         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
10353         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
10354         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
10355         return (uint64_t)ret_conv;
10356 }
10357
10358 uint32_t  __attribute__((visibility("default"))) TS_COption_AccessZ_some(uint32_t o) {
10359         LDKAccess o_conv = *(LDKAccess*)(((uint64_t)o) & ~1);
10360         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
10361         *ret_copy = COption_AccessZ_some(o_conv);
10362         uint64_t ret_ref = (uint64_t)ret_copy;
10363         return ret_ref;
10364 }
10365
10366 uint32_t  __attribute__((visibility("default"))) TS_COption_AccessZ_none() {
10367         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
10368         *ret_copy = COption_AccessZ_none();
10369         uint64_t ret_ref = (uint64_t)ret_copy;
10370         return ret_ref;
10371 }
10372
10373 void  __attribute__((visibility("default"))) TS_COption_AccessZ_free(uint32_t _res) {
10374         if ((_res & 1) != 0) return;
10375         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(((uint64_t)_res) & ~1);
10376         FREE((void*)_res);
10377         COption_AccessZ_free(_res_conv);
10378 }
10379
10380 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
10381         LDKDirectionalChannelInfo o_conv;
10382         o_conv.inner = (void*)(o & (~1));
10383         o_conv.is_owned = (o & 1) || (o == 0);
10384         o_conv = DirectionalChannelInfo_clone(&o_conv);
10385         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
10386         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
10387         return (uint64_t)ret_conv;
10388 }
10389
10390 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
10391         LDKDecodeError e_conv;
10392         e_conv.inner = (void*)(e & (~1));
10393         e_conv.is_owned = (e & 1) || (e == 0);
10394         e_conv = DecodeError_clone(&e_conv);
10395         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
10396         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
10397         return (uint64_t)ret_conv;
10398 }
10399
10400 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
10401         if ((_res & 1) != 0) return;
10402         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
10403         FREE((void*)_res);
10404         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
10405 }
10406
10407 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
10408         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
10409         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
10410         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
10411         return (uint64_t)ret_conv;
10412 }
10413
10414 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
10415         LDKChannelInfo o_conv;
10416         o_conv.inner = (void*)(o & (~1));
10417         o_conv.is_owned = (o & 1) || (o == 0);
10418         o_conv = ChannelInfo_clone(&o_conv);
10419         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
10420         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
10421         return (uint64_t)ret_conv;
10422 }
10423
10424 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
10425         LDKDecodeError e_conv;
10426         e_conv.inner = (void*)(e & (~1));
10427         e_conv.is_owned = (e & 1) || (e == 0);
10428         e_conv = DecodeError_clone(&e_conv);
10429         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
10430         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
10431         return (uint64_t)ret_conv;
10432 }
10433
10434 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
10435         if ((_res & 1) != 0) return;
10436         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
10437         FREE((void*)_res);
10438         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
10439 }
10440
10441 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
10442         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
10443         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
10444         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
10445         return (uint64_t)ret_conv;
10446 }
10447
10448 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
10449         LDKRoutingFees o_conv;
10450         o_conv.inner = (void*)(o & (~1));
10451         o_conv.is_owned = (o & 1) || (o == 0);
10452         o_conv = RoutingFees_clone(&o_conv);
10453         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
10454         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
10455         return (uint64_t)ret_conv;
10456 }
10457
10458 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
10459         LDKDecodeError e_conv;
10460         e_conv.inner = (void*)(e & (~1));
10461         e_conv.is_owned = (e & 1) || (e == 0);
10462         e_conv = DecodeError_clone(&e_conv);
10463         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
10464         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
10465         return (uint64_t)ret_conv;
10466 }
10467
10468 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
10469         if ((_res & 1) != 0) return;
10470         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10471         FREE((void*)_res);
10472         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
10473 }
10474
10475 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
10476         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
10477         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
10478         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
10479         return (uint64_t)ret_conv;
10480 }
10481
10482 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
10483         LDKNodeAnnouncementInfo o_conv;
10484         o_conv.inner = (void*)(o & (~1));
10485         o_conv.is_owned = (o & 1) || (o == 0);
10486         o_conv = NodeAnnouncementInfo_clone(&o_conv);
10487         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
10488         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
10489         return (uint64_t)ret_conv;
10490 }
10491
10492 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
10493         LDKDecodeError e_conv;
10494         e_conv.inner = (void*)(e & (~1));
10495         e_conv.is_owned = (e & 1) || (e == 0);
10496         e_conv = DecodeError_clone(&e_conv);
10497         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
10498         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
10499         return (uint64_t)ret_conv;
10500 }
10501
10502 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
10503         if ((_res & 1) != 0) return;
10504         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
10505         FREE((void*)_res);
10506         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
10507 }
10508
10509 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
10510         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
10511         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
10512         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
10513         return (uint64_t)ret_conv;
10514 }
10515
10516 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
10517         LDKCVec_u64Z _res_constr;
10518         _res_constr.datalen = *((uint32_t*)_res);
10519         if (_res_constr.datalen > 0)
10520                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
10521         else
10522                 _res_constr.data = NULL;
10523         int64_t* _res_vals = (int64_t*)(_res + 4);
10524         for (size_t i = 0; i < _res_constr.datalen; i++) {
10525                 int64_t _res_conv_8 = _res_vals[i];
10526                 _res_constr.data[i] = _res_conv_8;
10527         }
10528         CVec_u64Z_free(_res_constr);
10529 }
10530
10531 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
10532         LDKNodeInfo o_conv;
10533         o_conv.inner = (void*)(o & (~1));
10534         o_conv.is_owned = (o & 1) || (o == 0);
10535         o_conv = NodeInfo_clone(&o_conv);
10536         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
10537         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
10538         return (uint64_t)ret_conv;
10539 }
10540
10541 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
10542         LDKDecodeError e_conv;
10543         e_conv.inner = (void*)(e & (~1));
10544         e_conv.is_owned = (e & 1) || (e == 0);
10545         e_conv = DecodeError_clone(&e_conv);
10546         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
10547         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
10548         return (uint64_t)ret_conv;
10549 }
10550
10551 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
10552         if ((_res & 1) != 0) return;
10553         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
10554         FREE((void*)_res);
10555         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
10556 }
10557
10558 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
10559         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
10560         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
10561         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
10562         return (uint64_t)ret_conv;
10563 }
10564
10565 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
10566         LDKNetworkGraph o_conv;
10567         o_conv.inner = (void*)(o & (~1));
10568         o_conv.is_owned = (o & 1) || (o == 0);
10569         o_conv = NetworkGraph_clone(&o_conv);
10570         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
10571         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
10572         return (uint64_t)ret_conv;
10573 }
10574
10575 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
10576         LDKDecodeError e_conv;
10577         e_conv.inner = (void*)(e & (~1));
10578         e_conv.is_owned = (e & 1) || (e == 0);
10579         e_conv = DecodeError_clone(&e_conv);
10580         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
10581         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
10582         return (uint64_t)ret_conv;
10583 }
10584
10585 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
10586         if ((_res & 1) != 0) return;
10587         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
10588         FREE((void*)_res);
10589         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
10590 }
10591
10592 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
10593         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
10594         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
10595         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
10596         return (uint64_t)ret_conv;
10597 }
10598
10599 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) {
10600         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
10601         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
10602         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
10603         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
10604         return (uint64_t)ret_conv;
10605 }
10606
10607 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
10608         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
10609         *ret_conv = CResult_NetAddressu8Z_err(e);
10610         return (uint64_t)ret_conv;
10611 }
10612
10613 void  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
10614         if ((_res & 1) != 0) return;
10615         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
10616         FREE((void*)_res);
10617         CResult_NetAddressu8Z_free(_res_conv);
10618 }
10619
10620 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone(uint32_t orig) {
10621         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
10622         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
10623         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
10624         return (uint64_t)ret_conv;
10625 }
10626
10627 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) {
10628         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
10629         o_conv = CResult_NetAddressu8Z_clone((LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1));
10630         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
10631         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
10632         return (uint64_t)ret_conv;
10633 }
10634
10635 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_err(uint32_t e) {
10636         LDKDecodeError e_conv;
10637         e_conv.inner = (void*)(e & (~1));
10638         e_conv.is_owned = (e & 1) || (e == 0);
10639         e_conv = DecodeError_clone(&e_conv);
10640         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
10641         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
10642         return (uint64_t)ret_conv;
10643 }
10644
10645 void  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
10646         if ((_res & 1) != 0) return;
10647         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10648         FREE((void*)_res);
10649         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
10650 }
10651
10652 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(uint32_t orig) {
10653         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
10654         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
10655         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
10656         return (uint64_t)ret_conv;
10657 }
10658
10659 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
10660         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
10661         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
10662         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
10663         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
10664         return (uint64_t)ret_conv;
10665 }
10666
10667 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
10668         LDKDecodeError e_conv;
10669         e_conv.inner = (void*)(e & (~1));
10670         e_conv.is_owned = (e & 1) || (e == 0);
10671         e_conv = DecodeError_clone(&e_conv);
10672         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
10673         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
10674         return (uint64_t)ret_conv;
10675 }
10676
10677 void  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
10678         if ((_res & 1) != 0) return;
10679         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
10680         FREE((void*)_res);
10681         CResult_NetAddressDecodeErrorZ_free(_res_conv);
10682 }
10683
10684 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
10685         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
10686         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
10687         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
10688         return (uint64_t)ret_conv;
10689 }
10690
10691 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
10692         LDKCVec_UpdateAddHTLCZ _res_constr;
10693         _res_constr.datalen = *((uint32_t*)_res);
10694         if (_res_constr.datalen > 0)
10695                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
10696         else
10697                 _res_constr.data = NULL;
10698         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10699         for (size_t p = 0; p < _res_constr.datalen; p++) {
10700                 uint32_t _res_conv_15 = _res_vals[p];
10701                 LDKUpdateAddHTLC _res_conv_15_conv;
10702                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
10703                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
10704                 _res_constr.data[p] = _res_conv_15_conv;
10705         }
10706         CVec_UpdateAddHTLCZ_free(_res_constr);
10707 }
10708
10709 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
10710         LDKCVec_UpdateFulfillHTLCZ _res_constr;
10711         _res_constr.datalen = *((uint32_t*)_res);
10712         if (_res_constr.datalen > 0)
10713                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
10714         else
10715                 _res_constr.data = NULL;
10716         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10717         for (size_t t = 0; t < _res_constr.datalen; t++) {
10718                 uint32_t _res_conv_19 = _res_vals[t];
10719                 LDKUpdateFulfillHTLC _res_conv_19_conv;
10720                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
10721                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
10722                 _res_constr.data[t] = _res_conv_19_conv;
10723         }
10724         CVec_UpdateFulfillHTLCZ_free(_res_constr);
10725 }
10726
10727 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
10728         LDKCVec_UpdateFailHTLCZ _res_constr;
10729         _res_constr.datalen = *((uint32_t*)_res);
10730         if (_res_constr.datalen > 0)
10731                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
10732         else
10733                 _res_constr.data = NULL;
10734         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10735         for (size_t q = 0; q < _res_constr.datalen; q++) {
10736                 uint32_t _res_conv_16 = _res_vals[q];
10737                 LDKUpdateFailHTLC _res_conv_16_conv;
10738                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10739                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10740                 _res_constr.data[q] = _res_conv_16_conv;
10741         }
10742         CVec_UpdateFailHTLCZ_free(_res_constr);
10743 }
10744
10745 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
10746         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
10747         _res_constr.datalen = *((uint32_t*)_res);
10748         if (_res_constr.datalen > 0)
10749                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
10750         else
10751                 _res_constr.data = NULL;
10752         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10753         for (size_t z = 0; z < _res_constr.datalen; z++) {
10754                 uint32_t _res_conv_25 = _res_vals[z];
10755                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
10756                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
10757                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
10758                 _res_constr.data[z] = _res_conv_25_conv;
10759         }
10760         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
10761 }
10762
10763 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
10764         LDKAcceptChannel o_conv;
10765         o_conv.inner = (void*)(o & (~1));
10766         o_conv.is_owned = (o & 1) || (o == 0);
10767         o_conv = AcceptChannel_clone(&o_conv);
10768         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
10769         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
10770         return (uint64_t)ret_conv;
10771 }
10772
10773 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
10774         LDKDecodeError e_conv;
10775         e_conv.inner = (void*)(e & (~1));
10776         e_conv.is_owned = (e & 1) || (e == 0);
10777         e_conv = DecodeError_clone(&e_conv);
10778         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
10779         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
10780         return (uint64_t)ret_conv;
10781 }
10782
10783 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
10784         if ((_res & 1) != 0) return;
10785         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
10786         FREE((void*)_res);
10787         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
10788 }
10789
10790 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
10791         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
10792         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
10793         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
10794         return (uint64_t)ret_conv;
10795 }
10796
10797 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
10798         LDKAnnouncementSignatures o_conv;
10799         o_conv.inner = (void*)(o & (~1));
10800         o_conv.is_owned = (o & 1) || (o == 0);
10801         o_conv = AnnouncementSignatures_clone(&o_conv);
10802         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
10803         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
10804         return (uint64_t)ret_conv;
10805 }
10806
10807 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
10808         LDKDecodeError e_conv;
10809         e_conv.inner = (void*)(e & (~1));
10810         e_conv.is_owned = (e & 1) || (e == 0);
10811         e_conv = DecodeError_clone(&e_conv);
10812         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
10813         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
10814         return (uint64_t)ret_conv;
10815 }
10816
10817 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
10818         if ((_res & 1) != 0) return;
10819         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10820         FREE((void*)_res);
10821         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
10822 }
10823
10824 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
10825         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
10826         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
10827         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
10828         return (uint64_t)ret_conv;
10829 }
10830
10831 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
10832         LDKChannelReestablish o_conv;
10833         o_conv.inner = (void*)(o & (~1));
10834         o_conv.is_owned = (o & 1) || (o == 0);
10835         o_conv = ChannelReestablish_clone(&o_conv);
10836         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
10837         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
10838         return (uint64_t)ret_conv;
10839 }
10840
10841 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
10842         LDKDecodeError e_conv;
10843         e_conv.inner = (void*)(e & (~1));
10844         e_conv.is_owned = (e & 1) || (e == 0);
10845         e_conv = DecodeError_clone(&e_conv);
10846         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
10847         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
10848         return (uint64_t)ret_conv;
10849 }
10850
10851 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
10852         if ((_res & 1) != 0) return;
10853         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
10854         FREE((void*)_res);
10855         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
10856 }
10857
10858 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
10859         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
10860         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
10861         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
10862         return (uint64_t)ret_conv;
10863 }
10864
10865 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
10866         LDKClosingSigned o_conv;
10867         o_conv.inner = (void*)(o & (~1));
10868         o_conv.is_owned = (o & 1) || (o == 0);
10869         o_conv = ClosingSigned_clone(&o_conv);
10870         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
10871         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
10872         return (uint64_t)ret_conv;
10873 }
10874
10875 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
10876         LDKDecodeError e_conv;
10877         e_conv.inner = (void*)(e & (~1));
10878         e_conv.is_owned = (e & 1) || (e == 0);
10879         e_conv = DecodeError_clone(&e_conv);
10880         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
10881         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
10882         return (uint64_t)ret_conv;
10883 }
10884
10885 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
10886         if ((_res & 1) != 0) return;
10887         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
10888         FREE((void*)_res);
10889         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
10890 }
10891
10892 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
10893         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
10894         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
10895         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
10896         return (uint64_t)ret_conv;
10897 }
10898
10899 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
10900         LDKClosingSignedFeeRange o_conv;
10901         o_conv.inner = (void*)(o & (~1));
10902         o_conv.is_owned = (o & 1) || (o == 0);
10903         o_conv = ClosingSignedFeeRange_clone(&o_conv);
10904         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
10905         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
10906         return (uint64_t)ret_conv;
10907 }
10908
10909 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
10910         LDKDecodeError e_conv;
10911         e_conv.inner = (void*)(e & (~1));
10912         e_conv.is_owned = (e & 1) || (e == 0);
10913         e_conv = DecodeError_clone(&e_conv);
10914         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
10915         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
10916         return (uint64_t)ret_conv;
10917 }
10918
10919 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
10920         if ((_res & 1) != 0) return;
10921         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
10922         FREE((void*)_res);
10923         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
10924 }
10925
10926 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
10927         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
10928         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
10929         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
10930         return (uint64_t)ret_conv;
10931 }
10932
10933 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
10934         LDKCommitmentSigned o_conv;
10935         o_conv.inner = (void*)(o & (~1));
10936         o_conv.is_owned = (o & 1) || (o == 0);
10937         o_conv = CommitmentSigned_clone(&o_conv);
10938         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
10939         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
10940         return (uint64_t)ret_conv;
10941 }
10942
10943 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
10944         LDKDecodeError e_conv;
10945         e_conv.inner = (void*)(e & (~1));
10946         e_conv.is_owned = (e & 1) || (e == 0);
10947         e_conv = DecodeError_clone(&e_conv);
10948         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
10949         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
10950         return (uint64_t)ret_conv;
10951 }
10952
10953 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
10954         if ((_res & 1) != 0) return;
10955         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
10956         FREE((void*)_res);
10957         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
10958 }
10959
10960 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
10961         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
10962         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
10963         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
10964         return (uint64_t)ret_conv;
10965 }
10966
10967 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
10968         LDKFundingCreated o_conv;
10969         o_conv.inner = (void*)(o & (~1));
10970         o_conv.is_owned = (o & 1) || (o == 0);
10971         o_conv = FundingCreated_clone(&o_conv);
10972         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
10973         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
10974         return (uint64_t)ret_conv;
10975 }
10976
10977 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
10978         LDKDecodeError e_conv;
10979         e_conv.inner = (void*)(e & (~1));
10980         e_conv.is_owned = (e & 1) || (e == 0);
10981         e_conv = DecodeError_clone(&e_conv);
10982         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
10983         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
10984         return (uint64_t)ret_conv;
10985 }
10986
10987 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
10988         if ((_res & 1) != 0) return;
10989         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
10990         FREE((void*)_res);
10991         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
10992 }
10993
10994 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
10995         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
10996         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
10997         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
10998         return (uint64_t)ret_conv;
10999 }
11000
11001 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
11002         LDKFundingSigned o_conv;
11003         o_conv.inner = (void*)(o & (~1));
11004         o_conv.is_owned = (o & 1) || (o == 0);
11005         o_conv = FundingSigned_clone(&o_conv);
11006         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
11007         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
11008         return (uint64_t)ret_conv;
11009 }
11010
11011 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
11012         LDKDecodeError e_conv;
11013         e_conv.inner = (void*)(e & (~1));
11014         e_conv.is_owned = (e & 1) || (e == 0);
11015         e_conv = DecodeError_clone(&e_conv);
11016         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
11017         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
11018         return (uint64_t)ret_conv;
11019 }
11020
11021 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
11022         if ((_res & 1) != 0) return;
11023         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
11024         FREE((void*)_res);
11025         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
11026 }
11027
11028 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
11029         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
11030         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
11031         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
11032         return (uint64_t)ret_conv;
11033 }
11034
11035 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
11036         LDKFundingLocked o_conv;
11037         o_conv.inner = (void*)(o & (~1));
11038         o_conv.is_owned = (o & 1) || (o == 0);
11039         o_conv = FundingLocked_clone(&o_conv);
11040         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
11041         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
11042         return (uint64_t)ret_conv;
11043 }
11044
11045 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
11046         LDKDecodeError e_conv;
11047         e_conv.inner = (void*)(e & (~1));
11048         e_conv.is_owned = (e & 1) || (e == 0);
11049         e_conv = DecodeError_clone(&e_conv);
11050         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
11051         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
11052         return (uint64_t)ret_conv;
11053 }
11054
11055 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
11056         if ((_res & 1) != 0) return;
11057         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
11058         FREE((void*)_res);
11059         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
11060 }
11061
11062 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
11063         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
11064         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
11065         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
11066         return (uint64_t)ret_conv;
11067 }
11068
11069 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
11070         LDKInit o_conv;
11071         o_conv.inner = (void*)(o & (~1));
11072         o_conv.is_owned = (o & 1) || (o == 0);
11073         o_conv = Init_clone(&o_conv);
11074         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
11075         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
11076         return (uint64_t)ret_conv;
11077 }
11078
11079 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
11080         LDKDecodeError e_conv;
11081         e_conv.inner = (void*)(e & (~1));
11082         e_conv.is_owned = (e & 1) || (e == 0);
11083         e_conv = DecodeError_clone(&e_conv);
11084         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
11085         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
11086         return (uint64_t)ret_conv;
11087 }
11088
11089 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
11090         if ((_res & 1) != 0) return;
11091         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
11092         FREE((void*)_res);
11093         CResult_InitDecodeErrorZ_free(_res_conv);
11094 }
11095
11096 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
11097         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
11098         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
11099         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
11100         return (uint64_t)ret_conv;
11101 }
11102
11103 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
11104         LDKOpenChannel o_conv;
11105         o_conv.inner = (void*)(o & (~1));
11106         o_conv.is_owned = (o & 1) || (o == 0);
11107         o_conv = OpenChannel_clone(&o_conv);
11108         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
11109         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
11110         return (uint64_t)ret_conv;
11111 }
11112
11113 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
11114         LDKDecodeError e_conv;
11115         e_conv.inner = (void*)(e & (~1));
11116         e_conv.is_owned = (e & 1) || (e == 0);
11117         e_conv = DecodeError_clone(&e_conv);
11118         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
11119         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
11120         return (uint64_t)ret_conv;
11121 }
11122
11123 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
11124         if ((_res & 1) != 0) return;
11125         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
11126         FREE((void*)_res);
11127         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
11128 }
11129
11130 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
11131         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
11132         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
11133         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
11134         return (uint64_t)ret_conv;
11135 }
11136
11137 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
11138         LDKRevokeAndACK o_conv;
11139         o_conv.inner = (void*)(o & (~1));
11140         o_conv.is_owned = (o & 1) || (o == 0);
11141         o_conv = RevokeAndACK_clone(&o_conv);
11142         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
11143         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
11144         return (uint64_t)ret_conv;
11145 }
11146
11147 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
11148         LDKDecodeError e_conv;
11149         e_conv.inner = (void*)(e & (~1));
11150         e_conv.is_owned = (e & 1) || (e == 0);
11151         e_conv = DecodeError_clone(&e_conv);
11152         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
11153         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
11154         return (uint64_t)ret_conv;
11155 }
11156
11157 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
11158         if ((_res & 1) != 0) return;
11159         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
11160         FREE((void*)_res);
11161         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
11162 }
11163
11164 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
11165         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
11166         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
11167         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
11168         return (uint64_t)ret_conv;
11169 }
11170
11171 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
11172         LDKShutdown o_conv;
11173         o_conv.inner = (void*)(o & (~1));
11174         o_conv.is_owned = (o & 1) || (o == 0);
11175         o_conv = Shutdown_clone(&o_conv);
11176         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
11177         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
11178         return (uint64_t)ret_conv;
11179 }
11180
11181 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
11182         LDKDecodeError e_conv;
11183         e_conv.inner = (void*)(e & (~1));
11184         e_conv.is_owned = (e & 1) || (e == 0);
11185         e_conv = DecodeError_clone(&e_conv);
11186         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
11187         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
11188         return (uint64_t)ret_conv;
11189 }
11190
11191 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
11192         if ((_res & 1) != 0) return;
11193         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
11194         FREE((void*)_res);
11195         CResult_ShutdownDecodeErrorZ_free(_res_conv);
11196 }
11197
11198 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
11199         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
11200         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
11201         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
11202         return (uint64_t)ret_conv;
11203 }
11204
11205 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
11206         LDKUpdateFailHTLC o_conv;
11207         o_conv.inner = (void*)(o & (~1));
11208         o_conv.is_owned = (o & 1) || (o == 0);
11209         o_conv = UpdateFailHTLC_clone(&o_conv);
11210         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
11211         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
11212         return (uint64_t)ret_conv;
11213 }
11214
11215 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
11216         LDKDecodeError e_conv;
11217         e_conv.inner = (void*)(e & (~1));
11218         e_conv.is_owned = (e & 1) || (e == 0);
11219         e_conv = DecodeError_clone(&e_conv);
11220         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
11221         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
11222         return (uint64_t)ret_conv;
11223 }
11224
11225 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
11226         if ((_res & 1) != 0) return;
11227         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
11228         FREE((void*)_res);
11229         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
11230 }
11231
11232 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
11233         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
11234         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
11235         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
11236         return (uint64_t)ret_conv;
11237 }
11238
11239 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
11240         LDKUpdateFailMalformedHTLC o_conv;
11241         o_conv.inner = (void*)(o & (~1));
11242         o_conv.is_owned = (o & 1) || (o == 0);
11243         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
11244         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
11245         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
11246         return (uint64_t)ret_conv;
11247 }
11248
11249 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
11250         LDKDecodeError e_conv;
11251         e_conv.inner = (void*)(e & (~1));
11252         e_conv.is_owned = (e & 1) || (e == 0);
11253         e_conv = DecodeError_clone(&e_conv);
11254         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
11255         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
11256         return (uint64_t)ret_conv;
11257 }
11258
11259 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
11260         if ((_res & 1) != 0) return;
11261         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
11262         FREE((void*)_res);
11263         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
11264 }
11265
11266 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
11267         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
11268         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
11269         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
11270         return (uint64_t)ret_conv;
11271 }
11272
11273 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
11274         LDKUpdateFee o_conv;
11275         o_conv.inner = (void*)(o & (~1));
11276         o_conv.is_owned = (o & 1) || (o == 0);
11277         o_conv = UpdateFee_clone(&o_conv);
11278         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
11279         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
11280         return (uint64_t)ret_conv;
11281 }
11282
11283 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
11284         LDKDecodeError e_conv;
11285         e_conv.inner = (void*)(e & (~1));
11286         e_conv.is_owned = (e & 1) || (e == 0);
11287         e_conv = DecodeError_clone(&e_conv);
11288         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
11289         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
11290         return (uint64_t)ret_conv;
11291 }
11292
11293 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
11294         if ((_res & 1) != 0) return;
11295         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
11296         FREE((void*)_res);
11297         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
11298 }
11299
11300 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
11301         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
11302         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
11303         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
11304         return (uint64_t)ret_conv;
11305 }
11306
11307 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
11308         LDKUpdateFulfillHTLC o_conv;
11309         o_conv.inner = (void*)(o & (~1));
11310         o_conv.is_owned = (o & 1) || (o == 0);
11311         o_conv = UpdateFulfillHTLC_clone(&o_conv);
11312         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
11313         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
11314         return (uint64_t)ret_conv;
11315 }
11316
11317 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
11318         LDKDecodeError e_conv;
11319         e_conv.inner = (void*)(e & (~1));
11320         e_conv.is_owned = (e & 1) || (e == 0);
11321         e_conv = DecodeError_clone(&e_conv);
11322         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
11323         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
11324         return (uint64_t)ret_conv;
11325 }
11326
11327 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
11328         if ((_res & 1) != 0) return;
11329         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
11330         FREE((void*)_res);
11331         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
11332 }
11333
11334 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
11335         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
11336         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
11337         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
11338         return (uint64_t)ret_conv;
11339 }
11340
11341 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
11342         LDKUpdateAddHTLC o_conv;
11343         o_conv.inner = (void*)(o & (~1));
11344         o_conv.is_owned = (o & 1) || (o == 0);
11345         o_conv = UpdateAddHTLC_clone(&o_conv);
11346         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
11347         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
11348         return (uint64_t)ret_conv;
11349 }
11350
11351 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
11352         LDKDecodeError e_conv;
11353         e_conv.inner = (void*)(e & (~1));
11354         e_conv.is_owned = (e & 1) || (e == 0);
11355         e_conv = DecodeError_clone(&e_conv);
11356         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
11357         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
11358         return (uint64_t)ret_conv;
11359 }
11360
11361 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
11362         if ((_res & 1) != 0) return;
11363         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
11364         FREE((void*)_res);
11365         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
11366 }
11367
11368 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
11369         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
11370         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
11371         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
11372         return (uint64_t)ret_conv;
11373 }
11374
11375 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
11376         LDKPing o_conv;
11377         o_conv.inner = (void*)(o & (~1));
11378         o_conv.is_owned = (o & 1) || (o == 0);
11379         o_conv = Ping_clone(&o_conv);
11380         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
11381         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
11382         return (uint64_t)ret_conv;
11383 }
11384
11385 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
11386         LDKDecodeError e_conv;
11387         e_conv.inner = (void*)(e & (~1));
11388         e_conv.is_owned = (e & 1) || (e == 0);
11389         e_conv = DecodeError_clone(&e_conv);
11390         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
11391         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
11392         return (uint64_t)ret_conv;
11393 }
11394
11395 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
11396         if ((_res & 1) != 0) return;
11397         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
11398         FREE((void*)_res);
11399         CResult_PingDecodeErrorZ_free(_res_conv);
11400 }
11401
11402 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
11403         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
11404         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
11405         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
11406         return (uint64_t)ret_conv;
11407 }
11408
11409 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
11410         LDKPong o_conv;
11411         o_conv.inner = (void*)(o & (~1));
11412         o_conv.is_owned = (o & 1) || (o == 0);
11413         o_conv = Pong_clone(&o_conv);
11414         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
11415         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
11416         return (uint64_t)ret_conv;
11417 }
11418
11419 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
11420         LDKDecodeError e_conv;
11421         e_conv.inner = (void*)(e & (~1));
11422         e_conv.is_owned = (e & 1) || (e == 0);
11423         e_conv = DecodeError_clone(&e_conv);
11424         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
11425         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
11426         return (uint64_t)ret_conv;
11427 }
11428
11429 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
11430         if ((_res & 1) != 0) return;
11431         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
11432         FREE((void*)_res);
11433         CResult_PongDecodeErrorZ_free(_res_conv);
11434 }
11435
11436 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
11437         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
11438         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
11439         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
11440         return (uint64_t)ret_conv;
11441 }
11442
11443 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
11444         LDKUnsignedChannelAnnouncement o_conv;
11445         o_conv.inner = (void*)(o & (~1));
11446         o_conv.is_owned = (o & 1) || (o == 0);
11447         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
11448         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
11449         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
11450         return (uint64_t)ret_conv;
11451 }
11452
11453 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
11454         LDKDecodeError e_conv;
11455         e_conv.inner = (void*)(e & (~1));
11456         e_conv.is_owned = (e & 1) || (e == 0);
11457         e_conv = DecodeError_clone(&e_conv);
11458         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
11459         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
11460         return (uint64_t)ret_conv;
11461 }
11462
11463 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
11464         if ((_res & 1) != 0) return;
11465         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
11466         FREE((void*)_res);
11467         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
11468 }
11469
11470 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
11471         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
11472         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
11473         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
11474         return (uint64_t)ret_conv;
11475 }
11476
11477 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
11478         LDKChannelAnnouncement o_conv;
11479         o_conv.inner = (void*)(o & (~1));
11480         o_conv.is_owned = (o & 1) || (o == 0);
11481         o_conv = ChannelAnnouncement_clone(&o_conv);
11482         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
11483         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
11484         return (uint64_t)ret_conv;
11485 }
11486
11487 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
11488         LDKDecodeError e_conv;
11489         e_conv.inner = (void*)(e & (~1));
11490         e_conv.is_owned = (e & 1) || (e == 0);
11491         e_conv = DecodeError_clone(&e_conv);
11492         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
11493         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
11494         return (uint64_t)ret_conv;
11495 }
11496
11497 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
11498         if ((_res & 1) != 0) return;
11499         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
11500         FREE((void*)_res);
11501         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
11502 }
11503
11504 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
11505         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
11506         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
11507         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
11508         return (uint64_t)ret_conv;
11509 }
11510
11511 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
11512         LDKUnsignedChannelUpdate o_conv;
11513         o_conv.inner = (void*)(o & (~1));
11514         o_conv.is_owned = (o & 1) || (o == 0);
11515         o_conv = UnsignedChannelUpdate_clone(&o_conv);
11516         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
11517         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
11518         return (uint64_t)ret_conv;
11519 }
11520
11521 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
11522         LDKDecodeError e_conv;
11523         e_conv.inner = (void*)(e & (~1));
11524         e_conv.is_owned = (e & 1) || (e == 0);
11525         e_conv = DecodeError_clone(&e_conv);
11526         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
11527         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
11528         return (uint64_t)ret_conv;
11529 }
11530
11531 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
11532         if ((_res & 1) != 0) return;
11533         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11534         FREE((void*)_res);
11535         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
11536 }
11537
11538 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
11539         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
11540         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
11541         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
11542         return (uint64_t)ret_conv;
11543 }
11544
11545 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
11546         LDKChannelUpdate o_conv;
11547         o_conv.inner = (void*)(o & (~1));
11548         o_conv.is_owned = (o & 1) || (o == 0);
11549         o_conv = ChannelUpdate_clone(&o_conv);
11550         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
11551         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
11552         return (uint64_t)ret_conv;
11553 }
11554
11555 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
11556         LDKDecodeError e_conv;
11557         e_conv.inner = (void*)(e & (~1));
11558         e_conv.is_owned = (e & 1) || (e == 0);
11559         e_conv = DecodeError_clone(&e_conv);
11560         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
11561         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
11562         return (uint64_t)ret_conv;
11563 }
11564
11565 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
11566         if ((_res & 1) != 0) return;
11567         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11568         FREE((void*)_res);
11569         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
11570 }
11571
11572 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
11573         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
11574         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
11575         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
11576         return (uint64_t)ret_conv;
11577 }
11578
11579 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
11580         LDKErrorMessage o_conv;
11581         o_conv.inner = (void*)(o & (~1));
11582         o_conv.is_owned = (o & 1) || (o == 0);
11583         o_conv = ErrorMessage_clone(&o_conv);
11584         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
11585         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
11586         return (uint64_t)ret_conv;
11587 }
11588
11589 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
11590         LDKDecodeError e_conv;
11591         e_conv.inner = (void*)(e & (~1));
11592         e_conv.is_owned = (e & 1) || (e == 0);
11593         e_conv = DecodeError_clone(&e_conv);
11594         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
11595         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
11596         return (uint64_t)ret_conv;
11597 }
11598
11599 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
11600         if ((_res & 1) != 0) return;
11601         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
11602         FREE((void*)_res);
11603         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
11604 }
11605
11606 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
11607         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
11608         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
11609         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
11610         return (uint64_t)ret_conv;
11611 }
11612
11613 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
11614         LDKUnsignedNodeAnnouncement o_conv;
11615         o_conv.inner = (void*)(o & (~1));
11616         o_conv.is_owned = (o & 1) || (o == 0);
11617         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
11618         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
11619         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
11620         return (uint64_t)ret_conv;
11621 }
11622
11623 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
11624         LDKDecodeError e_conv;
11625         e_conv.inner = (void*)(e & (~1));
11626         e_conv.is_owned = (e & 1) || (e == 0);
11627         e_conv = DecodeError_clone(&e_conv);
11628         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
11629         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
11630         return (uint64_t)ret_conv;
11631 }
11632
11633 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
11634         if ((_res & 1) != 0) return;
11635         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
11636         FREE((void*)_res);
11637         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
11638 }
11639
11640 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
11641         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
11642         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
11643         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
11644         return (uint64_t)ret_conv;
11645 }
11646
11647 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
11648         LDKNodeAnnouncement o_conv;
11649         o_conv.inner = (void*)(o & (~1));
11650         o_conv.is_owned = (o & 1) || (o == 0);
11651         o_conv = NodeAnnouncement_clone(&o_conv);
11652         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
11653         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
11654         return (uint64_t)ret_conv;
11655 }
11656
11657 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
11658         LDKDecodeError e_conv;
11659         e_conv.inner = (void*)(e & (~1));
11660         e_conv.is_owned = (e & 1) || (e == 0);
11661         e_conv = DecodeError_clone(&e_conv);
11662         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
11663         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
11664         return (uint64_t)ret_conv;
11665 }
11666
11667 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
11668         if ((_res & 1) != 0) return;
11669         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
11670         FREE((void*)_res);
11671         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
11672 }
11673
11674 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
11675         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
11676         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
11677         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
11678         return (uint64_t)ret_conv;
11679 }
11680
11681 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
11682         LDKQueryShortChannelIds o_conv;
11683         o_conv.inner = (void*)(o & (~1));
11684         o_conv.is_owned = (o & 1) || (o == 0);
11685         o_conv = QueryShortChannelIds_clone(&o_conv);
11686         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
11687         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
11688         return (uint64_t)ret_conv;
11689 }
11690
11691 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
11692         LDKDecodeError e_conv;
11693         e_conv.inner = (void*)(e & (~1));
11694         e_conv.is_owned = (e & 1) || (e == 0);
11695         e_conv = DecodeError_clone(&e_conv);
11696         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
11697         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
11698         return (uint64_t)ret_conv;
11699 }
11700
11701 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
11702         if ((_res & 1) != 0) return;
11703         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
11704         FREE((void*)_res);
11705         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
11706 }
11707
11708 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
11709         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
11710         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
11711         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
11712         return (uint64_t)ret_conv;
11713 }
11714
11715 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
11716         LDKReplyShortChannelIdsEnd o_conv;
11717         o_conv.inner = (void*)(o & (~1));
11718         o_conv.is_owned = (o & 1) || (o == 0);
11719         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
11720         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
11721         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
11722         return (uint64_t)ret_conv;
11723 }
11724
11725 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
11726         LDKDecodeError e_conv;
11727         e_conv.inner = (void*)(e & (~1));
11728         e_conv.is_owned = (e & 1) || (e == 0);
11729         e_conv = DecodeError_clone(&e_conv);
11730         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
11731         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
11732         return (uint64_t)ret_conv;
11733 }
11734
11735 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
11736         if ((_res & 1) != 0) return;
11737         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
11738         FREE((void*)_res);
11739         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
11740 }
11741
11742 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
11743         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
11744         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
11745         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
11746         return (uint64_t)ret_conv;
11747 }
11748
11749 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
11750         LDKQueryChannelRange o_conv;
11751         o_conv.inner = (void*)(o & (~1));
11752         o_conv.is_owned = (o & 1) || (o == 0);
11753         o_conv = QueryChannelRange_clone(&o_conv);
11754         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
11755         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
11756         return (uint64_t)ret_conv;
11757 }
11758
11759 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
11760         LDKDecodeError e_conv;
11761         e_conv.inner = (void*)(e & (~1));
11762         e_conv.is_owned = (e & 1) || (e == 0);
11763         e_conv = DecodeError_clone(&e_conv);
11764         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
11765         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
11766         return (uint64_t)ret_conv;
11767 }
11768
11769 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
11770         if ((_res & 1) != 0) return;
11771         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
11772         FREE((void*)_res);
11773         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
11774 }
11775
11776 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
11777         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
11778         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
11779         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
11780         return (uint64_t)ret_conv;
11781 }
11782
11783 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
11784         LDKReplyChannelRange o_conv;
11785         o_conv.inner = (void*)(o & (~1));
11786         o_conv.is_owned = (o & 1) || (o == 0);
11787         o_conv = ReplyChannelRange_clone(&o_conv);
11788         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
11789         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
11790         return (uint64_t)ret_conv;
11791 }
11792
11793 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
11794         LDKDecodeError e_conv;
11795         e_conv.inner = (void*)(e & (~1));
11796         e_conv.is_owned = (e & 1) || (e == 0);
11797         e_conv = DecodeError_clone(&e_conv);
11798         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
11799         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
11800         return (uint64_t)ret_conv;
11801 }
11802
11803 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
11804         if ((_res & 1) != 0) return;
11805         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
11806         FREE((void*)_res);
11807         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
11808 }
11809
11810 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
11811         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
11812         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
11813         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
11814         return (uint64_t)ret_conv;
11815 }
11816
11817 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
11818         LDKGossipTimestampFilter o_conv;
11819         o_conv.inner = (void*)(o & (~1));
11820         o_conv.is_owned = (o & 1) || (o == 0);
11821         o_conv = GossipTimestampFilter_clone(&o_conv);
11822         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
11823         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
11824         return (uint64_t)ret_conv;
11825 }
11826
11827 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
11828         LDKDecodeError e_conv;
11829         e_conv.inner = (void*)(e & (~1));
11830         e_conv.is_owned = (e & 1) || (e == 0);
11831         e_conv = DecodeError_clone(&e_conv);
11832         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
11833         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
11834         return (uint64_t)ret_conv;
11835 }
11836
11837 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
11838         if ((_res & 1) != 0) return;
11839         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
11840         FREE((void*)_res);
11841         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
11842 }
11843
11844 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
11845         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
11846         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
11847         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
11848         return (uint64_t)ret_conv;
11849 }
11850
11851 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
11852         LDKInvoice o_conv;
11853         o_conv.inner = (void*)(o & (~1));
11854         o_conv.is_owned = (o & 1) || (o == 0);
11855         o_conv = Invoice_clone(&o_conv);
11856         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
11857         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
11858         return (uint64_t)ret_conv;
11859 }
11860
11861 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
11862         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
11863         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1));
11864         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
11865         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
11866         return (uint64_t)ret_conv;
11867 }
11868
11869 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
11870         if ((_res & 1) != 0) return;
11871         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
11872         FREE((void*)_res);
11873         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
11874 }
11875
11876 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
11877         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
11878         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
11879         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
11880         return (uint64_t)ret_conv;
11881 }
11882
11883 uint32_t  __attribute__((visibility("default"))) TS_COption_FilterZ_some(uint32_t o) {
11884         LDKFilter o_conv = *(LDKFilter*)(((uint64_t)o) & ~1);
11885         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
11886         *ret_copy = COption_FilterZ_some(o_conv);
11887         uint64_t ret_ref = (uint64_t)ret_copy;
11888         return ret_ref;
11889 }
11890
11891 uint32_t  __attribute__((visibility("default"))) TS_COption_FilterZ_none() {
11892         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
11893         *ret_copy = COption_FilterZ_none();
11894         uint64_t ret_ref = (uint64_t)ret_copy;
11895         return ret_ref;
11896 }
11897
11898 void  __attribute__((visibility("default"))) TS_COption_FilterZ_free(uint32_t _res) {
11899         if ((_res & 1) != 0) return;
11900         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(((uint64_t)_res) & ~1);
11901         FREE((void*)_res);
11902         COption_FilterZ_free(_res_conv);
11903 }
11904
11905 void  __attribute__((visibility("default"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
11906         if ((this_ptr & 1) != 0) return;
11907         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(((uint64_t)this_ptr) & ~1);
11908         FREE((void*)this_ptr);
11909         PaymentPurpose_free(this_ptr_conv);
11910 }
11911
11912 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_clone(uint32_t orig) {
11913         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
11914         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
11915         *ret_copy = PaymentPurpose_clone(orig_conv);
11916         uint64_t ret_ref = (uint64_t)ret_copy;
11917         return ret_ref;
11918 }
11919
11920 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret, int64_t user_payment_id) {
11921         LDKThirtyTwoBytes payment_preimage_ref;
11922         CHECK(*((uint32_t*)payment_preimage) == 32);
11923         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
11924         LDKThirtyTwoBytes payment_secret_ref;
11925         CHECK(*((uint32_t*)payment_secret) == 32);
11926         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
11927         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
11928         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref, user_payment_id);
11929         uint64_t ret_ref = (uint64_t)ret_copy;
11930         return ret_ref;
11931 }
11932
11933 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
11934         LDKThirtyTwoBytes a_ref;
11935         CHECK(*((uint32_t*)a) == 32);
11936         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
11937         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
11938         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
11939         uint64_t ret_ref = (uint64_t)ret_copy;
11940         return ret_ref;
11941 }
11942
11943 void  __attribute__((visibility("default"))) TS_ClosureReason_free(uint32_t this_ptr) {
11944         if ((this_ptr & 1) != 0) return;
11945         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(((uint64_t)this_ptr) & ~1);
11946         FREE((void*)this_ptr);
11947         ClosureReason_free(this_ptr_conv);
11948 }
11949
11950 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_clone(uint32_t orig) {
11951         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
11952         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
11953         *ret_copy = ClosureReason_clone(orig_conv);
11954         uint64_t ret_ref = (uint64_t)ret_copy;
11955         return ret_ref;
11956 }
11957
11958 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
11959         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
11960         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
11961         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
11962         uint64_t ret_ref = (uint64_t)ret_copy;
11963         return ret_ref;
11964 }
11965
11966 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_holder_force_closed() {
11967         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
11968         *ret_copy = ClosureReason_holder_force_closed();
11969         uint64_t ret_ref = (uint64_t)ret_copy;
11970         return ret_ref;
11971 }
11972
11973 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_cooperative_closure() {
11974         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
11975         *ret_copy = ClosureReason_cooperative_closure();
11976         uint64_t ret_ref = (uint64_t)ret_copy;
11977         return ret_ref;
11978 }
11979
11980 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_commitment_tx_confirmed() {
11981         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
11982         *ret_copy = ClosureReason_commitment_tx_confirmed();
11983         uint64_t ret_ref = (uint64_t)ret_copy;
11984         return ret_ref;
11985 }
11986
11987 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_processing_error(jstring err) {
11988         LDKStr err_conv = str_ref_to_owned_c(err);
11989         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
11990         *ret_copy = ClosureReason_processing_error(err_conv);
11991         uint64_t ret_ref = (uint64_t)ret_copy;
11992         return ret_ref;
11993 }
11994
11995 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_disconnected_peer() {
11996         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
11997         *ret_copy = ClosureReason_disconnected_peer();
11998         uint64_t ret_ref = (uint64_t)ret_copy;
11999         return ret_ref;
12000 }
12001
12002 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_outdated_channel_manager() {
12003         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
12004         *ret_copy = ClosureReason_outdated_channel_manager();
12005         uint64_t ret_ref = (uint64_t)ret_copy;
12006         return ret_ref;
12007 }
12008
12009 int8_tArray  __attribute__((visibility("default"))) TS_ClosureReason_write(uint32_t obj) {
12010         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
12011         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
12012         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12013         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12014         CVec_u8Z_free(ret_var);
12015         return ret_arr;
12016 }
12017
12018 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
12019         if ((this_ptr & 1) != 0) return;
12020         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
12021         FREE((void*)this_ptr);
12022         Event_free(this_ptr_conv);
12023 }
12024
12025 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
12026         LDKEvent* orig_conv = (LDKEvent*)orig;
12027         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12028         *ret_copy = Event_clone(orig_conv);
12029         uint64_t ret_ref = (uint64_t)ret_copy;
12030         return ret_ref;
12031 }
12032
12033 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) {
12034         LDKThirtyTwoBytes temporary_channel_id_ref;
12035         CHECK(*((uint32_t*)temporary_channel_id) == 32);
12036         memcpy(temporary_channel_id_ref.data, (uint8_t*)(temporary_channel_id + 4), 32);
12037         LDKCVec_u8Z output_script_ref;
12038         output_script_ref.datalen = *((uint32_t*)output_script);
12039         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
12040         memcpy(output_script_ref.data, (uint8_t*)(output_script + 4), output_script_ref.datalen);
12041         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12042         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
12043         uint64_t ret_ref = (uint64_t)ret_copy;
12044         return ret_ref;
12045 }
12046
12047 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
12048         LDKThirtyTwoBytes payment_hash_ref;
12049         CHECK(*((uint32_t*)payment_hash) == 32);
12050         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
12051         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(((uint64_t)purpose) & ~1);
12052         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1));
12053         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12054         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
12055         uint64_t ret_ref = (uint64_t)ret_copy;
12056         return ret_ref;
12057 }
12058
12059 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_sent(int8_tArray payment_preimage) {
12060         LDKThirtyTwoBytes payment_preimage_ref;
12061         CHECK(*((uint32_t*)payment_preimage) == 32);
12062         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
12063         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12064         *ret_copy = Event_payment_sent(payment_preimage_ref);
12065         uint64_t ret_ref = (uint64_t)ret_copy;
12066         return ret_ref;
12067 }
12068
12069 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_path_failed(int8_tArray payment_hash, jboolean rejected_by_dest, uint32_t network_update, jboolean all_paths_failed, uint32_tArray path) {
12070         LDKThirtyTwoBytes payment_hash_ref;
12071         CHECK(*((uint32_t*)payment_hash) == 32);
12072         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
12073         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1);
12074         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
12075         LDKCVec_RouteHopZ path_constr;
12076         path_constr.datalen = *((uint32_t*)path);
12077         if (path_constr.datalen > 0)
12078                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12079         else
12080                 path_constr.data = NULL;
12081         uint32_t* path_vals = (uint32_t*)(path + 4);
12082         for (size_t k = 0; k < path_constr.datalen; k++) {
12083                 uint32_t path_conv_10 = path_vals[k];
12084                 LDKRouteHop path_conv_10_conv;
12085                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
12086                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
12087                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
12088                 path_constr.data[k] = path_conv_10_conv;
12089         }
12090         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12091         *ret_copy = Event_payment_path_failed(payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr);
12092         uint64_t ret_ref = (uint64_t)ret_copy;
12093         return ret_ref;
12094 }
12095
12096 uint32_t  __attribute__((visibility("default"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
12097         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12098         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
12099         uint64_t ret_ref = (uint64_t)ret_copy;
12100         return ret_ref;
12101 }
12102
12103 uint32_t  __attribute__((visibility("default"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
12104         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
12105         outputs_constr.datalen = *((uint32_t*)outputs);
12106         if (outputs_constr.datalen > 0)
12107                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12108         else
12109                 outputs_constr.data = NULL;
12110         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
12111         for (size_t b = 0; b < outputs_constr.datalen; b++) {
12112                 uint32_t outputs_conv_27 = outputs_vals[b];
12113                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1);
12114                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
12115                 outputs_constr.data[b] = outputs_conv_27_conv;
12116         }
12117         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12118         *ret_copy = Event_spendable_outputs(outputs_constr);
12119         uint64_t ret_ref = (uint64_t)ret_copy;
12120         return ret_ref;
12121 }
12122
12123 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
12124         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1);
12125         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1));
12126         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12127         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
12128         uint64_t ret_ref = (uint64_t)ret_copy;
12129         return ret_ref;
12130 }
12131
12132 uint32_t  __attribute__((visibility("default"))) TS_Event_channel_closed(int8_tArray channel_id, uint32_t reason) {
12133         LDKThirtyTwoBytes channel_id_ref;
12134         CHECK(*((uint32_t*)channel_id) == 32);
12135         memcpy(channel_id_ref.data, (uint8_t*)(channel_id + 4), 32);
12136         LDKClosureReason reason_conv = *(LDKClosureReason*)(((uint64_t)reason) & ~1);
12137         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
12138         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12139         *ret_copy = Event_channel_closed(channel_id_ref, reason_conv);
12140         uint64_t ret_ref = (uint64_t)ret_copy;
12141         return ret_ref;
12142 }
12143
12144 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
12145         LDKEvent* obj_conv = (LDKEvent*)obj;
12146         LDKCVec_u8Z ret_var = Event_write(obj_conv);
12147         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12148         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
12149         CVec_u8Z_free(ret_var);
12150         return ret_arr;
12151 }
12152
12153 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
12154         if ((this_ptr & 1) != 0) return;
12155         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
12156         FREE((void*)this_ptr);
12157         MessageSendEvent_free(this_ptr_conv);
12158 }
12159
12160 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
12161         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
12162         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12163         *ret_copy = MessageSendEvent_clone(orig_conv);
12164         uint64_t ret_ref = (uint64_t)ret_copy;
12165         return ret_ref;
12166 }
12167
12168 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
12169         LDKPublicKey node_id_ref;
12170         CHECK(*((uint32_t*)node_id) == 33);
12171         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12172         LDKAcceptChannel msg_conv;
12173         msg_conv.inner = (void*)(msg & (~1));
12174         msg_conv.is_owned = (msg & 1) || (msg == 0);
12175         msg_conv = AcceptChannel_clone(&msg_conv);
12176         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12177         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
12178         uint64_t ret_ref = (uint64_t)ret_copy;
12179         return ret_ref;
12180 }
12181
12182 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
12183         LDKPublicKey node_id_ref;
12184         CHECK(*((uint32_t*)node_id) == 33);
12185         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12186         LDKOpenChannel msg_conv;
12187         msg_conv.inner = (void*)(msg & (~1));
12188         msg_conv.is_owned = (msg & 1) || (msg == 0);
12189         msg_conv = OpenChannel_clone(&msg_conv);
12190         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12191         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
12192         uint64_t ret_ref = (uint64_t)ret_copy;
12193         return ret_ref;
12194 }
12195
12196 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
12197         LDKPublicKey node_id_ref;
12198         CHECK(*((uint32_t*)node_id) == 33);
12199         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12200         LDKFundingCreated msg_conv;
12201         msg_conv.inner = (void*)(msg & (~1));
12202         msg_conv.is_owned = (msg & 1) || (msg == 0);
12203         msg_conv = FundingCreated_clone(&msg_conv);
12204         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12205         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
12206         uint64_t ret_ref = (uint64_t)ret_copy;
12207         return ret_ref;
12208 }
12209
12210 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
12211         LDKPublicKey node_id_ref;
12212         CHECK(*((uint32_t*)node_id) == 33);
12213         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12214         LDKFundingSigned msg_conv;
12215         msg_conv.inner = (void*)(msg & (~1));
12216         msg_conv.is_owned = (msg & 1) || (msg == 0);
12217         msg_conv = FundingSigned_clone(&msg_conv);
12218         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12219         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
12220         uint64_t ret_ref = (uint64_t)ret_copy;
12221         return ret_ref;
12222 }
12223
12224 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
12225         LDKPublicKey node_id_ref;
12226         CHECK(*((uint32_t*)node_id) == 33);
12227         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12228         LDKFundingLocked msg_conv;
12229         msg_conv.inner = (void*)(msg & (~1));
12230         msg_conv.is_owned = (msg & 1) || (msg == 0);
12231         msg_conv = FundingLocked_clone(&msg_conv);
12232         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12233         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
12234         uint64_t ret_ref = (uint64_t)ret_copy;
12235         return ret_ref;
12236 }
12237
12238 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
12239         LDKPublicKey node_id_ref;
12240         CHECK(*((uint32_t*)node_id) == 33);
12241         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12242         LDKAnnouncementSignatures msg_conv;
12243         msg_conv.inner = (void*)(msg & (~1));
12244         msg_conv.is_owned = (msg & 1) || (msg == 0);
12245         msg_conv = AnnouncementSignatures_clone(&msg_conv);
12246         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12247         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
12248         uint64_t ret_ref = (uint64_t)ret_copy;
12249         return ret_ref;
12250 }
12251
12252 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
12253         LDKPublicKey node_id_ref;
12254         CHECK(*((uint32_t*)node_id) == 33);
12255         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12256         LDKCommitmentUpdate updates_conv;
12257         updates_conv.inner = (void*)(updates & (~1));
12258         updates_conv.is_owned = (updates & 1) || (updates == 0);
12259         updates_conv = CommitmentUpdate_clone(&updates_conv);
12260         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12261         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
12262         uint64_t ret_ref = (uint64_t)ret_copy;
12263         return ret_ref;
12264 }
12265
12266 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
12267         LDKPublicKey node_id_ref;
12268         CHECK(*((uint32_t*)node_id) == 33);
12269         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12270         LDKRevokeAndACK msg_conv;
12271         msg_conv.inner = (void*)(msg & (~1));
12272         msg_conv.is_owned = (msg & 1) || (msg == 0);
12273         msg_conv = RevokeAndACK_clone(&msg_conv);
12274         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12275         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
12276         uint64_t ret_ref = (uint64_t)ret_copy;
12277         return ret_ref;
12278 }
12279
12280 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
12281         LDKPublicKey node_id_ref;
12282         CHECK(*((uint32_t*)node_id) == 33);
12283         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12284         LDKClosingSigned msg_conv;
12285         msg_conv.inner = (void*)(msg & (~1));
12286         msg_conv.is_owned = (msg & 1) || (msg == 0);
12287         msg_conv = ClosingSigned_clone(&msg_conv);
12288         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12289         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
12290         uint64_t ret_ref = (uint64_t)ret_copy;
12291         return ret_ref;
12292 }
12293
12294 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
12295         LDKPublicKey node_id_ref;
12296         CHECK(*((uint32_t*)node_id) == 33);
12297         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12298         LDKShutdown msg_conv;
12299         msg_conv.inner = (void*)(msg & (~1));
12300         msg_conv.is_owned = (msg & 1) || (msg == 0);
12301         msg_conv = Shutdown_clone(&msg_conv);
12302         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12303         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
12304         uint64_t ret_ref = (uint64_t)ret_copy;
12305         return ret_ref;
12306 }
12307
12308 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
12309         LDKPublicKey node_id_ref;
12310         CHECK(*((uint32_t*)node_id) == 33);
12311         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12312         LDKChannelReestablish msg_conv;
12313         msg_conv.inner = (void*)(msg & (~1));
12314         msg_conv.is_owned = (msg & 1) || (msg == 0);
12315         msg_conv = ChannelReestablish_clone(&msg_conv);
12316         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12317         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
12318         uint64_t ret_ref = (uint64_t)ret_copy;
12319         return ret_ref;
12320 }
12321
12322 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
12323         LDKChannelAnnouncement msg_conv;
12324         msg_conv.inner = (void*)(msg & (~1));
12325         msg_conv.is_owned = (msg & 1) || (msg == 0);
12326         msg_conv = ChannelAnnouncement_clone(&msg_conv);
12327         LDKChannelUpdate update_msg_conv;
12328         update_msg_conv.inner = (void*)(update_msg & (~1));
12329         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
12330         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
12331         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12332         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
12333         uint64_t ret_ref = (uint64_t)ret_copy;
12334         return ret_ref;
12335 }
12336
12337 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
12338         LDKNodeAnnouncement msg_conv;
12339         msg_conv.inner = (void*)(msg & (~1));
12340         msg_conv.is_owned = (msg & 1) || (msg == 0);
12341         msg_conv = NodeAnnouncement_clone(&msg_conv);
12342         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12343         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
12344         uint64_t ret_ref = (uint64_t)ret_copy;
12345         return ret_ref;
12346 }
12347
12348 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
12349         LDKChannelUpdate msg_conv;
12350         msg_conv.inner = (void*)(msg & (~1));
12351         msg_conv.is_owned = (msg & 1) || (msg == 0);
12352         msg_conv = ChannelUpdate_clone(&msg_conv);
12353         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12354         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
12355         uint64_t ret_ref = (uint64_t)ret_copy;
12356         return ret_ref;
12357 }
12358
12359 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
12360         LDKPublicKey node_id_ref;
12361         CHECK(*((uint32_t*)node_id) == 33);
12362         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12363         LDKChannelUpdate msg_conv;
12364         msg_conv.inner = (void*)(msg & (~1));
12365         msg_conv.is_owned = (msg & 1) || (msg == 0);
12366         msg_conv = ChannelUpdate_clone(&msg_conv);
12367         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12368         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
12369         uint64_t ret_ref = (uint64_t)ret_copy;
12370         return ret_ref;
12371 }
12372
12373 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
12374         LDKPublicKey node_id_ref;
12375         CHECK(*((uint32_t*)node_id) == 33);
12376         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12377         LDKErrorAction action_conv = *(LDKErrorAction*)(((uint64_t)action) & ~1);
12378         action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1));
12379         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12380         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
12381         uint64_t ret_ref = (uint64_t)ret_copy;
12382         return ret_ref;
12383 }
12384
12385 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
12386         LDKPublicKey node_id_ref;
12387         CHECK(*((uint32_t*)node_id) == 33);
12388         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12389         LDKQueryChannelRange msg_conv;
12390         msg_conv.inner = (void*)(msg & (~1));
12391         msg_conv.is_owned = (msg & 1) || (msg == 0);
12392         msg_conv = QueryChannelRange_clone(&msg_conv);
12393         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12394         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
12395         uint64_t ret_ref = (uint64_t)ret_copy;
12396         return ret_ref;
12397 }
12398
12399 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
12400         LDKPublicKey node_id_ref;
12401         CHECK(*((uint32_t*)node_id) == 33);
12402         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12403         LDKQueryShortChannelIds msg_conv;
12404         msg_conv.inner = (void*)(msg & (~1));
12405         msg_conv.is_owned = (msg & 1) || (msg == 0);
12406         msg_conv = QueryShortChannelIds_clone(&msg_conv);
12407         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12408         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
12409         uint64_t ret_ref = (uint64_t)ret_copy;
12410         return ret_ref;
12411 }
12412
12413 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
12414         LDKPublicKey node_id_ref;
12415         CHECK(*((uint32_t*)node_id) == 33);
12416         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12417         LDKReplyChannelRange msg_conv;
12418         msg_conv.inner = (void*)(msg & (~1));
12419         msg_conv.is_owned = (msg & 1) || (msg == 0);
12420         msg_conv = ReplyChannelRange_clone(&msg_conv);
12421         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12422         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
12423         uint64_t ret_ref = (uint64_t)ret_copy;
12424         return ret_ref;
12425 }
12426
12427 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
12428         if ((this_ptr & 1) != 0) return;
12429         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
12430         FREE((void*)this_ptr);
12431         MessageSendEventsProvider_free(this_ptr_conv);
12432 }
12433
12434 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
12435         if ((this_ptr & 1) != 0) return;
12436         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
12437         FREE((void*)this_ptr);
12438         EventsProvider_free(this_ptr_conv);
12439 }
12440
12441 void  __attribute__((visibility("default"))) TS_EventHandler_free(uint32_t this_ptr) {
12442         if ((this_ptr & 1) != 0) return;
12443         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
12444         FREE((void*)this_ptr);
12445         EventHandler_free(this_ptr_conv);
12446 }
12447
12448 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
12449         if ((this_ptr & 1) != 0) return;
12450         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
12451         FREE((void*)this_ptr);
12452         APIError_free(this_ptr_conv);
12453 }
12454
12455 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
12456         LDKAPIError* orig_conv = (LDKAPIError*)orig;
12457         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12458         *ret_copy = APIError_clone(orig_conv);
12459         uint64_t ret_ref = (uint64_t)ret_copy;
12460         return ret_ref;
12461 }
12462
12463 uint32_t  __attribute__((visibility("default"))) TS_APIError_apimisuse_error(jstring err) {
12464         LDKStr err_conv = str_ref_to_owned_c(err);
12465         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12466         *ret_copy = APIError_apimisuse_error(err_conv);
12467         uint64_t ret_ref = (uint64_t)ret_copy;
12468         return ret_ref;
12469 }
12470
12471 uint32_t  __attribute__((visibility("default"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
12472         LDKStr err_conv = str_ref_to_owned_c(err);
12473         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12474         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
12475         uint64_t ret_ref = (uint64_t)ret_copy;
12476         return ret_ref;
12477 }
12478
12479 uint32_t  __attribute__((visibility("default"))) TS_APIError_route_error(jstring err) {
12480         LDKStr err_conv = str_ref_to_owned_c(err);
12481         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12482         *ret_copy = APIError_route_error(err_conv);
12483         uint64_t ret_ref = (uint64_t)ret_copy;
12484         return ret_ref;
12485 }
12486
12487 uint32_t  __attribute__((visibility("default"))) TS_APIError_channel_unavailable(jstring err) {
12488         LDKStr err_conv = str_ref_to_owned_c(err);
12489         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12490         *ret_copy = APIError_channel_unavailable(err_conv);
12491         uint64_t ret_ref = (uint64_t)ret_copy;
12492         return ret_ref;
12493 }
12494
12495 uint32_t  __attribute__((visibility("default"))) TS_APIError_monitor_update_failed() {
12496         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12497         *ret_copy = APIError_monitor_update_failed();
12498         uint64_t ret_ref = (uint64_t)ret_copy;
12499         return ret_ref;
12500 }
12501
12502 uint32_t  __attribute__((visibility("default"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
12503         LDKShutdownScript script_conv;
12504         script_conv.inner = (void*)(script & (~1));
12505         script_conv.is_owned = (script & 1) || (script == 0);
12506         script_conv = ShutdownScript_clone(&script_conv);
12507         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
12508         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
12509         uint64_t ret_ref = (uint64_t)ret_copy;
12510         return ret_ref;
12511 }
12512
12513 uint32_t  __attribute__((visibility("default"))) TS_sign(int8_tArray msg, int8_tArray sk) {
12514         LDKu8slice msg_ref;
12515         msg_ref.datalen = *((uint32_t*)msg);
12516         msg_ref.data = (int8_t*)(msg + 4);
12517         unsigned char sk_arr[32];
12518         CHECK(*((uint32_t*)sk) == 32);
12519         memcpy(sk_arr, (uint8_t*)(sk + 4), 32);
12520         unsigned char (*sk_ref)[32] = &sk_arr;
12521         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
12522         *ret_conv = sign(msg_ref, sk_ref);
12523         return (uint64_t)ret_conv;
12524 }
12525
12526 uint32_t  __attribute__((visibility("default"))) TS_recover_pk(int8_tArray msg, jstring sig) {
12527         LDKu8slice msg_ref;
12528         msg_ref.datalen = *((uint32_t*)msg);
12529         msg_ref.data = (int8_t*)(msg + 4);
12530         LDKStr sig_conv = str_ref_to_owned_c(sig);
12531         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
12532         *ret_conv = recover_pk(msg_ref, sig_conv);
12533         return (uint64_t)ret_conv;
12534 }
12535
12536 jboolean  __attribute__((visibility("default"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
12537         LDKu8slice msg_ref;
12538         msg_ref.datalen = *((uint32_t*)msg);
12539         msg_ref.data = (int8_t*)(msg + 4);
12540         LDKStr sig_conv = str_ref_to_owned_c(sig);
12541         LDKPublicKey pk_ref;
12542         CHECK(*((uint32_t*)pk) == 33);
12543         memcpy(pk_ref.compressed_form, (uint8_t*)(pk + 4), 33);
12544         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
12545         return ret_val;
12546 }
12547
12548 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
12549         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
12550         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
12551         return ret_conv;
12552 }
12553
12554 uint32_t  __attribute__((visibility("default"))) TS_Level_trace() {
12555         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
12556         return ret_conv;
12557 }
12558
12559 uint32_t  __attribute__((visibility("default"))) TS_Level_debug() {
12560         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
12561         return ret_conv;
12562 }
12563
12564 uint32_t  __attribute__((visibility("default"))) TS_Level_info() {
12565         uint32_t ret_conv = LDKLevel_to_js(Level_info());
12566         return ret_conv;
12567 }
12568
12569 uint32_t  __attribute__((visibility("default"))) TS_Level_warn() {
12570         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
12571         return ret_conv;
12572 }
12573
12574 uint32_t  __attribute__((visibility("default"))) TS_Level_error() {
12575         uint32_t ret_conv = LDKLevel_to_js(Level_error());
12576         return ret_conv;
12577 }
12578
12579 jboolean  __attribute__((visibility("default"))) TS_Level_eq(uint32_t a, uint32_t b) {
12580         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
12581         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
12582         jboolean ret_val = Level_eq(a_conv, b_conv);
12583         return ret_val;
12584 }
12585
12586 int64_t  __attribute__((visibility("default"))) TS_Level_hash(uint32_t o) {
12587         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
12588         int64_t ret_val = Level_hash(o_conv);
12589         return ret_val;
12590 }
12591
12592 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
12593         uint32_t ret_conv = LDKLevel_to_js(Level_max());
12594         return ret_conv;
12595 }
12596
12597 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
12598         if ((this_ptr & 1) != 0) return;
12599         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
12600         FREE((void*)this_ptr);
12601         Logger_free(this_ptr_conv);
12602 }
12603
12604 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
12605         LDKChannelHandshakeConfig this_obj_conv;
12606         this_obj_conv.inner = (void*)(this_obj & (~1));
12607         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12608         ChannelHandshakeConfig_free(this_obj_conv);
12609 }
12610
12611 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
12612         LDKChannelHandshakeConfig this_ptr_conv;
12613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12614         this_ptr_conv.is_owned = false;
12615         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
12616         return ret_val;
12617 }
12618
12619 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
12620         LDKChannelHandshakeConfig this_ptr_conv;
12621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12622         this_ptr_conv.is_owned = false;
12623         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
12624 }
12625
12626 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
12627         LDKChannelHandshakeConfig this_ptr_conv;
12628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12629         this_ptr_conv.is_owned = false;
12630         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
12631         return ret_val;
12632 }
12633
12634 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
12635         LDKChannelHandshakeConfig this_ptr_conv;
12636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12637         this_ptr_conv.is_owned = false;
12638         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
12639 }
12640
12641 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
12642         LDKChannelHandshakeConfig this_ptr_conv;
12643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12644         this_ptr_conv.is_owned = false;
12645         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
12646         return ret_val;
12647 }
12648
12649 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
12650         LDKChannelHandshakeConfig this_ptr_conv;
12651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12652         this_ptr_conv.is_owned = false;
12653         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
12654 }
12655
12656 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) {
12657         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
12658         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12659         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12660         uint64_t ret_ref = (uint64_t)ret_var.inner;
12661         if (ret_var.is_owned) {
12662                 ret_ref |= 1;
12663         }
12664         return ret_ref;
12665 }
12666
12667 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
12668         LDKChannelHandshakeConfig orig_conv;
12669         orig_conv.inner = (void*)(orig & (~1));
12670         orig_conv.is_owned = false;
12671         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
12672         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12673         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12674         uint64_t ret_ref = (uint64_t)ret_var.inner;
12675         if (ret_var.is_owned) {
12676                 ret_ref |= 1;
12677         }
12678         return ret_ref;
12679 }
12680
12681 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
12682         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
12683         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12684         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12685         uint64_t ret_ref = (uint64_t)ret_var.inner;
12686         if (ret_var.is_owned) {
12687                 ret_ref |= 1;
12688         }
12689         return ret_ref;
12690 }
12691
12692 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
12693         LDKChannelHandshakeLimits this_obj_conv;
12694         this_obj_conv.inner = (void*)(this_obj & (~1));
12695         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12696         ChannelHandshakeLimits_free(this_obj_conv);
12697 }
12698
12699 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
12700         LDKChannelHandshakeLimits this_ptr_conv;
12701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12702         this_ptr_conv.is_owned = false;
12703         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
12704         return ret_val;
12705 }
12706
12707 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
12708         LDKChannelHandshakeLimits this_ptr_conv;
12709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12710         this_ptr_conv.is_owned = false;
12711         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
12712 }
12713
12714 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
12715         LDKChannelHandshakeLimits this_ptr_conv;
12716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12717         this_ptr_conv.is_owned = false;
12718         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
12719         return ret_val;
12720 }
12721
12722 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
12723         LDKChannelHandshakeLimits this_ptr_conv;
12724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12725         this_ptr_conv.is_owned = false;
12726         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
12727 }
12728
12729 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
12730         LDKChannelHandshakeLimits this_ptr_conv;
12731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12732         this_ptr_conv.is_owned = false;
12733         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
12734         return ret_val;
12735 }
12736
12737 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
12738         LDKChannelHandshakeLimits this_ptr_conv;
12739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12740         this_ptr_conv.is_owned = false;
12741         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
12742 }
12743
12744 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
12745         LDKChannelHandshakeLimits this_ptr_conv;
12746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12747         this_ptr_conv.is_owned = false;
12748         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
12749         return ret_val;
12750 }
12751
12752 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
12753         LDKChannelHandshakeLimits this_ptr_conv;
12754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12755         this_ptr_conv.is_owned = false;
12756         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
12757 }
12758
12759 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
12760         LDKChannelHandshakeLimits this_ptr_conv;
12761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12762         this_ptr_conv.is_owned = false;
12763         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
12764         return ret_val;
12765 }
12766
12767 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
12768         LDKChannelHandshakeLimits this_ptr_conv;
12769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12770         this_ptr_conv.is_owned = false;
12771         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
12772 }
12773
12774 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
12775         LDKChannelHandshakeLimits this_ptr_conv;
12776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12777         this_ptr_conv.is_owned = false;
12778         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
12779         return ret_val;
12780 }
12781
12782 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
12783         LDKChannelHandshakeLimits this_ptr_conv;
12784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12785         this_ptr_conv.is_owned = false;
12786         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
12787 }
12788
12789 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
12790         LDKChannelHandshakeLimits this_ptr_conv;
12791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12792         this_ptr_conv.is_owned = false;
12793         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
12794         return ret_val;
12795 }
12796
12797 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
12798         LDKChannelHandshakeLimits this_ptr_conv;
12799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12800         this_ptr_conv.is_owned = false;
12801         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
12802 }
12803
12804 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
12805         LDKChannelHandshakeLimits this_ptr_conv;
12806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12807         this_ptr_conv.is_owned = false;
12808         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
12809         return ret_val;
12810 }
12811
12812 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
12813         LDKChannelHandshakeLimits this_ptr_conv;
12814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12815         this_ptr_conv.is_owned = false;
12816         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
12817 }
12818
12819 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) {
12820         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);
12821         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12822         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12823         uint64_t ret_ref = (uint64_t)ret_var.inner;
12824         if (ret_var.is_owned) {
12825                 ret_ref |= 1;
12826         }
12827         return ret_ref;
12828 }
12829
12830 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
12831         LDKChannelHandshakeLimits orig_conv;
12832         orig_conv.inner = (void*)(orig & (~1));
12833         orig_conv.is_owned = false;
12834         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
12835         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12836         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12837         uint64_t ret_ref = (uint64_t)ret_var.inner;
12838         if (ret_var.is_owned) {
12839                 ret_ref |= 1;
12840         }
12841         return ret_ref;
12842 }
12843
12844 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
12845         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
12846         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12847         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12848         uint64_t ret_ref = (uint64_t)ret_var.inner;
12849         if (ret_var.is_owned) {
12850                 ret_ref |= 1;
12851         }
12852         return ret_ref;
12853 }
12854
12855 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_obj) {
12856         LDKChannelConfig this_obj_conv;
12857         this_obj_conv.inner = (void*)(this_obj & (~1));
12858         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
12859         ChannelConfig_free(this_obj_conv);
12860 }
12861
12862 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
12863         LDKChannelConfig this_ptr_conv;
12864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12865         this_ptr_conv.is_owned = false;
12866         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
12867         return ret_val;
12868 }
12869
12870 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
12871         LDKChannelConfig this_ptr_conv;
12872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12873         this_ptr_conv.is_owned = false;
12874         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
12875 }
12876
12877 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
12878         LDKChannelConfig this_ptr_conv;
12879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12880         this_ptr_conv.is_owned = false;
12881         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
12882         return ret_val;
12883 }
12884
12885 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_base_msat(uint32_t this_ptr, int32_t val) {
12886         LDKChannelConfig this_ptr_conv;
12887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12888         this_ptr_conv.is_owned = false;
12889         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
12890 }
12891
12892 int16_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
12893         LDKChannelConfig this_ptr_conv;
12894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12895         this_ptr_conv.is_owned = false;
12896         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
12897         return ret_val;
12898 }
12899
12900 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
12901         LDKChannelConfig this_ptr_conv;
12902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12903         this_ptr_conv.is_owned = false;
12904         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
12905 }
12906
12907 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
12908         LDKChannelConfig this_ptr_conv;
12909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12910         this_ptr_conv.is_owned = false;
12911         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
12912         return ret_val;
12913 }
12914
12915 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
12916         LDKChannelConfig this_ptr_conv;
12917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12918         this_ptr_conv.is_owned = false;
12919         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
12920 }
12921
12922 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
12923         LDKChannelConfig this_ptr_conv;
12924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12925         this_ptr_conv.is_owned = false;
12926         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
12927         return ret_val;
12928 }
12929
12930 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
12931         LDKChannelConfig this_ptr_conv;
12932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12933         this_ptr_conv.is_owned = false;
12934         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
12935 }
12936
12937 int64_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_max_dust_htlc_exposure_msat(uint32_t this_ptr) {
12938         LDKChannelConfig this_ptr_conv;
12939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12940         this_ptr_conv.is_owned = false;
12941         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
12942         return ret_val;
12943 }
12944
12945 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_max_dust_htlc_exposure_msat(uint32_t this_ptr, int64_t val) {
12946         LDKChannelConfig this_ptr_conv;
12947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12948         this_ptr_conv.is_owned = false;
12949         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
12950 }
12951
12952 int64_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr) {
12953         LDKChannelConfig this_ptr_conv;
12954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12955         this_ptr_conv.is_owned = false;
12956         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
12957         return ret_val;
12958 }
12959
12960 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
12961         LDKChannelConfig this_ptr_conv;
12962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12963         this_ptr_conv.is_owned = false;
12964         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
12965 }
12966
12967 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) {
12968         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);
12969         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12970         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12971         uint64_t ret_ref = (uint64_t)ret_var.inner;
12972         if (ret_var.is_owned) {
12973                 ret_ref |= 1;
12974         }
12975         return ret_ref;
12976 }
12977
12978 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
12979         LDKChannelConfig orig_conv;
12980         orig_conv.inner = (void*)(orig & (~1));
12981         orig_conv.is_owned = false;
12982         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
12983         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12984         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12985         uint64_t ret_ref = (uint64_t)ret_var.inner;
12986         if (ret_var.is_owned) {
12987                 ret_ref |= 1;
12988         }
12989         return ret_ref;
12990 }
12991
12992 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
12993         LDKChannelConfig ret_var = ChannelConfig_default();
12994         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12995         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12996         uint64_t ret_ref = (uint64_t)ret_var.inner;
12997         if (ret_var.is_owned) {
12998                 ret_ref |= 1;
12999         }
13000         return ret_ref;
13001 }
13002
13003 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
13004         LDKChannelConfig obj_conv;
13005         obj_conv.inner = (void*)(obj & (~1));
13006         obj_conv.is_owned = false;
13007         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
13008         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13009         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13010         CVec_u8Z_free(ret_var);
13011         return ret_arr;
13012 }
13013
13014 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
13015         LDKu8slice ser_ref;
13016         ser_ref.datalen = *((uint32_t*)ser);
13017         ser_ref.data = (int8_t*)(ser + 4);
13018         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
13019         *ret_conv = ChannelConfig_read(ser_ref);
13020         return (uint64_t)ret_conv;
13021 }
13022
13023 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_obj) {
13024         LDKUserConfig this_obj_conv;
13025         this_obj_conv.inner = (void*)(this_obj & (~1));
13026         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13027         UserConfig_free(this_obj_conv);
13028 }
13029
13030 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
13031         LDKUserConfig this_ptr_conv;
13032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13033         this_ptr_conv.is_owned = false;
13034         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
13035         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13036         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13037         uint64_t ret_ref = (uint64_t)ret_var.inner;
13038         if (ret_var.is_owned) {
13039                 ret_ref |= 1;
13040         }
13041         return ret_ref;
13042 }
13043
13044 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
13045         LDKUserConfig this_ptr_conv;
13046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13047         this_ptr_conv.is_owned = false;
13048         LDKChannelHandshakeConfig val_conv;
13049         val_conv.inner = (void*)(val & (~1));
13050         val_conv.is_owned = (val & 1) || (val == 0);
13051         val_conv = ChannelHandshakeConfig_clone(&val_conv);
13052         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
13053 }
13054
13055 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
13056         LDKUserConfig this_ptr_conv;
13057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13058         this_ptr_conv.is_owned = false;
13059         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
13060         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13061         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13062         uint64_t ret_ref = (uint64_t)ret_var.inner;
13063         if (ret_var.is_owned) {
13064                 ret_ref |= 1;
13065         }
13066         return ret_ref;
13067 }
13068
13069 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
13070         LDKUserConfig this_ptr_conv;
13071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13072         this_ptr_conv.is_owned = false;
13073         LDKChannelHandshakeLimits val_conv;
13074         val_conv.inner = (void*)(val & (~1));
13075         val_conv.is_owned = (val & 1) || (val == 0);
13076         val_conv = ChannelHandshakeLimits_clone(&val_conv);
13077         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
13078 }
13079
13080 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
13081         LDKUserConfig this_ptr_conv;
13082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13083         this_ptr_conv.is_owned = false;
13084         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
13085         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13086         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13087         uint64_t ret_ref = (uint64_t)ret_var.inner;
13088         if (ret_var.is_owned) {
13089                 ret_ref |= 1;
13090         }
13091         return ret_ref;
13092 }
13093
13094 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
13095         LDKUserConfig this_ptr_conv;
13096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13097         this_ptr_conv.is_owned = false;
13098         LDKChannelConfig val_conv;
13099         val_conv.inner = (void*)(val & (~1));
13100         val_conv.is_owned = (val & 1) || (val == 0);
13101         val_conv = ChannelConfig_clone(&val_conv);
13102         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
13103 }
13104
13105 jboolean  __attribute__((visibility("default"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
13106         LDKUserConfig this_ptr_conv;
13107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13108         this_ptr_conv.is_owned = false;
13109         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
13110         return ret_val;
13111 }
13112
13113 void  __attribute__((visibility("default"))) TS_UserConfig_set_accept_forwards_to_priv_channels(uint32_t this_ptr, jboolean val) {
13114         LDKUserConfig this_ptr_conv;
13115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13116         this_ptr_conv.is_owned = false;
13117         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
13118 }
13119
13120 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) {
13121         LDKChannelHandshakeConfig own_channel_config_arg_conv;
13122         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
13123         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
13124         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
13125         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
13126         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
13127         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
13128         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
13129         LDKChannelConfig channel_options_arg_conv;
13130         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
13131         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
13132         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
13133         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);
13134         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13135         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13136         uint64_t ret_ref = (uint64_t)ret_var.inner;
13137         if (ret_var.is_owned) {
13138                 ret_ref |= 1;
13139         }
13140         return ret_ref;
13141 }
13142
13143 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
13144         LDKUserConfig orig_conv;
13145         orig_conv.inner = (void*)(orig & (~1));
13146         orig_conv.is_owned = false;
13147         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
13148         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13149         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13150         uint64_t ret_ref = (uint64_t)ret_var.inner;
13151         if (ret_var.is_owned) {
13152                 ret_ref |= 1;
13153         }
13154         return ret_ref;
13155 }
13156
13157 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
13158         LDKUserConfig ret_var = UserConfig_default();
13159         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13160         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13161         uint64_t ret_ref = (uint64_t)ret_var.inner;
13162         if (ret_var.is_owned) {
13163                 ret_ref |= 1;
13164         }
13165         return ret_ref;
13166 }
13167
13168 void  __attribute__((visibility("default"))) TS_BestBlock_free(uint32_t this_obj) {
13169         LDKBestBlock this_obj_conv;
13170         this_obj_conv.inner = (void*)(this_obj & (~1));
13171         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13172         BestBlock_free(this_obj_conv);
13173 }
13174
13175 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t orig) {
13176         LDKBestBlock orig_conv;
13177         orig_conv.inner = (void*)(orig & (~1));
13178         orig_conv.is_owned = false;
13179         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
13180         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13181         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13182         uint64_t ret_ref = (uint64_t)ret_var.inner;
13183         if (ret_var.is_owned) {
13184                 ret_ref |= 1;
13185         }
13186         return ret_ref;
13187 }
13188
13189 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) {
13190         LDKNetwork network_conv = LDKNetwork_from_js(network);
13191         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
13192         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13193         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13194         uint64_t ret_ref = (uint64_t)ret_var.inner;
13195         if (ret_var.is_owned) {
13196                 ret_ref |= 1;
13197         }
13198         return ret_ref;
13199 }
13200
13201 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
13202         LDKThirtyTwoBytes block_hash_ref;
13203         CHECK(*((uint32_t*)block_hash) == 32);
13204         memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32);
13205         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
13206         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13207         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13208         uint64_t ret_ref = (uint64_t)ret_var.inner;
13209         if (ret_var.is_owned) {
13210                 ret_ref |= 1;
13211         }
13212         return ret_ref;
13213 }
13214
13215 int8_tArray  __attribute__((visibility("default"))) TS_BestBlock_block_hash(uint32_t this_arg) {
13216         LDKBestBlock this_arg_conv;
13217         this_arg_conv.inner = (void*)(this_arg & (~1));
13218         this_arg_conv.is_owned = false;
13219         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13220         memcpy((uint8_t*)(ret_arr + 4), BestBlock_block_hash(&this_arg_conv).data, 32);
13221         return ret_arr;
13222 }
13223
13224 int32_t  __attribute__((visibility("default"))) TS_BestBlock_height(uint32_t this_arg) {
13225         LDKBestBlock this_arg_conv;
13226         this_arg_conv.inner = (void*)(this_arg & (~1));
13227         this_arg_conv.is_owned = false;
13228         int32_t ret_val = BestBlock_height(&this_arg_conv);
13229         return ret_val;
13230 }
13231
13232 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
13233         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
13234         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
13235         return ret_conv;
13236 }
13237
13238 uint32_t  __attribute__((visibility("default"))) TS_AccessError_unknown_chain() {
13239         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
13240         return ret_conv;
13241 }
13242
13243 uint32_t  __attribute__((visibility("default"))) TS_AccessError_unknown_tx() {
13244         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
13245         return ret_conv;
13246 }
13247
13248 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
13249         if ((this_ptr & 1) != 0) return;
13250         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
13251         FREE((void*)this_ptr);
13252         Access_free(this_ptr_conv);
13253 }
13254
13255 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
13256         if ((this_ptr & 1) != 0) return;
13257         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
13258         FREE((void*)this_ptr);
13259         Listen_free(this_ptr_conv);
13260 }
13261
13262 void  __attribute__((visibility("default"))) TS_Confirm_free(uint32_t this_ptr) {
13263         if ((this_ptr & 1) != 0) return;
13264         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
13265         FREE((void*)this_ptr);
13266         Confirm_free(this_ptr_conv);
13267 }
13268
13269 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
13270         if ((this_ptr & 1) != 0) return;
13271         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
13272         FREE((void*)this_ptr);
13273         Watch_free(this_ptr_conv);
13274 }
13275
13276 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
13277         if ((this_ptr & 1) != 0) return;
13278         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
13279         FREE((void*)this_ptr);
13280         Filter_free(this_ptr_conv);
13281 }
13282
13283 void  __attribute__((visibility("default"))) TS_WatchedOutput_free(uint32_t this_obj) {
13284         LDKWatchedOutput this_obj_conv;
13285         this_obj_conv.inner = (void*)(this_obj & (~1));
13286         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13287         WatchedOutput_free(this_obj_conv);
13288 }
13289
13290 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
13291         LDKWatchedOutput this_ptr_conv;
13292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13293         this_ptr_conv.is_owned = false;
13294         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13295         memcpy((uint8_t*)(ret_arr + 4), WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
13296         return ret_arr;
13297 }
13298
13299 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
13300         LDKWatchedOutput this_ptr_conv;
13301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13302         this_ptr_conv.is_owned = false;
13303         LDKThirtyTwoBytes val_ref;
13304         CHECK(*((uint32_t*)val) == 32);
13305         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13306         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
13307 }
13308
13309 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
13310         LDKWatchedOutput this_ptr_conv;
13311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13312         this_ptr_conv.is_owned = false;
13313         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
13314         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13315         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13316         uint64_t ret_ref = (uint64_t)ret_var.inner;
13317         if (ret_var.is_owned) {
13318                 ret_ref |= 1;
13319         }
13320         return ret_ref;
13321 }
13322
13323 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
13324         LDKWatchedOutput this_ptr_conv;
13325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13326         this_ptr_conv.is_owned = false;
13327         LDKOutPoint val_conv;
13328         val_conv.inner = (void*)(val & (~1));
13329         val_conv.is_owned = (val & 1) || (val == 0);
13330         val_conv = OutPoint_clone(&val_conv);
13331         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
13332 }
13333
13334 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
13335         LDKWatchedOutput this_ptr_conv;
13336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13337         this_ptr_conv.is_owned = false;
13338         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
13339         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13340         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13341         return ret_arr;
13342 }
13343
13344 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
13345         LDKWatchedOutput this_ptr_conv;
13346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13347         this_ptr_conv.is_owned = false;
13348         LDKCVec_u8Z val_ref;
13349         val_ref.datalen = *((uint32_t*)val);
13350         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
13351         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
13352         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
13353 }
13354
13355 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_new(int8_tArray block_hash_arg, uint32_t outpoint_arg, int8_tArray script_pubkey_arg) {
13356         LDKThirtyTwoBytes block_hash_arg_ref;
13357         CHECK(*((uint32_t*)block_hash_arg) == 32);
13358         memcpy(block_hash_arg_ref.data, (uint8_t*)(block_hash_arg + 4), 32);
13359         LDKOutPoint outpoint_arg_conv;
13360         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
13361         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
13362         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
13363         LDKCVec_u8Z script_pubkey_arg_ref;
13364         script_pubkey_arg_ref.datalen = *((uint32_t*)script_pubkey_arg);
13365         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
13366         memcpy(script_pubkey_arg_ref.data, (uint8_t*)(script_pubkey_arg + 4), script_pubkey_arg_ref.datalen);
13367         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
13368         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13369         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13370         uint64_t ret_ref = (uint64_t)ret_var.inner;
13371         if (ret_var.is_owned) {
13372                 ret_ref |= 1;
13373         }
13374         return ret_ref;
13375 }
13376
13377 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_clone(uint32_t orig) {
13378         LDKWatchedOutput orig_conv;
13379         orig_conv.inner = (void*)(orig & (~1));
13380         orig_conv.is_owned = false;
13381         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
13382         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13383         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13384         uint64_t ret_ref = (uint64_t)ret_var.inner;
13385         if (ret_var.is_owned) {
13386                 ret_ref |= 1;
13387         }
13388         return ret_ref;
13389 }
13390
13391 int64_t  __attribute__((visibility("default"))) TS_WatchedOutput_hash(uint32_t o) {
13392         LDKWatchedOutput o_conv;
13393         o_conv.inner = (void*)(o & (~1));
13394         o_conv.is_owned = false;
13395         int64_t ret_val = WatchedOutput_hash(&o_conv);
13396         return ret_val;
13397 }
13398
13399 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
13400         if ((this_ptr & 1) != 0) return;
13401         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
13402         FREE((void*)this_ptr);
13403         BroadcasterInterface_free(this_ptr_conv);
13404 }
13405
13406 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
13407         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
13408         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
13409         return ret_conv;
13410 }
13411
13412 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_background() {
13413         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
13414         return ret_conv;
13415 }
13416
13417 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_normal() {
13418         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
13419         return ret_conv;
13420 }
13421
13422 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_high_priority() {
13423         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
13424         return ret_conv;
13425 }
13426
13427 jboolean  __attribute__((visibility("default"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
13428         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
13429         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
13430         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
13431         return ret_val;
13432 }
13433
13434 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
13435         if ((this_ptr & 1) != 0) return;
13436         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
13437         FREE((void*)this_ptr);
13438         FeeEstimator_free(this_ptr_conv);
13439 }
13440
13441 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
13442         LDKChainMonitor this_obj_conv;
13443         this_obj_conv.inner = (void*)(this_obj & (~1));
13444         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13445         ChainMonitor_free(this_obj_conv);
13446 }
13447
13448 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
13449         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(((uint64_t)chain_source) & ~1);
13450         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
13451         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
13452                 // Manually implement clone for Java trait instances
13453         }
13454         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13455         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13456         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
13457         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
13458         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
13459         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13460         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13461         uint64_t ret_ref = (uint64_t)ret_var.inner;
13462         if (ret_var.is_owned) {
13463                 ret_ref |= 1;
13464         }
13465         return ret_ref;
13466 }
13467
13468 uint32_tArray  __attribute__((visibility("default"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
13469         LDKChainMonitor this_arg_conv;
13470         this_arg_conv.inner = (void*)(this_arg & (~1));
13471         this_arg_conv.is_owned = false;
13472         LDKCVec_ChannelDetailsZ ignored_channels_constr;
13473         ignored_channels_constr.datalen = *((uint32_t*)ignored_channels);
13474         if (ignored_channels_constr.datalen > 0)
13475                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13476         else
13477                 ignored_channels_constr.data = NULL;
13478         uint32_t* ignored_channels_vals = (uint32_t*)(ignored_channels + 4);
13479         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
13480                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
13481                 LDKChannelDetails ignored_channels_conv_16_conv;
13482                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
13483                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
13484                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
13485                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
13486         }
13487         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
13488         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13489         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13490         for (size_t j = 0; j < ret_var.datalen; j++) {
13491                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
13492                 *ret_conv_9_copy = Balance_clone(&ret_var.data[j]);
13493                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
13494                 ret_arr_ptr[j] = ret_conv_9_ref;
13495         }
13496         FREE(ret_var.data);
13497         return ret_arr;
13498 }
13499
13500 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
13501         LDKChainMonitor this_arg_conv;
13502         this_arg_conv.inner = (void*)(this_arg & (~1));
13503         this_arg_conv.is_owned = false;
13504         LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen");
13505         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
13506         return (uint64_t)ret_ret;
13507 }
13508
13509 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
13510         LDKChainMonitor this_arg_conv;
13511         this_arg_conv.inner = (void*)(this_arg & (~1));
13512         this_arg_conv.is_owned = false;
13513         LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
13514         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
13515         return (uint64_t)ret_ret;
13516 }
13517
13518 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
13519         LDKChainMonitor this_arg_conv;
13520         this_arg_conv.inner = (void*)(this_arg & (~1));
13521         this_arg_conv.is_owned = false;
13522         LDKWatch* ret_ret =MALLOC(sizeof(LDKWatch), "LDKWatch");
13523         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
13524         return (uint64_t)ret_ret;
13525 }
13526
13527 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
13528         LDKChainMonitor this_arg_conv;
13529         this_arg_conv.inner = (void*)(this_arg & (~1));
13530         this_arg_conv.is_owned = false;
13531         LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
13532         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
13533         return (uint64_t)ret_ret;
13534 }
13535
13536 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
13537         LDKChannelMonitorUpdate this_obj_conv;
13538         this_obj_conv.inner = (void*)(this_obj & (~1));
13539         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13540         ChannelMonitorUpdate_free(this_obj_conv);
13541 }
13542
13543 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
13544         LDKChannelMonitorUpdate this_ptr_conv;
13545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13546         this_ptr_conv.is_owned = false;
13547         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
13548         return ret_val;
13549 }
13550
13551 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
13552         LDKChannelMonitorUpdate this_ptr_conv;
13553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13554         this_ptr_conv.is_owned = false;
13555         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
13556 }
13557
13558 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
13559         LDKChannelMonitorUpdate orig_conv;
13560         orig_conv.inner = (void*)(orig & (~1));
13561         orig_conv.is_owned = false;
13562         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
13563         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13564         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13565         uint64_t ret_ref = (uint64_t)ret_var.inner;
13566         if (ret_var.is_owned) {
13567                 ret_ref |= 1;
13568         }
13569         return ret_ref;
13570 }
13571
13572 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
13573         LDKChannelMonitorUpdate obj_conv;
13574         obj_conv.inner = (void*)(obj & (~1));
13575         obj_conv.is_owned = false;
13576         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
13577         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13578         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13579         CVec_u8Z_free(ret_var);
13580         return ret_arr;
13581 }
13582
13583 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
13584         LDKu8slice ser_ref;
13585         ser_ref.datalen = *((uint32_t*)ser);
13586         ser_ref.data = (int8_t*)(ser + 4);
13587         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
13588         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
13589         return (uint64_t)ret_conv;
13590 }
13591
13592 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
13593         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
13594         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
13595         return ret_conv;
13596 }
13597
13598 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
13599         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
13600         return ret_conv;
13601 }
13602
13603 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
13604         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
13605         return ret_conv;
13606 }
13607
13608 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_obj) {
13609         LDKMonitorUpdateError this_obj_conv;
13610         this_obj_conv.inner = (void*)(this_obj & (~1));
13611         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13612         MonitorUpdateError_free(this_obj_conv);
13613 }
13614
13615 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
13616         LDKMonitorUpdateError orig_conv;
13617         orig_conv.inner = (void*)(orig & (~1));
13618         orig_conv.is_owned = false;
13619         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
13620         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13621         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13622         uint64_t ret_ref = (uint64_t)ret_var.inner;
13623         if (ret_var.is_owned) {
13624                 ret_ref |= 1;
13625         }
13626         return ret_ref;
13627 }
13628
13629 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
13630         if ((this_ptr & 1) != 0) return;
13631         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
13632         FREE((void*)this_ptr);
13633         MonitorEvent_free(this_ptr_conv);
13634 }
13635
13636 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
13637         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
13638         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
13639         *ret_copy = MonitorEvent_clone(orig_conv);
13640         uint64_t ret_ref = (uint64_t)ret_copy;
13641         return ret_ref;
13642 }
13643
13644 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_htlcevent(uint32_t a) {
13645         LDKHTLCUpdate a_conv;
13646         a_conv.inner = (void*)(a & (~1));
13647         a_conv.is_owned = (a & 1) || (a == 0);
13648         a_conv = HTLCUpdate_clone(&a_conv);
13649         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
13650         *ret_copy = MonitorEvent_htlcevent(a_conv);
13651         uint64_t ret_ref = (uint64_t)ret_copy;
13652         return ret_ref;
13653 }
13654
13655 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
13656         LDKOutPoint a_conv;
13657         a_conv.inner = (void*)(a & (~1));
13658         a_conv.is_owned = (a & 1) || (a == 0);
13659         a_conv = OutPoint_clone(&a_conv);
13660         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
13661         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
13662         uint64_t ret_ref = (uint64_t)ret_copy;
13663         return ret_ref;
13664 }
13665
13666 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_obj) {
13667         LDKHTLCUpdate this_obj_conv;
13668         this_obj_conv.inner = (void*)(this_obj & (~1));
13669         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13670         HTLCUpdate_free(this_obj_conv);
13671 }
13672
13673 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
13674         LDKHTLCUpdate orig_conv;
13675         orig_conv.inner = (void*)(orig & (~1));
13676         orig_conv.is_owned = false;
13677         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
13678         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13679         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13680         uint64_t ret_ref = (uint64_t)ret_var.inner;
13681         if (ret_var.is_owned) {
13682                 ret_ref |= 1;
13683         }
13684         return ret_ref;
13685 }
13686
13687 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
13688         LDKHTLCUpdate obj_conv;
13689         obj_conv.inner = (void*)(obj & (~1));
13690         obj_conv.is_owned = false;
13691         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
13692         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13693         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13694         CVec_u8Z_free(ret_var);
13695         return ret_arr;
13696 }
13697
13698 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
13699         LDKu8slice ser_ref;
13700         ser_ref.datalen = *((uint32_t*)ser);
13701         ser_ref.data = (int8_t*)(ser + 4);
13702         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
13703         *ret_conv = HTLCUpdate_read(ser_ref);
13704         return (uint64_t)ret_conv;
13705 }
13706
13707 void  __attribute__((visibility("default"))) TS_Balance_free(uint32_t this_ptr) {
13708         if ((this_ptr & 1) != 0) return;
13709         LDKBalance this_ptr_conv = *(LDKBalance*)(((uint64_t)this_ptr) & ~1);
13710         FREE((void*)this_ptr);
13711         Balance_free(this_ptr_conv);
13712 }
13713
13714 uint32_t  __attribute__((visibility("default"))) TS_Balance_clone(uint32_t orig) {
13715         LDKBalance* orig_conv = (LDKBalance*)orig;
13716         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
13717         *ret_copy = Balance_clone(orig_conv);
13718         uint64_t ret_ref = (uint64_t)ret_copy;
13719         return ret_ref;
13720 }
13721
13722 uint32_t  __attribute__((visibility("default"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
13723         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
13724         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
13725         uint64_t ret_ref = (uint64_t)ret_copy;
13726         return ret_ref;
13727 }
13728
13729 uint32_t  __attribute__((visibility("default"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
13730         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
13731         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
13732         uint64_t ret_ref = (uint64_t)ret_copy;
13733         return ret_ref;
13734 }
13735
13736 uint32_t  __attribute__((visibility("default"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
13737         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
13738         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
13739         uint64_t ret_ref = (uint64_t)ret_copy;
13740         return ret_ref;
13741 }
13742
13743 uint32_t  __attribute__((visibility("default"))) TS_Balance_maybe_claimable_htlcawaiting_timeout(int64_t claimable_amount_satoshis, int32_t claimable_height) {
13744         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
13745         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
13746         uint64_t ret_ref = (uint64_t)ret_copy;
13747         return ret_ref;
13748 }
13749
13750 jboolean  __attribute__((visibility("default"))) TS_Balance_eq(uint32_t a, uint32_t b) {
13751         LDKBalance* a_conv = (LDKBalance*)a;
13752         LDKBalance* b_conv = (LDKBalance*)b;
13753         jboolean ret_val = Balance_eq(a_conv, b_conv);
13754         return ret_val;
13755 }
13756
13757 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) {
13758         LDKChannelMonitor this_obj_conv;
13759         this_obj_conv.inner = (void*)(this_obj & (~1));
13760         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13761         ChannelMonitor_free(this_obj_conv);
13762 }
13763
13764 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_t orig) {
13765         LDKChannelMonitor orig_conv;
13766         orig_conv.inner = (void*)(orig & (~1));
13767         orig_conv.is_owned = false;
13768         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
13769         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13770         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13771         uint64_t ret_ref = (uint64_t)ret_var.inner;
13772         if (ret_var.is_owned) {
13773                 ret_ref |= 1;
13774         }
13775         return ret_ref;
13776 }
13777
13778 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
13779         LDKChannelMonitor obj_conv;
13780         obj_conv.inner = (void*)(obj & (~1));
13781         obj_conv.is_owned = false;
13782         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
13783         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13784         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
13785         CVec_u8Z_free(ret_var);
13786         return ret_arr;
13787 }
13788
13789 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) {
13790         LDKChannelMonitor this_arg_conv;
13791         this_arg_conv.inner = (void*)(this_arg & (~1));
13792         this_arg_conv.is_owned = false;
13793         LDKChannelMonitorUpdate updates_conv;
13794         updates_conv.inner = (void*)(updates & (~1));
13795         updates_conv.is_owned = false;
13796         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13797         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13798         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
13799         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
13800         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
13801         return (uint64_t)ret_conv;
13802 }
13803
13804 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
13805         LDKChannelMonitor this_arg_conv;
13806         this_arg_conv.inner = (void*)(this_arg & (~1));
13807         this_arg_conv.is_owned = false;
13808         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
13809         return ret_val;
13810 }
13811
13812 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
13813         LDKChannelMonitor this_arg_conv;
13814         this_arg_conv.inner = (void*)(this_arg & (~1));
13815         this_arg_conv.is_owned = false;
13816         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
13817         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
13818         return ((uint64_t)ret_conv);
13819 }
13820
13821 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
13822         LDKChannelMonitor this_arg_conv;
13823         this_arg_conv.inner = (void*)(this_arg & (~1));
13824         this_arg_conv.is_owned = false;
13825         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
13826         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13827         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13828         for (size_t o = 0; o < ret_var.datalen; o++) {
13829                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
13830                 *ret_conv_40_conv = ret_var.data[o];
13831                 ret_arr_ptr[o] = ((uint64_t)ret_conv_40_conv);
13832         }
13833         FREE(ret_var.data);
13834         return ret_arr;
13835 }
13836
13837 void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
13838         LDKChannelMonitor this_arg_conv;
13839         this_arg_conv.inner = (void*)(this_arg & (~1));
13840         this_arg_conv.is_owned = false;
13841         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
13842         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
13843 }
13844
13845 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
13846         LDKChannelMonitor this_arg_conv;
13847         this_arg_conv.inner = (void*)(this_arg & (~1));
13848         this_arg_conv.is_owned = false;
13849         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
13850         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13851         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13852         for (size_t o = 0; o < ret_var.datalen; o++) {
13853                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
13854                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
13855                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
13856                 ret_arr_ptr[o] = ret_conv_14_ref;
13857         }
13858         FREE(ret_var.data);
13859         return ret_arr;
13860 }
13861
13862 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
13863         LDKChannelMonitor this_arg_conv;
13864         this_arg_conv.inner = (void*)(this_arg & (~1));
13865         this_arg_conv.is_owned = false;
13866         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
13867         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13868         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13869         for (size_t h = 0; h < ret_var.datalen; h++) {
13870                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13871                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
13872                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
13873                 ret_arr_ptr[h] = ret_conv_7_ref;
13874         }
13875         FREE(ret_var.data);
13876         return ret_arr;
13877 }
13878
13879 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
13880         LDKChannelMonitor this_arg_conv;
13881         this_arg_conv.inner = (void*)(this_arg & (~1));
13882         this_arg_conv.is_owned = false;
13883         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
13884         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
13885         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
13886         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
13887         for (size_t m = 0; m < ret_var.datalen; m++) {
13888                 LDKTransaction ret_conv_12_var = ret_var.data[m];
13889                 int8_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13890                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_conv_12_var.data, ret_conv_12_var.datalen);
13891                 Transaction_free(ret_conv_12_var);
13892                 ret_arr_ptr[m] = ret_conv_12_arr;
13893         }
13894         FREE(ret_var.data);
13895         return ret_arr;
13896 }
13897
13898 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) {
13899         LDKChannelMonitor this_arg_conv;
13900         this_arg_conv.inner = (void*)(this_arg & (~1));
13901         this_arg_conv.is_owned = false;
13902         unsigned char header_arr[80];
13903         CHECK(*((uint32_t*)header) == 80);
13904         memcpy(header_arr, (uint8_t*)(header + 4), 80);
13905         unsigned char (*header_ref)[80] = &header_arr;
13906         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
13907         txdata_constr.datalen = *((uint32_t*)txdata);
13908         if (txdata_constr.datalen > 0)
13909                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
13910         else
13911                 txdata_constr.data = NULL;
13912         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
13913         for (size_t c = 0; c < txdata_constr.datalen; c++) {
13914                 uint32_t txdata_conv_28 = txdata_vals[c];
13915                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
13916                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
13917                 txdata_constr.data[c] = txdata_conv_28_conv;
13918         }
13919         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13920         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13921         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13922         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);
13923         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13924         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13925         for (size_t n = 0; n < ret_var.datalen; n++) {
13926                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
13927                 *ret_conv_39_conv = ret_var.data[n];
13928                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
13929         }
13930         FREE(ret_var.data);
13931         return ret_arr;
13932 }
13933
13934 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) {
13935         LDKChannelMonitor this_arg_conv;
13936         this_arg_conv.inner = (void*)(this_arg & (~1));
13937         this_arg_conv.is_owned = false;
13938         unsigned char header_arr[80];
13939         CHECK(*((uint32_t*)header) == 80);
13940         memcpy(header_arr, (uint8_t*)(header + 4), 80);
13941         unsigned char (*header_ref)[80] = &header_arr;
13942         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13943         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13944         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13945         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
13946 }
13947
13948 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) {
13949         LDKChannelMonitor this_arg_conv;
13950         this_arg_conv.inner = (void*)(this_arg & (~1));
13951         this_arg_conv.is_owned = false;
13952         unsigned char header_arr[80];
13953         CHECK(*((uint32_t*)header) == 80);
13954         memcpy(header_arr, (uint8_t*)(header + 4), 80);
13955         unsigned char (*header_ref)[80] = &header_arr;
13956         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
13957         txdata_constr.datalen = *((uint32_t*)txdata);
13958         if (txdata_constr.datalen > 0)
13959                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
13960         else
13961                 txdata_constr.data = NULL;
13962         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
13963         for (size_t c = 0; c < txdata_constr.datalen; c++) {
13964                 uint32_t txdata_conv_28 = txdata_vals[c];
13965                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1);
13966                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
13967                 txdata_constr.data[c] = txdata_conv_28_conv;
13968         }
13969         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13970         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13971         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13972         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);
13973         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
13974         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
13975         for (size_t n = 0; n < ret_var.datalen; n++) {
13976                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
13977                 *ret_conv_39_conv = ret_var.data[n];
13978                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
13979         }
13980         FREE(ret_var.data);
13981         return ret_arr;
13982 }
13983
13984 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) {
13985         LDKChannelMonitor this_arg_conv;
13986         this_arg_conv.inner = (void*)(this_arg & (~1));
13987         this_arg_conv.is_owned = false;
13988         unsigned char txid_arr[32];
13989         CHECK(*((uint32_t*)txid) == 32);
13990         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
13991         unsigned char (*txid_ref)[32] = &txid_arr;
13992         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
13993         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
13994         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
13995         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
13996 }
13997
13998 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) {
13999         LDKChannelMonitor this_arg_conv;
14000         this_arg_conv.inner = (void*)(this_arg & (~1));
14001         this_arg_conv.is_owned = false;
14002         unsigned char header_arr[80];
14003         CHECK(*((uint32_t*)header) == 80);
14004         memcpy(header_arr, (uint8_t*)(header + 4), 80);
14005         unsigned char (*header_ref)[80] = &header_arr;
14006         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14007         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14008         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14009         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
14010         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
14011         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
14012         for (size_t n = 0; n < ret_var.datalen; n++) {
14013                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
14014                 *ret_conv_39_conv = ret_var.data[n];
14015                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
14016         }
14017         FREE(ret_var.data);
14018         return ret_arr;
14019 }
14020
14021 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
14022         LDKChannelMonitor this_arg_conv;
14023         this_arg_conv.inner = (void*)(this_arg & (~1));
14024         this_arg_conv.is_owned = false;
14025         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
14026         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
14027         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
14028         for (size_t m = 0; m < ret_var.datalen; m++) {
14029                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14030                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
14031                 ret_arr_ptr[m] = ret_conv_12_arr;
14032         }
14033         FREE(ret_var.data);
14034         return ret_arr;
14035 }
14036
14037 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
14038         LDKChannelMonitor this_arg_conv;
14039         this_arg_conv.inner = (void*)(this_arg & (~1));
14040         this_arg_conv.is_owned = false;
14041         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
14042         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14043         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14044         uint64_t ret_ref = (uint64_t)ret_var.inner;
14045         if (ret_var.is_owned) {
14046                 ret_ref |= 1;
14047         }
14048         return ret_ref;
14049 }
14050
14051 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
14052         LDKChannelMonitor this_arg_conv;
14053         this_arg_conv.inner = (void*)(this_arg & (~1));
14054         this_arg_conv.is_owned = false;
14055         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
14056         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
14057         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
14058         for (size_t j = 0; j < ret_var.datalen; j++) {
14059                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
14060                 *ret_conv_9_copy = Balance_clone(&ret_var.data[j]);
14061                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
14062                 ret_arr_ptr[j] = ret_conv_9_ref;
14063         }
14064         FREE(ret_var.data);
14065         return ret_arr;
14066 }
14067
14068 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
14069         if ((this_ptr & 1) != 0) return;
14070         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
14071         FREE((void*)this_ptr);
14072         Persist_free(this_ptr_conv);
14073 }
14074
14075 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
14076         LDKu8slice ser_ref;
14077         ser_ref.datalen = *((uint32_t*)ser);
14078         ser_ref.data = (int8_t*)(ser + 4);
14079         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
14080         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
14081         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
14082         return (uint64_t)ret_conv;
14083 }
14084
14085 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_obj) {
14086         LDKOutPoint this_obj_conv;
14087         this_obj_conv.inner = (void*)(this_obj & (~1));
14088         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14089         OutPoint_free(this_obj_conv);
14090 }
14091
14092 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
14093         LDKOutPoint this_ptr_conv;
14094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14095         this_ptr_conv.is_owned = false;
14096         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14097         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
14098         return ret_arr;
14099 }
14100
14101 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
14102         LDKOutPoint this_ptr_conv;
14103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14104         this_ptr_conv.is_owned = false;
14105         LDKThirtyTwoBytes val_ref;
14106         CHECK(*((uint32_t*)val) == 32);
14107         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14108         OutPoint_set_txid(&this_ptr_conv, val_ref);
14109 }
14110
14111 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
14112         LDKOutPoint this_ptr_conv;
14113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14114         this_ptr_conv.is_owned = false;
14115         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
14116         return ret_val;
14117 }
14118
14119 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
14120         LDKOutPoint this_ptr_conv;
14121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14122         this_ptr_conv.is_owned = false;
14123         OutPoint_set_index(&this_ptr_conv, val);
14124 }
14125
14126 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
14127         LDKThirtyTwoBytes txid_arg_ref;
14128         CHECK(*((uint32_t*)txid_arg) == 32);
14129         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
14130         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
14131         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14132         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14133         uint64_t ret_ref = (uint64_t)ret_var.inner;
14134         if (ret_var.is_owned) {
14135                 ret_ref |= 1;
14136         }
14137         return ret_ref;
14138 }
14139
14140 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
14141         LDKOutPoint orig_conv;
14142         orig_conv.inner = (void*)(orig & (~1));
14143         orig_conv.is_owned = false;
14144         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
14145         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14146         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14147         uint64_t ret_ref = (uint64_t)ret_var.inner;
14148         if (ret_var.is_owned) {
14149                 ret_ref |= 1;
14150         }
14151         return ret_ref;
14152 }
14153
14154 jboolean  __attribute__((visibility("default"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
14155         LDKOutPoint a_conv;
14156         a_conv.inner = (void*)(a & (~1));
14157         a_conv.is_owned = false;
14158         LDKOutPoint b_conv;
14159         b_conv.inner = (void*)(b & (~1));
14160         b_conv.is_owned = false;
14161         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
14162         return ret_val;
14163 }
14164
14165 int64_t  __attribute__((visibility("default"))) TS_OutPoint_hash(uint32_t o) {
14166         LDKOutPoint o_conv;
14167         o_conv.inner = (void*)(o & (~1));
14168         o_conv.is_owned = false;
14169         int64_t ret_val = OutPoint_hash(&o_conv);
14170         return ret_val;
14171 }
14172
14173 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
14174         LDKOutPoint this_arg_conv;
14175         this_arg_conv.inner = (void*)(this_arg & (~1));
14176         this_arg_conv.is_owned = false;
14177         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14178         memcpy((uint8_t*)(ret_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
14179         return ret_arr;
14180 }
14181
14182 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
14183         LDKOutPoint obj_conv;
14184         obj_conv.inner = (void*)(obj & (~1));
14185         obj_conv.is_owned = false;
14186         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
14187         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14188         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14189         CVec_u8Z_free(ret_var);
14190         return ret_arr;
14191 }
14192
14193 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
14194         LDKu8slice ser_ref;
14195         ser_ref.datalen = *((uint32_t*)ser);
14196         ser_ref.data = (int8_t*)(ser + 4);
14197         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14198         *ret_conv = OutPoint_read(ser_ref);
14199         return (uint64_t)ret_conv;
14200 }
14201
14202 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
14203         LDKDelayedPaymentOutputDescriptor this_obj_conv;
14204         this_obj_conv.inner = (void*)(this_obj & (~1));
14205         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14206         DelayedPaymentOutputDescriptor_free(this_obj_conv);
14207 }
14208
14209 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
14210         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14212         this_ptr_conv.is_owned = false;
14213         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
14214         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14215         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14216         uint64_t ret_ref = (uint64_t)ret_var.inner;
14217         if (ret_var.is_owned) {
14218                 ret_ref |= 1;
14219         }
14220         return ret_ref;
14221 }
14222
14223 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
14224         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14226         this_ptr_conv.is_owned = false;
14227         LDKOutPoint val_conv;
14228         val_conv.inner = (void*)(val & (~1));
14229         val_conv.is_owned = (val & 1) || (val == 0);
14230         val_conv = OutPoint_clone(&val_conv);
14231         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
14232 }
14233
14234 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
14235         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14237         this_ptr_conv.is_owned = false;
14238         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14239         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
14240         return ret_arr;
14241 }
14242
14243 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
14244         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14246         this_ptr_conv.is_owned = false;
14247         LDKPublicKey val_ref;
14248         CHECK(*((uint32_t*)val) == 33);
14249         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14250         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
14251 }
14252
14253 int16_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
14254         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14256         this_ptr_conv.is_owned = false;
14257         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
14258         return ret_val;
14259 }
14260
14261 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
14262         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14264         this_ptr_conv.is_owned = false;
14265         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
14266 }
14267
14268 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
14269         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14271         this_ptr_conv.is_owned = false;
14272         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
14273         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
14274         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
14275 }
14276
14277 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
14278         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14280         this_ptr_conv.is_owned = false;
14281         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14282         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
14283         return ret_arr;
14284 }
14285
14286 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
14287         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14289         this_ptr_conv.is_owned = false;
14290         LDKPublicKey val_ref;
14291         CHECK(*((uint32_t*)val) == 33);
14292         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14293         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
14294 }
14295
14296 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
14297         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14299         this_ptr_conv.is_owned = false;
14300         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14301         memcpy((uint8_t*)(ret_arr + 4), *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
14302         return ret_arr;
14303 }
14304
14305 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
14306         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14308         this_ptr_conv.is_owned = false;
14309         LDKThirtyTwoBytes val_ref;
14310         CHECK(*((uint32_t*)val) == 32);
14311         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14312         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
14313 }
14314
14315 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
14316         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14318         this_ptr_conv.is_owned = false;
14319         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
14320         return ret_val;
14321 }
14322
14323 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
14324         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
14325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14326         this_ptr_conv.is_owned = false;
14327         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
14328 }
14329
14330 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) {
14331         LDKOutPoint outpoint_arg_conv;
14332         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14333         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14334         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14335         LDKPublicKey per_commitment_point_arg_ref;
14336         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
14337         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
14338         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
14339         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
14340         LDKPublicKey revocation_pubkey_arg_ref;
14341         CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
14342         memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33);
14343         LDKThirtyTwoBytes channel_keys_id_arg_ref;
14344         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
14345         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
14346         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);
14347         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14348         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14349         uint64_t ret_ref = (uint64_t)ret_var.inner;
14350         if (ret_var.is_owned) {
14351                 ret_ref |= 1;
14352         }
14353         return ret_ref;
14354 }
14355
14356 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
14357         LDKDelayedPaymentOutputDescriptor orig_conv;
14358         orig_conv.inner = (void*)(orig & (~1));
14359         orig_conv.is_owned = false;
14360         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
14361         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14362         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14363         uint64_t ret_ref = (uint64_t)ret_var.inner;
14364         if (ret_var.is_owned) {
14365                 ret_ref |= 1;
14366         }
14367         return ret_ref;
14368 }
14369
14370 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
14371         LDKDelayedPaymentOutputDescriptor obj_conv;
14372         obj_conv.inner = (void*)(obj & (~1));
14373         obj_conv.is_owned = false;
14374         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
14375         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14376         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14377         CVec_u8Z_free(ret_var);
14378         return ret_arr;
14379 }
14380
14381 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
14382         LDKu8slice ser_ref;
14383         ser_ref.datalen = *((uint32_t*)ser);
14384         ser_ref.data = (int8_t*)(ser + 4);
14385         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14386         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
14387         return (uint64_t)ret_conv;
14388 }
14389
14390 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
14391         LDKStaticPaymentOutputDescriptor this_obj_conv;
14392         this_obj_conv.inner = (void*)(this_obj & (~1));
14393         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14394         StaticPaymentOutputDescriptor_free(this_obj_conv);
14395 }
14396
14397 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
14398         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14400         this_ptr_conv.is_owned = false;
14401         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
14402         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14403         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14404         uint64_t ret_ref = (uint64_t)ret_var.inner;
14405         if (ret_var.is_owned) {
14406                 ret_ref |= 1;
14407         }
14408         return ret_ref;
14409 }
14410
14411 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
14412         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14414         this_ptr_conv.is_owned = false;
14415         LDKOutPoint val_conv;
14416         val_conv.inner = (void*)(val & (~1));
14417         val_conv.is_owned = (val & 1) || (val == 0);
14418         val_conv = OutPoint_clone(&val_conv);
14419         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
14420 }
14421
14422 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
14423         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14425         this_ptr_conv.is_owned = false;
14426         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
14427         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
14428         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
14429 }
14430
14431 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
14432         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14434         this_ptr_conv.is_owned = false;
14435         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14436         memcpy((uint8_t*)(ret_arr + 4), *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
14437         return ret_arr;
14438 }
14439
14440 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
14441         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14443         this_ptr_conv.is_owned = false;
14444         LDKThirtyTwoBytes val_ref;
14445         CHECK(*((uint32_t*)val) == 32);
14446         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14447         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
14448 }
14449
14450 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
14451         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14453         this_ptr_conv.is_owned = false;
14454         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
14455         return ret_val;
14456 }
14457
14458 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
14459         LDKStaticPaymentOutputDescriptor this_ptr_conv;
14460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14461         this_ptr_conv.is_owned = false;
14462         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
14463 }
14464
14465 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) {
14466         LDKOutPoint outpoint_arg_conv;
14467         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14468         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14469         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14470         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
14471         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
14472         LDKThirtyTwoBytes channel_keys_id_arg_ref;
14473         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
14474         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
14475         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
14476         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14477         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14478         uint64_t ret_ref = (uint64_t)ret_var.inner;
14479         if (ret_var.is_owned) {
14480                 ret_ref |= 1;
14481         }
14482         return ret_ref;
14483 }
14484
14485 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
14486         LDKStaticPaymentOutputDescriptor orig_conv;
14487         orig_conv.inner = (void*)(orig & (~1));
14488         orig_conv.is_owned = false;
14489         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
14490         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14491         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14492         uint64_t ret_ref = (uint64_t)ret_var.inner;
14493         if (ret_var.is_owned) {
14494                 ret_ref |= 1;
14495         }
14496         return ret_ref;
14497 }
14498
14499 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
14500         LDKStaticPaymentOutputDescriptor obj_conv;
14501         obj_conv.inner = (void*)(obj & (~1));
14502         obj_conv.is_owned = false;
14503         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
14504         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14505         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14506         CVec_u8Z_free(ret_var);
14507         return ret_arr;
14508 }
14509
14510 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
14511         LDKu8slice ser_ref;
14512         ser_ref.datalen = *((uint32_t*)ser);
14513         ser_ref.data = (int8_t*)(ser + 4);
14514         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14515         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
14516         return (uint64_t)ret_conv;
14517 }
14518
14519 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
14520         if ((this_ptr & 1) != 0) return;
14521         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
14522         FREE((void*)this_ptr);
14523         SpendableOutputDescriptor_free(this_ptr_conv);
14524 }
14525
14526 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
14527         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
14528         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
14529         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
14530         uint64_t ret_ref = (uint64_t)ret_copy;
14531         return ret_ref;
14532 }
14533
14534 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
14535         LDKOutPoint outpoint_conv;
14536         outpoint_conv.inner = (void*)(outpoint & (~1));
14537         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
14538         outpoint_conv = OutPoint_clone(&outpoint_conv);
14539         LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1);
14540         output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1));
14541         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
14542         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
14543         uint64_t ret_ref = (uint64_t)ret_copy;
14544         return ret_ref;
14545 }
14546
14547 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
14548         LDKDelayedPaymentOutputDescriptor a_conv;
14549         a_conv.inner = (void*)(a & (~1));
14550         a_conv.is_owned = (a & 1) || (a == 0);
14551         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
14552         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
14553         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
14554         uint64_t ret_ref = (uint64_t)ret_copy;
14555         return ret_ref;
14556 }
14557
14558 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
14559         LDKStaticPaymentOutputDescriptor a_conv;
14560         a_conv.inner = (void*)(a & (~1));
14561         a_conv.is_owned = (a & 1) || (a == 0);
14562         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
14563         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
14564         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
14565         uint64_t ret_ref = (uint64_t)ret_copy;
14566         return ret_ref;
14567 }
14568
14569 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
14570         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
14571         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
14572         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14573         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14574         CVec_u8Z_free(ret_var);
14575         return ret_arr;
14576 }
14577
14578 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
14579         LDKu8slice ser_ref;
14580         ser_ref.datalen = *((uint32_t*)ser);
14581         ser_ref.data = (int8_t*)(ser + 4);
14582         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14583         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
14584         return (uint64_t)ret_conv;
14585 }
14586
14587 void  __attribute__((visibility("default"))) TS_BaseSign_free(uint32_t this_ptr) {
14588         if ((this_ptr & 1) != 0) return;
14589         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
14590         FREE((void*)this_ptr);
14591         BaseSign_free(this_ptr_conv);
14592 }
14593
14594 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
14595         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
14596         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
14597         *ret_ret = Sign_clone(orig_conv);
14598         return (uint64_t)ret_ret;
14599 }
14600
14601 void  __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) {
14602         if ((this_ptr & 1) != 0) return;
14603         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
14604         FREE((void*)this_ptr);
14605         Sign_free(this_ptr_conv);
14606 }
14607
14608 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
14609         if ((this_ptr & 1) != 0) return;
14610         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
14611         FREE((void*)this_ptr);
14612         KeysInterface_free(this_ptr_conv);
14613 }
14614
14615 void  __attribute__((visibility("default"))) TS_InMemorySigner_free(uint32_t this_obj) {
14616         LDKInMemorySigner this_obj_conv;
14617         this_obj_conv.inner = (void*)(this_obj & (~1));
14618         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14619         InMemorySigner_free(this_obj_conv);
14620 }
14621
14622 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
14623         LDKInMemorySigner this_ptr_conv;
14624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14625         this_ptr_conv.is_owned = false;
14626         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14627         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
14628         return ret_arr;
14629 }
14630
14631 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
14632         LDKInMemorySigner this_ptr_conv;
14633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14634         this_ptr_conv.is_owned = false;
14635         LDKSecretKey val_ref;
14636         CHECK(*((uint32_t*)val) == 32);
14637         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
14638         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
14639 }
14640
14641 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
14642         LDKInMemorySigner this_ptr_conv;
14643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14644         this_ptr_conv.is_owned = false;
14645         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14646         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
14647         return ret_arr;
14648 }
14649
14650 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
14651         LDKInMemorySigner this_ptr_conv;
14652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14653         this_ptr_conv.is_owned = false;
14654         LDKSecretKey val_ref;
14655         CHECK(*((uint32_t*)val) == 32);
14656         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
14657         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
14658 }
14659
14660 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
14661         LDKInMemorySigner this_ptr_conv;
14662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14663         this_ptr_conv.is_owned = false;
14664         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14665         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
14666         return ret_arr;
14667 }
14668
14669 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
14670         LDKInMemorySigner this_ptr_conv;
14671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14672         this_ptr_conv.is_owned = false;
14673         LDKSecretKey val_ref;
14674         CHECK(*((uint32_t*)val) == 32);
14675         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
14676         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
14677 }
14678
14679 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
14680         LDKInMemorySigner this_ptr_conv;
14681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14682         this_ptr_conv.is_owned = false;
14683         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14684         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
14685         return ret_arr;
14686 }
14687
14688 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
14689         LDKInMemorySigner this_ptr_conv;
14690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14691         this_ptr_conv.is_owned = false;
14692         LDKSecretKey val_ref;
14693         CHECK(*((uint32_t*)val) == 32);
14694         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
14695         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
14696 }
14697
14698 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
14699         LDKInMemorySigner this_ptr_conv;
14700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14701         this_ptr_conv.is_owned = false;
14702         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14703         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
14704         return ret_arr;
14705 }
14706
14707 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
14708         LDKInMemorySigner this_ptr_conv;
14709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14710         this_ptr_conv.is_owned = false;
14711         LDKSecretKey val_ref;
14712         CHECK(*((uint32_t*)val) == 32);
14713         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
14714         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
14715 }
14716
14717 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
14718         LDKInMemorySigner this_ptr_conv;
14719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14720         this_ptr_conv.is_owned = false;
14721         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14722         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
14723         return ret_arr;
14724 }
14725
14726 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
14727         LDKInMemorySigner this_ptr_conv;
14728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14729         this_ptr_conv.is_owned = false;
14730         LDKThirtyTwoBytes val_ref;
14731         CHECK(*((uint32_t*)val) == 32);
14732         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14733         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
14734 }
14735
14736 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_t orig) {
14737         LDKInMemorySigner orig_conv;
14738         orig_conv.inner = (void*)(orig & (~1));
14739         orig_conv.is_owned = false;
14740         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
14741         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14742         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14743         uint64_t ret_ref = (uint64_t)ret_var.inner;
14744         if (ret_var.is_owned) {
14745                 ret_ref |= 1;
14746         }
14747         return ret_ref;
14748 }
14749
14750 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) {
14751         LDKSecretKey funding_key_ref;
14752         CHECK(*((uint32_t*)funding_key) == 32);
14753         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
14754         LDKSecretKey revocation_base_key_ref;
14755         CHECK(*((uint32_t*)revocation_base_key) == 32);
14756         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
14757         LDKSecretKey payment_key_ref;
14758         CHECK(*((uint32_t*)payment_key) == 32);
14759         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
14760         LDKSecretKey delayed_payment_base_key_ref;
14761         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
14762         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
14763         LDKSecretKey htlc_base_key_ref;
14764         CHECK(*((uint32_t*)htlc_base_key) == 32);
14765         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
14766         LDKThirtyTwoBytes commitment_seed_ref;
14767         CHECK(*((uint32_t*)commitment_seed) == 32);
14768         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
14769         LDKThirtyTwoBytes channel_keys_id_ref;
14770         CHECK(*((uint32_t*)channel_keys_id) == 32);
14771         memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
14772         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);
14773         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14774         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14775         uint64_t ret_ref = (uint64_t)ret_var.inner;
14776         if (ret_var.is_owned) {
14777                 ret_ref |= 1;
14778         }
14779         return ret_ref;
14780 }
14781
14782 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
14783         LDKInMemorySigner this_arg_conv;
14784         this_arg_conv.inner = (void*)(this_arg & (~1));
14785         this_arg_conv.is_owned = false;
14786         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
14787         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14788         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14789         uint64_t ret_ref = (uint64_t)ret_var.inner;
14790         if (ret_var.is_owned) {
14791                 ret_ref |= 1;
14792         }
14793         return ret_ref;
14794 }
14795
14796 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
14797         LDKInMemorySigner this_arg_conv;
14798         this_arg_conv.inner = (void*)(this_arg & (~1));
14799         this_arg_conv.is_owned = false;
14800         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
14801         return ret_val;
14802 }
14803
14804 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
14805         LDKInMemorySigner this_arg_conv;
14806         this_arg_conv.inner = (void*)(this_arg & (~1));
14807         this_arg_conv.is_owned = false;
14808         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
14809         return ret_val;
14810 }
14811
14812 jboolean  __attribute__((visibility("default"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
14813         LDKInMemorySigner this_arg_conv;
14814         this_arg_conv.inner = (void*)(this_arg & (~1));
14815         this_arg_conv.is_owned = false;
14816         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
14817         return ret_val;
14818 }
14819
14820 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
14821         LDKInMemorySigner this_arg_conv;
14822         this_arg_conv.inner = (void*)(this_arg & (~1));
14823         this_arg_conv.is_owned = false;
14824         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
14825         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14826         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14827         uint64_t ret_ref = (uint64_t)ret_var.inner;
14828         if (ret_var.is_owned) {
14829                 ret_ref |= 1;
14830         }
14831         return ret_ref;
14832 }
14833
14834 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
14835         LDKInMemorySigner this_arg_conv;
14836         this_arg_conv.inner = (void*)(this_arg & (~1));
14837         this_arg_conv.is_owned = false;
14838         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
14839         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14840         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14841         uint64_t ret_ref = (uint64_t)ret_var.inner;
14842         if (ret_var.is_owned) {
14843                 ret_ref |= 1;
14844         }
14845         return ret_ref;
14846 }
14847
14848 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) {
14849         LDKInMemorySigner this_arg_conv;
14850         this_arg_conv.inner = (void*)(this_arg & (~1));
14851         this_arg_conv.is_owned = false;
14852         LDKTransaction spend_tx_ref;
14853         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
14854         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
14855         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
14856         spend_tx_ref.data_is_owned = true;
14857         LDKStaticPaymentOutputDescriptor descriptor_conv;
14858         descriptor_conv.inner = (void*)(descriptor & (~1));
14859         descriptor_conv.is_owned = false;
14860         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
14861         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
14862         return (uint64_t)ret_conv;
14863 }
14864
14865 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) {
14866         LDKInMemorySigner this_arg_conv;
14867         this_arg_conv.inner = (void*)(this_arg & (~1));
14868         this_arg_conv.is_owned = false;
14869         LDKTransaction spend_tx_ref;
14870         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
14871         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
14872         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
14873         spend_tx_ref.data_is_owned = true;
14874         LDKDelayedPaymentOutputDescriptor descriptor_conv;
14875         descriptor_conv.inner = (void*)(descriptor & (~1));
14876         descriptor_conv.is_owned = false;
14877         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
14878         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
14879         return (uint64_t)ret_conv;
14880 }
14881
14882 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
14883         LDKInMemorySigner this_arg_conv;
14884         this_arg_conv.inner = (void*)(this_arg & (~1));
14885         this_arg_conv.is_owned = false;
14886         LDKBaseSign* ret_ret =MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
14887         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
14888         return (uint64_t)ret_ret;
14889 }
14890
14891 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
14892         LDKInMemorySigner this_arg_conv;
14893         this_arg_conv.inner = (void*)(this_arg & (~1));
14894         this_arg_conv.is_owned = false;
14895         LDKSign* ret_ret =MALLOC(sizeof(LDKSign), "LDKSign");
14896         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
14897         return (uint64_t)ret_ret;
14898 }
14899
14900 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) {
14901         LDKInMemorySigner obj_conv;
14902         obj_conv.inner = (void*)(obj & (~1));
14903         obj_conv.is_owned = false;
14904         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
14905         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14906         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
14907         CVec_u8Z_free(ret_var);
14908         return ret_arr;
14909 }
14910
14911 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_read(int8_tArray ser) {
14912         LDKu8slice ser_ref;
14913         ser_ref.datalen = *((uint32_t*)ser);
14914         ser_ref.data = (int8_t*)(ser + 4);
14915         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
14916         *ret_conv = InMemorySigner_read(ser_ref);
14917         return (uint64_t)ret_conv;
14918 }
14919
14920 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_obj) {
14921         LDKKeysManager this_obj_conv;
14922         this_obj_conv.inner = (void*)(this_obj & (~1));
14923         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14924         KeysManager_free(this_obj_conv);
14925 }
14926
14927 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
14928         unsigned char seed_arr[32];
14929         CHECK(*((uint32_t*)seed) == 32);
14930         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
14931         unsigned char (*seed_ref)[32] = &seed_arr;
14932         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
14933         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14934         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14935         uint64_t ret_ref = (uint64_t)ret_var.inner;
14936         if (ret_var.is_owned) {
14937                 ret_ref |= 1;
14938         }
14939         return ret_ref;
14940 }
14941
14942 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
14943         LDKKeysManager this_arg_conv;
14944         this_arg_conv.inner = (void*)(this_arg & (~1));
14945         this_arg_conv.is_owned = false;
14946         unsigned char params_arr[32];
14947         CHECK(*((uint32_t*)params) == 32);
14948         memcpy(params_arr, (uint8_t*)(params + 4), 32);
14949         unsigned char (*params_ref)[32] = &params_arr;
14950         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
14951         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14952         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14953         uint64_t ret_ref = (uint64_t)ret_var.inner;
14954         if (ret_var.is_owned) {
14955                 ret_ref |= 1;
14956         }
14957         return ret_ref;
14958 }
14959
14960 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) {
14961         LDKKeysManager this_arg_conv;
14962         this_arg_conv.inner = (void*)(this_arg & (~1));
14963         this_arg_conv.is_owned = false;
14964         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
14965         descriptors_constr.datalen = *((uint32_t*)descriptors);
14966         if (descriptors_constr.datalen > 0)
14967                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
14968         else
14969                 descriptors_constr.data = NULL;
14970         uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
14971         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
14972                 uint32_t descriptors_conv_27 = descriptors_vals[b];
14973                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
14974                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
14975                 descriptors_constr.data[b] = descriptors_conv_27_conv;
14976         }
14977         LDKCVec_TxOutZ outputs_constr;
14978         outputs_constr.datalen = *((uint32_t*)outputs);
14979         if (outputs_constr.datalen > 0)
14980                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
14981         else
14982                 outputs_constr.data = NULL;
14983         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
14984         for (size_t h = 0; h < outputs_constr.datalen; h++) {
14985                 uint32_t outputs_conv_7 = outputs_vals[h];
14986                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
14987                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
14988                 outputs_constr.data[h] = outputs_conv_7_conv;
14989         }
14990         LDKCVec_u8Z change_destination_script_ref;
14991         change_destination_script_ref.datalen = *((uint32_t*)change_destination_script);
14992         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
14993         memcpy(change_destination_script_ref.data, (uint8_t*)(change_destination_script + 4), change_destination_script_ref.datalen);
14994         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
14995         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
14996         return (uint64_t)ret_conv;
14997 }
14998
14999 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
15000         LDKKeysManager this_arg_conv;
15001         this_arg_conv.inner = (void*)(this_arg & (~1));
15002         this_arg_conv.is_owned = false;
15003         LDKKeysInterface* ret_ret =MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
15004         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
15005         return (uint64_t)ret_ret;
15006 }
15007
15008 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
15009         LDKChannelManager this_obj_conv;
15010         this_obj_conv.inner = (void*)(this_obj & (~1));
15011         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15012         ChannelManager_free(this_obj_conv);
15013 }
15014
15015 void  __attribute__((visibility("default"))) TS_ChainParameters_free(uint32_t this_obj) {
15016         LDKChainParameters this_obj_conv;
15017         this_obj_conv.inner = (void*)(this_obj & (~1));
15018         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15019         ChainParameters_free(this_obj_conv);
15020 }
15021
15022 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
15023         LDKChainParameters this_ptr_conv;
15024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15025         this_ptr_conv.is_owned = false;
15026         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
15027         return ret_conv;
15028 }
15029
15030 void  __attribute__((visibility("default"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
15031         LDKChainParameters this_ptr_conv;
15032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15033         this_ptr_conv.is_owned = false;
15034         LDKNetwork val_conv = LDKNetwork_from_js(val);
15035         ChainParameters_set_network(&this_ptr_conv, val_conv);
15036 }
15037
15038 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
15039         LDKChainParameters this_ptr_conv;
15040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15041         this_ptr_conv.is_owned = false;
15042         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
15043         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15044         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15045         uint64_t ret_ref = (uint64_t)ret_var.inner;
15046         if (ret_var.is_owned) {
15047                 ret_ref |= 1;
15048         }
15049         return ret_ref;
15050 }
15051
15052 void  __attribute__((visibility("default"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
15053         LDKChainParameters this_ptr_conv;
15054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15055         this_ptr_conv.is_owned = false;
15056         LDKBestBlock val_conv;
15057         val_conv.inner = (void*)(val & (~1));
15058         val_conv.is_owned = (val & 1) || (val == 0);
15059         val_conv = BestBlock_clone(&val_conv);
15060         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
15061 }
15062
15063 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
15064         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
15065         LDKBestBlock best_block_arg_conv;
15066         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
15067         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
15068         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
15069         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
15070         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15071         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15072         uint64_t ret_ref = (uint64_t)ret_var.inner;
15073         if (ret_var.is_owned) {
15074                 ret_ref |= 1;
15075         }
15076         return ret_ref;
15077 }
15078
15079 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32_t orig) {
15080         LDKChainParameters orig_conv;
15081         orig_conv.inner = (void*)(orig & (~1));
15082         orig_conv.is_owned = false;
15083         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
15084         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15085         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15086         uint64_t ret_ref = (uint64_t)ret_var.inner;
15087         if (ret_var.is_owned) {
15088                 ret_ref |= 1;
15089         }
15090         return ret_ref;
15091 }
15092
15093 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
15094         LDKCounterpartyForwardingInfo this_obj_conv;
15095         this_obj_conv.inner = (void*)(this_obj & (~1));
15096         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15097         CounterpartyForwardingInfo_free(this_obj_conv);
15098 }
15099
15100 int32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
15101         LDKCounterpartyForwardingInfo this_ptr_conv;
15102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15103         this_ptr_conv.is_owned = false;
15104         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
15105         return ret_val;
15106 }
15107
15108 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
15109         LDKCounterpartyForwardingInfo this_ptr_conv;
15110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15111         this_ptr_conv.is_owned = false;
15112         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
15113 }
15114
15115 int32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
15116         LDKCounterpartyForwardingInfo this_ptr_conv;
15117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15118         this_ptr_conv.is_owned = false;
15119         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
15120         return ret_val;
15121 }
15122
15123 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
15124         LDKCounterpartyForwardingInfo this_ptr_conv;
15125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15126         this_ptr_conv.is_owned = false;
15127         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
15128 }
15129
15130 int16_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
15131         LDKCounterpartyForwardingInfo this_ptr_conv;
15132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15133         this_ptr_conv.is_owned = false;
15134         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
15135         return ret_val;
15136 }
15137
15138 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
15139         LDKCounterpartyForwardingInfo this_ptr_conv;
15140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15141         this_ptr_conv.is_owned = false;
15142         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
15143 }
15144
15145 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) {
15146         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
15147         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15148         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15149         uint64_t ret_ref = (uint64_t)ret_var.inner;
15150         if (ret_var.is_owned) {
15151                 ret_ref |= 1;
15152         }
15153         return ret_ref;
15154 }
15155
15156 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
15157         LDKCounterpartyForwardingInfo orig_conv;
15158         orig_conv.inner = (void*)(orig & (~1));
15159         orig_conv.is_owned = false;
15160         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
15161         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15162         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15163         uint64_t ret_ref = (uint64_t)ret_var.inner;
15164         if (ret_var.is_owned) {
15165                 ret_ref |= 1;
15166         }
15167         return ret_ref;
15168 }
15169
15170 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
15171         LDKChannelCounterparty this_obj_conv;
15172         this_obj_conv.inner = (void*)(this_obj & (~1));
15173         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15174         ChannelCounterparty_free(this_obj_conv);
15175 }
15176
15177 int8_tArray  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
15178         LDKChannelCounterparty this_ptr_conv;
15179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15180         this_ptr_conv.is_owned = false;
15181         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15182         memcpy((uint8_t*)(ret_arr + 4), ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
15183         return ret_arr;
15184 }
15185
15186 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
15187         LDKChannelCounterparty this_ptr_conv;
15188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15189         this_ptr_conv.is_owned = false;
15190         LDKPublicKey val_ref;
15191         CHECK(*((uint32_t*)val) == 33);
15192         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15193         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
15194 }
15195
15196 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
15197         LDKChannelCounterparty this_ptr_conv;
15198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15199         this_ptr_conv.is_owned = false;
15200         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
15201         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15202         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15203         uint64_t ret_ref = (uint64_t)ret_var.inner;
15204         if (ret_var.is_owned) {
15205                 ret_ref |= 1;
15206         }
15207         return ret_ref;
15208 }
15209
15210 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
15211         LDKChannelCounterparty this_ptr_conv;
15212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15213         this_ptr_conv.is_owned = false;
15214         LDKInitFeatures val_conv;
15215         val_conv.inner = (void*)(val & (~1));
15216         val_conv.is_owned = (val & 1) || (val == 0);
15217         val_conv = InitFeatures_clone(&val_conv);
15218         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
15219 }
15220
15221 int64_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
15222         LDKChannelCounterparty this_ptr_conv;
15223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15224         this_ptr_conv.is_owned = false;
15225         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
15226         return ret_val;
15227 }
15228
15229 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
15230         LDKChannelCounterparty this_ptr_conv;
15231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15232         this_ptr_conv.is_owned = false;
15233         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
15234 }
15235
15236 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
15237         LDKChannelCounterparty this_ptr_conv;
15238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15239         this_ptr_conv.is_owned = false;
15240         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
15241         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15242         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15243         uint64_t ret_ref = (uint64_t)ret_var.inner;
15244         if (ret_var.is_owned) {
15245                 ret_ref |= 1;
15246         }
15247         return ret_ref;
15248 }
15249
15250 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
15251         LDKChannelCounterparty this_ptr_conv;
15252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15253         this_ptr_conv.is_owned = false;
15254         LDKCounterpartyForwardingInfo val_conv;
15255         val_conv.inner = (void*)(val & (~1));
15256         val_conv.is_owned = (val & 1) || (val == 0);
15257         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
15258         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
15259 }
15260
15261 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) {
15262         LDKPublicKey node_id_arg_ref;
15263         CHECK(*((uint32_t*)node_id_arg) == 33);
15264         memcpy(node_id_arg_ref.compressed_form, (uint8_t*)(node_id_arg + 4), 33);
15265         LDKInitFeatures features_arg_conv;
15266         features_arg_conv.inner = (void*)(features_arg & (~1));
15267         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
15268         features_arg_conv = InitFeatures_clone(&features_arg_conv);
15269         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
15270         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
15271         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
15272         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
15273         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
15274         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15275         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15276         uint64_t ret_ref = (uint64_t)ret_var.inner;
15277         if (ret_var.is_owned) {
15278                 ret_ref |= 1;
15279         }
15280         return ret_ref;
15281 }
15282
15283 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_clone(uint32_t orig) {
15284         LDKChannelCounterparty orig_conv;
15285         orig_conv.inner = (void*)(orig & (~1));
15286         orig_conv.is_owned = false;
15287         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
15288         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15289         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15290         uint64_t ret_ref = (uint64_t)ret_var.inner;
15291         if (ret_var.is_owned) {
15292                 ret_ref |= 1;
15293         }
15294         return ret_ref;
15295 }
15296
15297 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) {
15298         LDKChannelDetails this_obj_conv;
15299         this_obj_conv.inner = (void*)(this_obj & (~1));
15300         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15301         ChannelDetails_free(this_obj_conv);
15302 }
15303
15304 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
15305         LDKChannelDetails this_ptr_conv;
15306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15307         this_ptr_conv.is_owned = false;
15308         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15309         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
15310         return ret_arr;
15311 }
15312
15313 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
15314         LDKChannelDetails this_ptr_conv;
15315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15316         this_ptr_conv.is_owned = false;
15317         LDKThirtyTwoBytes val_ref;
15318         CHECK(*((uint32_t*)val) == 32);
15319         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15320         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
15321 }
15322
15323 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
15324         LDKChannelDetails this_ptr_conv;
15325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15326         this_ptr_conv.is_owned = false;
15327         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
15328         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15329         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15330         uint64_t ret_ref = (uint64_t)ret_var.inner;
15331         if (ret_var.is_owned) {
15332                 ret_ref |= 1;
15333         }
15334         return ret_ref;
15335 }
15336
15337 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
15338         LDKChannelDetails this_ptr_conv;
15339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15340         this_ptr_conv.is_owned = false;
15341         LDKChannelCounterparty val_conv;
15342         val_conv.inner = (void*)(val & (~1));
15343         val_conv.is_owned = (val & 1) || (val == 0);
15344         val_conv = ChannelCounterparty_clone(&val_conv);
15345         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
15346 }
15347
15348 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
15349         LDKChannelDetails this_ptr_conv;
15350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15351         this_ptr_conv.is_owned = false;
15352         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
15353         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15354         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15355         uint64_t ret_ref = (uint64_t)ret_var.inner;
15356         if (ret_var.is_owned) {
15357                 ret_ref |= 1;
15358         }
15359         return ret_ref;
15360 }
15361
15362 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
15363         LDKChannelDetails this_ptr_conv;
15364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15365         this_ptr_conv.is_owned = false;
15366         LDKOutPoint val_conv;
15367         val_conv.inner = (void*)(val & (~1));
15368         val_conv.is_owned = (val & 1) || (val == 0);
15369         val_conv = OutPoint_clone(&val_conv);
15370         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
15371 }
15372
15373 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
15374         LDKChannelDetails this_ptr_conv;
15375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15376         this_ptr_conv.is_owned = false;
15377         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15378         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
15379         uint64_t ret_ref = (uint64_t)ret_copy;
15380         return ret_ref;
15381 }
15382
15383 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
15384         LDKChannelDetails this_ptr_conv;
15385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15386         this_ptr_conv.is_owned = false;
15387         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
15388         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
15389         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
15390 }
15391
15392 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
15393         LDKChannelDetails this_ptr_conv;
15394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15395         this_ptr_conv.is_owned = false;
15396         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
15397         return ret_val;
15398 }
15399
15400 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
15401         LDKChannelDetails this_ptr_conv;
15402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15403         this_ptr_conv.is_owned = false;
15404         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
15405 }
15406
15407 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
15408         LDKChannelDetails this_ptr_conv;
15409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15410         this_ptr_conv.is_owned = false;
15411         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15412         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
15413         uint64_t ret_ref = (uint64_t)ret_copy;
15414         return ret_ref;
15415 }
15416
15417 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
15418         LDKChannelDetails this_ptr_conv;
15419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15420         this_ptr_conv.is_owned = false;
15421         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
15422         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
15423         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
15424 }
15425
15426 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_id(uint32_t this_ptr) {
15427         LDKChannelDetails this_ptr_conv;
15428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15429         this_ptr_conv.is_owned = false;
15430         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
15431         return ret_val;
15432 }
15433
15434 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_id(uint32_t this_ptr, int64_t val) {
15435         LDKChannelDetails this_ptr_conv;
15436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15437         this_ptr_conv.is_owned = false;
15438         ChannelDetails_set_user_id(&this_ptr_conv, val);
15439 }
15440
15441 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
15442         LDKChannelDetails this_ptr_conv;
15443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15444         this_ptr_conv.is_owned = false;
15445         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
15446         return ret_val;
15447 }
15448
15449 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
15450         LDKChannelDetails this_ptr_conv;
15451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15452         this_ptr_conv.is_owned = false;
15453         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
15454 }
15455
15456 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
15457         LDKChannelDetails this_ptr_conv;
15458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15459         this_ptr_conv.is_owned = false;
15460         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
15461         return ret_val;
15462 }
15463
15464 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
15465         LDKChannelDetails this_ptr_conv;
15466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15467         this_ptr_conv.is_owned = false;
15468         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
15469 }
15470
15471 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
15472         LDKChannelDetails this_ptr_conv;
15473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15474         this_ptr_conv.is_owned = false;
15475         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15476         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
15477         uint64_t ret_ref = (uint64_t)ret_copy;
15478         return ret_ref;
15479 }
15480
15481 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
15482         LDKChannelDetails this_ptr_conv;
15483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15484         this_ptr_conv.is_owned = false;
15485         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
15486         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
15487         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
15488 }
15489
15490 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
15491         LDKChannelDetails this_ptr_conv;
15492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15493         this_ptr_conv.is_owned = false;
15494         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15495         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
15496         uint64_t ret_ref = (uint64_t)ret_copy;
15497         return ret_ref;
15498 }
15499
15500 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_force_close_spend_delay(uint32_t this_ptr, uint32_t val) {
15501         LDKChannelDetails this_ptr_conv;
15502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15503         this_ptr_conv.is_owned = false;
15504         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
15505         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
15506         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
15507 }
15508
15509 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
15510         LDKChannelDetails this_ptr_conv;
15511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15512         this_ptr_conv.is_owned = false;
15513         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
15514         return ret_val;
15515 }
15516
15517 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
15518         LDKChannelDetails this_ptr_conv;
15519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15520         this_ptr_conv.is_owned = false;
15521         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
15522 }
15523
15524 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
15525         LDKChannelDetails this_ptr_conv;
15526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15527         this_ptr_conv.is_owned = false;
15528         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
15529         return ret_val;
15530 }
15531
15532 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
15533         LDKChannelDetails this_ptr_conv;
15534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15535         this_ptr_conv.is_owned = false;
15536         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
15537 }
15538
15539 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
15540         LDKChannelDetails this_ptr_conv;
15541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15542         this_ptr_conv.is_owned = false;
15543         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
15544         return ret_val;
15545 }
15546
15547 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
15548         LDKChannelDetails this_ptr_conv;
15549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15550         this_ptr_conv.is_owned = false;
15551         ChannelDetails_set_is_usable(&this_ptr_conv, val);
15552 }
15553
15554 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
15555         LDKChannelDetails this_ptr_conv;
15556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15557         this_ptr_conv.is_owned = false;
15558         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
15559         return ret_val;
15560 }
15561
15562 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
15563         LDKChannelDetails this_ptr_conv;
15564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15565         this_ptr_conv.is_owned = false;
15566         ChannelDetails_set_is_public(&this_ptr_conv, val);
15567 }
15568
15569 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_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) {
15570         LDKThirtyTwoBytes channel_id_arg_ref;
15571         CHECK(*((uint32_t*)channel_id_arg) == 32);
15572         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
15573         LDKChannelCounterparty counterparty_arg_conv;
15574         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
15575         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
15576         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
15577         LDKOutPoint funding_txo_arg_conv;
15578         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
15579         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
15580         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
15581         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1);
15582         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1));
15583         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
15584         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1);
15585         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1));
15586         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1);
15587         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1));
15588         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_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);
15589         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15590         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15591         uint64_t ret_ref = (uint64_t)ret_var.inner;
15592         if (ret_var.is_owned) {
15593                 ret_ref |= 1;
15594         }
15595         return ret_ref;
15596 }
15597
15598 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
15599         LDKChannelDetails orig_conv;
15600         orig_conv.inner = (void*)(orig & (~1));
15601         orig_conv.is_owned = false;
15602         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
15603         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15604         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15605         uint64_t ret_ref = (uint64_t)ret_var.inner;
15606         if (ret_var.is_owned) {
15607                 ret_ref |= 1;
15608         }
15609         return ret_ref;
15610 }
15611
15612 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
15613         if ((this_ptr & 1) != 0) return;
15614         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
15615         FREE((void*)this_ptr);
15616         PaymentSendFailure_free(this_ptr_conv);
15617 }
15618
15619 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uint32_t orig) {
15620         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
15621         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
15622         *ret_copy = PaymentSendFailure_clone(orig_conv);
15623         uint64_t ret_ref = (uint64_t)ret_copy;
15624         return ret_ref;
15625 }
15626
15627 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
15628         LDKAPIError a_conv = *(LDKAPIError*)(((uint64_t)a) & ~1);
15629         a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
15630         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
15631         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
15632         uint64_t ret_ref = (uint64_t)ret_copy;
15633         return ret_ref;
15634 }
15635
15636 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
15637         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
15638         a_constr.datalen = *((uint32_t*)a);
15639         if (a_constr.datalen > 0)
15640                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15641         else
15642                 a_constr.data = NULL;
15643         uint32_t* a_vals = (uint32_t*)(a + 4);
15644         for (size_t w = 0; w < a_constr.datalen; w++) {
15645                 uint32_t a_conv_22 = a_vals[w];
15646                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
15647                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
15648                 a_constr.data[w] = a_conv_22_conv;
15649         }
15650         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
15651         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
15652         uint64_t ret_ref = (uint64_t)ret_copy;
15653         return ret_ref;
15654 }
15655
15656 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
15657         LDKCVec_APIErrorZ a_constr;
15658         a_constr.datalen = *((uint32_t*)a);
15659         if (a_constr.datalen > 0)
15660                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
15661         else
15662                 a_constr.data = NULL;
15663         uint32_t* a_vals = (uint32_t*)(a + 4);
15664         for (size_t k = 0; k < a_constr.datalen; k++) {
15665                 uint32_t a_conv_10 = a_vals[k];
15666                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(((uint64_t)a_conv_10) & ~1);
15667                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
15668                 a_constr.data[k] = a_conv_10_conv;
15669         }
15670         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
15671         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
15672         uint64_t ret_ref = (uint64_t)ret_copy;
15673         return ret_ref;
15674 }
15675
15676 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_partial_failure(uint32_tArray a) {
15677         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
15678         a_constr.datalen = *((uint32_t*)a);
15679         if (a_constr.datalen > 0)
15680                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15681         else
15682                 a_constr.data = NULL;
15683         uint32_t* a_vals = (uint32_t*)(a + 4);
15684         for (size_t w = 0; w < a_constr.datalen; w++) {
15685                 uint32_t a_conv_22 = a_vals[w];
15686                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
15687                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
15688                 a_constr.data[w] = a_conv_22_conv;
15689         }
15690         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
15691         *ret_copy = PaymentSendFailure_partial_failure(a_constr);
15692         uint64_t ret_ref = (uint64_t)ret_copy;
15693         return ret_ref;
15694 }
15695
15696 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) {
15697         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
15698         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
15699         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
15700         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15701         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
15702         LDKUserConfig config_conv;
15703         config_conv.inner = (void*)(config & (~1));
15704         config_conv.is_owned = (config & 1) || (config == 0);
15705         config_conv = UserConfig_clone(&config_conv);
15706         LDKChainParameters params_conv;
15707         params_conv.inner = (void*)(params & (~1));
15708         params_conv.is_owned = (params & 1) || (params == 0);
15709         params_conv = ChainParameters_clone(&params_conv);
15710         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
15711         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15712         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15713         uint64_t ret_ref = (uint64_t)ret_var.inner;
15714         if (ret_var.is_owned) {
15715                 ret_ref |= 1;
15716         }
15717         return ret_ref;
15718 }
15719
15720 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
15721         LDKChannelManager this_arg_conv;
15722         this_arg_conv.inner = (void*)(this_arg & (~1));
15723         this_arg_conv.is_owned = false;
15724         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
15725         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15726         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15727         uint64_t ret_ref = (uint64_t)ret_var.inner;
15728         if (ret_var.is_owned) {
15729                 ret_ref |= 1;
15730         }
15731         return ret_ref;
15732 }
15733
15734 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_id, uint32_t override_config) {
15735         LDKChannelManager this_arg_conv;
15736         this_arg_conv.inner = (void*)(this_arg & (~1));
15737         this_arg_conv.is_owned = false;
15738         LDKPublicKey their_network_key_ref;
15739         CHECK(*((uint32_t*)their_network_key) == 33);
15740         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
15741         LDKUserConfig override_config_conv;
15742         override_config_conv.inner = (void*)(override_config & (~1));
15743         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
15744         override_config_conv = UserConfig_clone(&override_config_conv);
15745         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15746         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
15747         return (uint64_t)ret_conv;
15748 }
15749
15750 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
15751         LDKChannelManager this_arg_conv;
15752         this_arg_conv.inner = (void*)(this_arg & (~1));
15753         this_arg_conv.is_owned = false;
15754         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
15755         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
15756         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
15757         for (size_t q = 0; q < ret_var.datalen; q++) {
15758                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
15759                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15760                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15761                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
15762                 if (ret_conv_16_var.is_owned) {
15763                         ret_conv_16_ref |= 1;
15764                 }
15765                 ret_arr_ptr[q] = ret_conv_16_ref;
15766         }
15767         FREE(ret_var.data);
15768         return ret_arr;
15769 }
15770
15771 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
15772         LDKChannelManager this_arg_conv;
15773         this_arg_conv.inner = (void*)(this_arg & (~1));
15774         this_arg_conv.is_owned = false;
15775         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
15776         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
15777         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
15778         for (size_t q = 0; q < ret_var.datalen; q++) {
15779                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
15780                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15781                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15782                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
15783                 if (ret_conv_16_var.is_owned) {
15784                         ret_conv_16_ref |= 1;
15785                 }
15786                 ret_arr_ptr[q] = ret_conv_16_ref;
15787         }
15788         FREE(ret_var.data);
15789         return ret_arr;
15790 }
15791
15792 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
15793         LDKChannelManager this_arg_conv;
15794         this_arg_conv.inner = (void*)(this_arg & (~1));
15795         this_arg_conv.is_owned = false;
15796         unsigned char channel_id_arr[32];
15797         CHECK(*((uint32_t*)channel_id) == 32);
15798         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
15799         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
15800         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15801         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
15802         return (uint64_t)ret_conv;
15803 }
15804
15805 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) {
15806         LDKChannelManager this_arg_conv;
15807         this_arg_conv.inner = (void*)(this_arg & (~1));
15808         this_arg_conv.is_owned = false;
15809         unsigned char channel_id_arr[32];
15810         CHECK(*((uint32_t*)channel_id) == 32);
15811         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
15812         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
15813         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15814         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
15815         return (uint64_t)ret_conv;
15816 }
15817
15818 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
15819         LDKChannelManager this_arg_conv;
15820         this_arg_conv.inner = (void*)(this_arg & (~1));
15821         this_arg_conv.is_owned = false;
15822         unsigned char channel_id_arr[32];
15823         CHECK(*((uint32_t*)channel_id) == 32);
15824         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
15825         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
15826         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15827         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
15828         return (uint64_t)ret_conv;
15829 }
15830
15831 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
15832         LDKChannelManager this_arg_conv;
15833         this_arg_conv.inner = (void*)(this_arg & (~1));
15834         this_arg_conv.is_owned = false;
15835         ChannelManager_force_close_all_channels(&this_arg_conv);
15836 }
15837
15838 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
15839         LDKChannelManager this_arg_conv;
15840         this_arg_conv.inner = (void*)(this_arg & (~1));
15841         this_arg_conv.is_owned = false;
15842         LDKRoute route_conv;
15843         route_conv.inner = (void*)(route & (~1));
15844         route_conv.is_owned = false;
15845         LDKThirtyTwoBytes payment_hash_ref;
15846         CHECK(*((uint32_t*)payment_hash) == 32);
15847         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
15848         LDKThirtyTwoBytes payment_secret_ref;
15849         CHECK(*((uint32_t*)payment_secret) == 32);
15850         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
15851         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15852         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
15853         return (uint64_t)ret_conv;
15854 }
15855
15856 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_spontaneous_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_preimage) {
15857         LDKChannelManager this_arg_conv;
15858         this_arg_conv.inner = (void*)(this_arg & (~1));
15859         this_arg_conv.is_owned = false;
15860         LDKRoute route_conv;
15861         route_conv.inner = (void*)(route & (~1));
15862         route_conv.is_owned = false;
15863         LDKThirtyTwoBytes payment_preimage_ref;
15864         CHECK(*((uint32_t*)payment_preimage) == 32);
15865         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
15866         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
15867         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
15868         return (uint64_t)ret_conv;
15869 }
15870
15871 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
15872         LDKChannelManager this_arg_conv;
15873         this_arg_conv.inner = (void*)(this_arg & (~1));
15874         this_arg_conv.is_owned = false;
15875         unsigned char temporary_channel_id_arr[32];
15876         CHECK(*((uint32_t*)temporary_channel_id) == 32);
15877         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
15878         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
15879         LDKTransaction funding_transaction_ref;
15880         funding_transaction_ref.datalen = *((uint32_t*)funding_transaction);
15881         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
15882         memcpy(funding_transaction_ref.data, (uint8_t*)(funding_transaction + 4), funding_transaction_ref.datalen);
15883         funding_transaction_ref.data_is_owned = true;
15884         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15885         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
15886         return (uint64_t)ret_conv;
15887 }
15888
15889 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
15890         LDKChannelManager this_arg_conv;
15891         this_arg_conv.inner = (void*)(this_arg & (~1));
15892         this_arg_conv.is_owned = false;
15893         LDKThreeBytes rgb_ref;
15894         CHECK(*((uint32_t*)rgb) == 3);
15895         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
15896         LDKThirtyTwoBytes alias_ref;
15897         CHECK(*((uint32_t*)alias) == 32);
15898         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
15899         LDKCVec_NetAddressZ addresses_constr;
15900         addresses_constr.datalen = *((uint32_t*)addresses);
15901         if (addresses_constr.datalen > 0)
15902                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15903         else
15904                 addresses_constr.data = NULL;
15905         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
15906         for (size_t m = 0; m < addresses_constr.datalen; m++) {
15907                 uint32_t addresses_conv_12 = addresses_vals[m];
15908                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
15909                 addresses_constr.data[m] = addresses_conv_12_conv;
15910         }
15911         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
15912 }
15913
15914 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
15915         LDKChannelManager this_arg_conv;
15916         this_arg_conv.inner = (void*)(this_arg & (~1));
15917         this_arg_conv.is_owned = false;
15918         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
15919 }
15920
15921 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
15922         LDKChannelManager this_arg_conv;
15923         this_arg_conv.inner = (void*)(this_arg & (~1));
15924         this_arg_conv.is_owned = false;
15925         ChannelManager_timer_tick_occurred(&this_arg_conv);
15926 }
15927
15928 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
15929         LDKChannelManager this_arg_conv;
15930         this_arg_conv.inner = (void*)(this_arg & (~1));
15931         this_arg_conv.is_owned = false;
15932         unsigned char payment_hash_arr[32];
15933         CHECK(*((uint32_t*)payment_hash) == 32);
15934         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
15935         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
15936         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
15937         return ret_val;
15938 }
15939
15940 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
15941         LDKChannelManager this_arg_conv;
15942         this_arg_conv.inner = (void*)(this_arg & (~1));
15943         this_arg_conv.is_owned = false;
15944         LDKThirtyTwoBytes payment_preimage_ref;
15945         CHECK(*((uint32_t*)payment_preimage) == 32);
15946         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
15947         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
15948         return ret_val;
15949 }
15950
15951 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
15952         LDKChannelManager this_arg_conv;
15953         this_arg_conv.inner = (void*)(this_arg & (~1));
15954         this_arg_conv.is_owned = false;
15955         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15956         memcpy((uint8_t*)(ret_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
15957         return ret_arr;
15958 }
15959
15960 void  __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
15961         LDKChannelManager this_arg_conv;
15962         this_arg_conv.inner = (void*)(this_arg & (~1));
15963         this_arg_conv.is_owned = false;
15964         LDKOutPoint funding_txo_conv;
15965         funding_txo_conv.inner = (void*)(funding_txo & (~1));
15966         funding_txo_conv.is_owned = false;
15967         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
15968 }
15969
15970 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) {
15971         LDKChannelManager this_arg_conv;
15972         this_arg_conv.inner = (void*)(this_arg & (~1));
15973         this_arg_conv.is_owned = false;
15974         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
15975         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
15976         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15977         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
15978         return ((uint64_t)ret_conv);
15979 }
15980
15981 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) {
15982         LDKChannelManager this_arg_conv;
15983         this_arg_conv.inner = (void*)(this_arg & (~1));
15984         this_arg_conv.is_owned = false;
15985         LDKThirtyTwoBytes payment_hash_ref;
15986         CHECK(*((uint32_t*)payment_hash) == 32);
15987         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
15988         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
15989         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
15990         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15991         *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);
15992         return (uint64_t)ret_conv;
15993 }
15994
15995 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
15996         LDKChannelManager this_arg_conv;
15997         this_arg_conv.inner = (void*)(this_arg & (~1));
15998         this_arg_conv.is_owned = false;
15999         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
16000         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
16001         return (uint64_t)ret_ret;
16002 }
16003
16004 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
16005         LDKChannelManager this_arg_conv;
16006         this_arg_conv.inner = (void*)(this_arg & (~1));
16007         this_arg_conv.is_owned = false;
16008         LDKEventsProvider* ret_ret =MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
16009         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
16010         return (uint64_t)ret_ret;
16011 }
16012
16013 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
16014         LDKChannelManager this_arg_conv;
16015         this_arg_conv.inner = (void*)(this_arg & (~1));
16016         this_arg_conv.is_owned = false;
16017         LDKListen* ret_ret =MALLOC(sizeof(LDKListen), "LDKListen");
16018         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
16019         return (uint64_t)ret_ret;
16020 }
16021
16022 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
16023         LDKChannelManager this_arg_conv;
16024         this_arg_conv.inner = (void*)(this_arg & (~1));
16025         this_arg_conv.is_owned = false;
16026         LDKConfirm* ret_ret =MALLOC(sizeof(LDKConfirm), "LDKConfirm");
16027         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
16028         return (uint64_t)ret_ret;
16029 }
16030
16031 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update_timeout(uint32_t this_arg, int64_t max_wait) {
16032         LDKChannelManager this_arg_conv;
16033         this_arg_conv.inner = (void*)(this_arg & (~1));
16034         this_arg_conv.is_owned = false;
16035         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
16036         return ret_val;
16037 }
16038
16039 void  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
16040         LDKChannelManager this_arg_conv;
16041         this_arg_conv.inner = (void*)(this_arg & (~1));
16042         this_arg_conv.is_owned = false;
16043         ChannelManager_await_persistable_update(&this_arg_conv);
16044 }
16045
16046 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
16047         LDKChannelManager this_arg_conv;
16048         this_arg_conv.inner = (void*)(this_arg & (~1));
16049         this_arg_conv.is_owned = false;
16050         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
16051         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16052         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16053         uint64_t ret_ref = (uint64_t)ret_var.inner;
16054         if (ret_var.is_owned) {
16055                 ret_ref |= 1;
16056         }
16057         return ret_ref;
16058 }
16059
16060 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
16061         LDKChannelManager this_arg_conv;
16062         this_arg_conv.inner = (void*)(this_arg & (~1));
16063         this_arg_conv.is_owned = false;
16064         LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
16065         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
16066         return (uint64_t)ret_ret;
16067 }
16068
16069 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
16070         LDKChannelManager obj_conv;
16071         obj_conv.inner = (void*)(obj & (~1));
16072         obj_conv.is_owned = false;
16073         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
16074         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16075         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16076         CVec_u8Z_free(ret_var);
16077         return ret_arr;
16078 }
16079
16080 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
16081         LDKChannelManagerReadArgs this_obj_conv;
16082         this_obj_conv.inner = (void*)(this_obj & (~1));
16083         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16084         ChannelManagerReadArgs_free(this_obj_conv);
16085 }
16086
16087 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
16088         LDKChannelManagerReadArgs this_ptr_conv;
16089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16090         this_ptr_conv.is_owned = false;
16091         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
16092         return ret_ret;
16093 }
16094
16095 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
16096         LDKChannelManagerReadArgs this_ptr_conv;
16097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16098         this_ptr_conv.is_owned = false;
16099         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
16100         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
16101 }
16102
16103 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
16104         LDKChannelManagerReadArgs this_ptr_conv;
16105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16106         this_ptr_conv.is_owned = false;
16107         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
16108         return ret_ret;
16109 }
16110
16111 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
16112         LDKChannelManagerReadArgs this_ptr_conv;
16113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16114         this_ptr_conv.is_owned = false;
16115         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
16116         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
16117 }
16118
16119 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
16120         LDKChannelManagerReadArgs this_ptr_conv;
16121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16122         this_ptr_conv.is_owned = false;
16123         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
16124         return ret_ret;
16125 }
16126
16127 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
16128         LDKChannelManagerReadArgs this_ptr_conv;
16129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16130         this_ptr_conv.is_owned = false;
16131         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
16132         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
16133 }
16134
16135 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
16136         LDKChannelManagerReadArgs this_ptr_conv;
16137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16138         this_ptr_conv.is_owned = false;
16139         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
16140         return ret_ret;
16141 }
16142
16143 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
16144         LDKChannelManagerReadArgs this_ptr_conv;
16145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16146         this_ptr_conv.is_owned = false;
16147         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
16148         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
16149 }
16150
16151 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
16152         LDKChannelManagerReadArgs this_ptr_conv;
16153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16154         this_ptr_conv.is_owned = false;
16155         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
16156         return ret_ret;
16157 }
16158
16159 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
16160         LDKChannelManagerReadArgs this_ptr_conv;
16161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16162         this_ptr_conv.is_owned = false;
16163         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
16164         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
16165 }
16166
16167 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
16168         LDKChannelManagerReadArgs this_ptr_conv;
16169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16170         this_ptr_conv.is_owned = false;
16171         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
16172         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16173         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16174         uint64_t ret_ref = (uint64_t)ret_var.inner;
16175         if (ret_var.is_owned) {
16176                 ret_ref |= 1;
16177         }
16178         return ret_ref;
16179 }
16180
16181 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
16182         LDKChannelManagerReadArgs this_ptr_conv;
16183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16184         this_ptr_conv.is_owned = false;
16185         LDKUserConfig val_conv;
16186         val_conv.inner = (void*)(val & (~1));
16187         val_conv.is_owned = (val & 1) || (val == 0);
16188         val_conv = UserConfig_clone(&val_conv);
16189         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
16190 }
16191
16192 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) {
16193         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16194         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
16195         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16196         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16197         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16198         LDKUserConfig default_config_conv;
16199         default_config_conv.inner = (void*)(default_config & (~1));
16200         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
16201         default_config_conv = UserConfig_clone(&default_config_conv);
16202         LDKCVec_ChannelMonitorZ channel_monitors_constr;
16203         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
16204         if (channel_monitors_constr.datalen > 0)
16205                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16206         else
16207                 channel_monitors_constr.data = NULL;
16208         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
16209         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
16210                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
16211                 LDKChannelMonitor channel_monitors_conv_16_conv;
16212                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
16213                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
16214                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
16215         }
16216         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);
16217         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16218         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16219         uint64_t ret_ref = (uint64_t)ret_var.inner;
16220         if (ret_var.is_owned) {
16221                 ret_ref |= 1;
16222         }
16223         return ret_ref;
16224 }
16225
16226 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
16227         LDKu8slice ser_ref;
16228         ser_ref.datalen = *((uint32_t*)ser);
16229         ser_ref.data = (int8_t*)(ser + 4);
16230         LDKChannelManagerReadArgs arg_conv;
16231         arg_conv.inner = (void*)(arg & (~1));
16232         arg_conv.is_owned = (arg & 1) || (arg == 0);
16233         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
16234         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16235         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
16236         return (uint64_t)ret_conv;
16237 }
16238
16239 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_obj) {
16240         LDKDecodeError this_obj_conv;
16241         this_obj_conv.inner = (void*)(this_obj & (~1));
16242         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16243         DecodeError_free(this_obj_conv);
16244 }
16245
16246 uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t orig) {
16247         LDKDecodeError orig_conv;
16248         orig_conv.inner = (void*)(orig & (~1));
16249         orig_conv.is_owned = false;
16250         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
16251         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16252         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16253         uint64_t ret_ref = (uint64_t)ret_var.inner;
16254         if (ret_var.is_owned) {
16255                 ret_ref |= 1;
16256         }
16257         return ret_ref;
16258 }
16259
16260 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_obj) {
16261         LDKInit this_obj_conv;
16262         this_obj_conv.inner = (void*)(this_obj & (~1));
16263         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16264         Init_free(this_obj_conv);
16265 }
16266
16267 uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t this_ptr) {
16268         LDKInit this_ptr_conv;
16269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16270         this_ptr_conv.is_owned = false;
16271         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
16272         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16273         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16274         uint64_t ret_ref = (uint64_t)ret_var.inner;
16275         if (ret_var.is_owned) {
16276                 ret_ref |= 1;
16277         }
16278         return ret_ref;
16279 }
16280
16281 void  __attribute__((visibility("default"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
16282         LDKInit this_ptr_conv;
16283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16284         this_ptr_conv.is_owned = false;
16285         LDKInitFeatures val_conv;
16286         val_conv.inner = (void*)(val & (~1));
16287         val_conv.is_owned = (val & 1) || (val == 0);
16288         val_conv = InitFeatures_clone(&val_conv);
16289         Init_set_features(&this_ptr_conv, val_conv);
16290 }
16291
16292 uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_arg) {
16293         LDKInitFeatures features_arg_conv;
16294         features_arg_conv.inner = (void*)(features_arg & (~1));
16295         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
16296         features_arg_conv = InitFeatures_clone(&features_arg_conv);
16297         LDKInit ret_var = Init_new(features_arg_conv);
16298         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16299         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16300         uint64_t ret_ref = (uint64_t)ret_var.inner;
16301         if (ret_var.is_owned) {
16302                 ret_ref |= 1;
16303         }
16304         return ret_ref;
16305 }
16306
16307 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
16308         LDKInit orig_conv;
16309         orig_conv.inner = (void*)(orig & (~1));
16310         orig_conv.is_owned = false;
16311         LDKInit ret_var = Init_clone(&orig_conv);
16312         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16313         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16314         uint64_t ret_ref = (uint64_t)ret_var.inner;
16315         if (ret_var.is_owned) {
16316                 ret_ref |= 1;
16317         }
16318         return ret_ref;
16319 }
16320
16321 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_obj) {
16322         LDKErrorMessage this_obj_conv;
16323         this_obj_conv.inner = (void*)(this_obj & (~1));
16324         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16325         ErrorMessage_free(this_obj_conv);
16326 }
16327
16328 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
16329         LDKErrorMessage this_ptr_conv;
16330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16331         this_ptr_conv.is_owned = false;
16332         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16333         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
16334         return ret_arr;
16335 }
16336
16337 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
16338         LDKErrorMessage this_ptr_conv;
16339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16340         this_ptr_conv.is_owned = false;
16341         LDKThirtyTwoBytes val_ref;
16342         CHECK(*((uint32_t*)val) == 32);
16343         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16344         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
16345 }
16346
16347 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
16348         LDKErrorMessage this_ptr_conv;
16349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16350         this_ptr_conv.is_owned = false;
16351         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
16352         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
16353         Str_free(ret_str);
16354         return ret_conv;
16355 }
16356
16357 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
16358         LDKErrorMessage this_ptr_conv;
16359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16360         this_ptr_conv.is_owned = false;
16361         LDKStr val_conv = str_ref_to_owned_c(val);
16362         ErrorMessage_set_data(&this_ptr_conv, val_conv);
16363 }
16364
16365 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
16366         LDKThirtyTwoBytes channel_id_arg_ref;
16367         CHECK(*((uint32_t*)channel_id_arg) == 32);
16368         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
16369         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
16370         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
16371         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16372         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16373         uint64_t ret_ref = (uint64_t)ret_var.inner;
16374         if (ret_var.is_owned) {
16375                 ret_ref |= 1;
16376         }
16377         return ret_ref;
16378 }
16379
16380 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
16381         LDKErrorMessage orig_conv;
16382         orig_conv.inner = (void*)(orig & (~1));
16383         orig_conv.is_owned = false;
16384         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
16385         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16386         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16387         uint64_t ret_ref = (uint64_t)ret_var.inner;
16388         if (ret_var.is_owned) {
16389                 ret_ref |= 1;
16390         }
16391         return ret_ref;
16392 }
16393
16394 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_obj) {
16395         LDKPing this_obj_conv;
16396         this_obj_conv.inner = (void*)(this_obj & (~1));
16397         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16398         Ping_free(this_obj_conv);
16399 }
16400
16401 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
16402         LDKPing this_ptr_conv;
16403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16404         this_ptr_conv.is_owned = false;
16405         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
16406         return ret_val;
16407 }
16408
16409 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
16410         LDKPing this_ptr_conv;
16411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16412         this_ptr_conv.is_owned = false;
16413         Ping_set_ponglen(&this_ptr_conv, val);
16414 }
16415
16416 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
16417         LDKPing this_ptr_conv;
16418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16419         this_ptr_conv.is_owned = false;
16420         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
16421         return ret_val;
16422 }
16423
16424 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
16425         LDKPing this_ptr_conv;
16426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16427         this_ptr_conv.is_owned = false;
16428         Ping_set_byteslen(&this_ptr_conv, val);
16429 }
16430
16431 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
16432         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
16433         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16434         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16435         uint64_t ret_ref = (uint64_t)ret_var.inner;
16436         if (ret_var.is_owned) {
16437                 ret_ref |= 1;
16438         }
16439         return ret_ref;
16440 }
16441
16442 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
16443         LDKPing orig_conv;
16444         orig_conv.inner = (void*)(orig & (~1));
16445         orig_conv.is_owned = false;
16446         LDKPing ret_var = Ping_clone(&orig_conv);
16447         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16448         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16449         uint64_t ret_ref = (uint64_t)ret_var.inner;
16450         if (ret_var.is_owned) {
16451                 ret_ref |= 1;
16452         }
16453         return ret_ref;
16454 }
16455
16456 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_obj) {
16457         LDKPong this_obj_conv;
16458         this_obj_conv.inner = (void*)(this_obj & (~1));
16459         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16460         Pong_free(this_obj_conv);
16461 }
16462
16463 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
16464         LDKPong this_ptr_conv;
16465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16466         this_ptr_conv.is_owned = false;
16467         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
16468         return ret_val;
16469 }
16470
16471 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
16472         LDKPong this_ptr_conv;
16473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16474         this_ptr_conv.is_owned = false;
16475         Pong_set_byteslen(&this_ptr_conv, val);
16476 }
16477
16478 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
16479         LDKPong ret_var = Pong_new(byteslen_arg);
16480         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16481         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16482         uint64_t ret_ref = (uint64_t)ret_var.inner;
16483         if (ret_var.is_owned) {
16484                 ret_ref |= 1;
16485         }
16486         return ret_ref;
16487 }
16488
16489 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
16490         LDKPong orig_conv;
16491         orig_conv.inner = (void*)(orig & (~1));
16492         orig_conv.is_owned = false;
16493         LDKPong ret_var = Pong_clone(&orig_conv);
16494         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16495         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16496         uint64_t ret_ref = (uint64_t)ret_var.inner;
16497         if (ret_var.is_owned) {
16498                 ret_ref |= 1;
16499         }
16500         return ret_ref;
16501 }
16502
16503 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_obj) {
16504         LDKOpenChannel this_obj_conv;
16505         this_obj_conv.inner = (void*)(this_obj & (~1));
16506         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16507         OpenChannel_free(this_obj_conv);
16508 }
16509
16510 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
16511         LDKOpenChannel this_ptr_conv;
16512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16513         this_ptr_conv.is_owned = false;
16514         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16515         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
16516         return ret_arr;
16517 }
16518
16519 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
16520         LDKOpenChannel this_ptr_conv;
16521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16522         this_ptr_conv.is_owned = false;
16523         LDKThirtyTwoBytes val_ref;
16524         CHECK(*((uint32_t*)val) == 32);
16525         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16526         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
16527 }
16528
16529 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
16530         LDKOpenChannel this_ptr_conv;
16531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16532         this_ptr_conv.is_owned = false;
16533         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16534         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
16535         return ret_arr;
16536 }
16537
16538 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
16539         LDKOpenChannel this_ptr_conv;
16540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16541         this_ptr_conv.is_owned = false;
16542         LDKThirtyTwoBytes val_ref;
16543         CHECK(*((uint32_t*)val) == 32);
16544         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16545         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
16546 }
16547
16548 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
16549         LDKOpenChannel this_ptr_conv;
16550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16551         this_ptr_conv.is_owned = false;
16552         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
16553         return ret_val;
16554 }
16555
16556 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
16557         LDKOpenChannel this_ptr_conv;
16558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16559         this_ptr_conv.is_owned = false;
16560         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
16561 }
16562
16563 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
16564         LDKOpenChannel this_ptr_conv;
16565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16566         this_ptr_conv.is_owned = false;
16567         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
16568         return ret_val;
16569 }
16570
16571 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
16572         LDKOpenChannel this_ptr_conv;
16573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16574         this_ptr_conv.is_owned = false;
16575         OpenChannel_set_push_msat(&this_ptr_conv, val);
16576 }
16577
16578 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
16579         LDKOpenChannel this_ptr_conv;
16580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16581         this_ptr_conv.is_owned = false;
16582         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
16583         return ret_val;
16584 }
16585
16586 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
16587         LDKOpenChannel this_ptr_conv;
16588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16589         this_ptr_conv.is_owned = false;
16590         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
16591 }
16592
16593 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
16594         LDKOpenChannel this_ptr_conv;
16595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16596         this_ptr_conv.is_owned = false;
16597         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
16598         return ret_val;
16599 }
16600
16601 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
16602         LDKOpenChannel this_ptr_conv;
16603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16604         this_ptr_conv.is_owned = false;
16605         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
16606 }
16607
16608 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
16609         LDKOpenChannel this_ptr_conv;
16610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16611         this_ptr_conv.is_owned = false;
16612         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
16613         return ret_val;
16614 }
16615
16616 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
16617         LDKOpenChannel this_ptr_conv;
16618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16619         this_ptr_conv.is_owned = false;
16620         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
16621 }
16622
16623 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
16624         LDKOpenChannel this_ptr_conv;
16625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16626         this_ptr_conv.is_owned = false;
16627         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
16628         return ret_val;
16629 }
16630
16631 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
16632         LDKOpenChannel this_ptr_conv;
16633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16634         this_ptr_conv.is_owned = false;
16635         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
16636 }
16637
16638 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
16639         LDKOpenChannel this_ptr_conv;
16640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16641         this_ptr_conv.is_owned = false;
16642         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
16643         return ret_val;
16644 }
16645
16646 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
16647         LDKOpenChannel this_ptr_conv;
16648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16649         this_ptr_conv.is_owned = false;
16650         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
16651 }
16652
16653 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
16654         LDKOpenChannel this_ptr_conv;
16655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16656         this_ptr_conv.is_owned = false;
16657         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
16658         return ret_val;
16659 }
16660
16661 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
16662         LDKOpenChannel this_ptr_conv;
16663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16664         this_ptr_conv.is_owned = false;
16665         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
16666 }
16667
16668 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
16669         LDKOpenChannel this_ptr_conv;
16670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16671         this_ptr_conv.is_owned = false;
16672         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
16673         return ret_val;
16674 }
16675
16676 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
16677         LDKOpenChannel this_ptr_conv;
16678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16679         this_ptr_conv.is_owned = false;
16680         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
16681 }
16682
16683 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
16684         LDKOpenChannel this_ptr_conv;
16685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16686         this_ptr_conv.is_owned = false;
16687         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16688         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
16689         return ret_arr;
16690 }
16691
16692 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
16693         LDKOpenChannel this_ptr_conv;
16694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16695         this_ptr_conv.is_owned = false;
16696         LDKPublicKey val_ref;
16697         CHECK(*((uint32_t*)val) == 33);
16698         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16699         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
16700 }
16701
16702 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
16703         LDKOpenChannel this_ptr_conv;
16704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16705         this_ptr_conv.is_owned = false;
16706         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16707         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
16708         return ret_arr;
16709 }
16710
16711 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
16712         LDKOpenChannel this_ptr_conv;
16713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16714         this_ptr_conv.is_owned = false;
16715         LDKPublicKey val_ref;
16716         CHECK(*((uint32_t*)val) == 33);
16717         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16718         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
16719 }
16720
16721 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
16722         LDKOpenChannel this_ptr_conv;
16723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16724         this_ptr_conv.is_owned = false;
16725         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16726         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
16727         return ret_arr;
16728 }
16729
16730 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
16731         LDKOpenChannel this_ptr_conv;
16732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16733         this_ptr_conv.is_owned = false;
16734         LDKPublicKey val_ref;
16735         CHECK(*((uint32_t*)val) == 33);
16736         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16737         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
16738 }
16739
16740 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
16741         LDKOpenChannel this_ptr_conv;
16742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16743         this_ptr_conv.is_owned = false;
16744         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16745         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
16746         return ret_arr;
16747 }
16748
16749 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
16750         LDKOpenChannel this_ptr_conv;
16751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16752         this_ptr_conv.is_owned = false;
16753         LDKPublicKey val_ref;
16754         CHECK(*((uint32_t*)val) == 33);
16755         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16756         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
16757 }
16758
16759 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
16760         LDKOpenChannel this_ptr_conv;
16761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16762         this_ptr_conv.is_owned = false;
16763         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16764         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
16765         return ret_arr;
16766 }
16767
16768 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
16769         LDKOpenChannel this_ptr_conv;
16770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16771         this_ptr_conv.is_owned = false;
16772         LDKPublicKey val_ref;
16773         CHECK(*((uint32_t*)val) == 33);
16774         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16775         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
16776 }
16777
16778 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
16779         LDKOpenChannel this_ptr_conv;
16780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16781         this_ptr_conv.is_owned = false;
16782         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16783         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
16784         return ret_arr;
16785 }
16786
16787 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
16788         LDKOpenChannel this_ptr_conv;
16789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16790         this_ptr_conv.is_owned = false;
16791         LDKPublicKey val_ref;
16792         CHECK(*((uint32_t*)val) == 33);
16793         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16794         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
16795 }
16796
16797 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
16798         LDKOpenChannel this_ptr_conv;
16799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16800         this_ptr_conv.is_owned = false;
16801         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
16802         return ret_val;
16803 }
16804
16805 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
16806         LDKOpenChannel this_ptr_conv;
16807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16808         this_ptr_conv.is_owned = false;
16809         OpenChannel_set_channel_flags(&this_ptr_conv, val);
16810 }
16811
16812 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
16813         LDKOpenChannel orig_conv;
16814         orig_conv.inner = (void*)(orig & (~1));
16815         orig_conv.is_owned = false;
16816         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
16817         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16818         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16819         uint64_t ret_ref = (uint64_t)ret_var.inner;
16820         if (ret_var.is_owned) {
16821                 ret_ref |= 1;
16822         }
16823         return ret_ref;
16824 }
16825
16826 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_obj) {
16827         LDKAcceptChannel this_obj_conv;
16828         this_obj_conv.inner = (void*)(this_obj & (~1));
16829         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16830         AcceptChannel_free(this_obj_conv);
16831 }
16832
16833 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
16834         LDKAcceptChannel this_ptr_conv;
16835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16836         this_ptr_conv.is_owned = false;
16837         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
16838         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
16839         return ret_arr;
16840 }
16841
16842 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
16843         LDKAcceptChannel this_ptr_conv;
16844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16845         this_ptr_conv.is_owned = false;
16846         LDKThirtyTwoBytes val_ref;
16847         CHECK(*((uint32_t*)val) == 32);
16848         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
16849         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
16850 }
16851
16852 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
16853         LDKAcceptChannel this_ptr_conv;
16854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16855         this_ptr_conv.is_owned = false;
16856         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
16857         return ret_val;
16858 }
16859
16860 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
16861         LDKAcceptChannel this_ptr_conv;
16862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16863         this_ptr_conv.is_owned = false;
16864         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
16865 }
16866
16867 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
16868         LDKAcceptChannel this_ptr_conv;
16869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16870         this_ptr_conv.is_owned = false;
16871         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
16872         return ret_val;
16873 }
16874
16875 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
16876         LDKAcceptChannel this_ptr_conv;
16877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16878         this_ptr_conv.is_owned = false;
16879         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
16880 }
16881
16882 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
16883         LDKAcceptChannel this_ptr_conv;
16884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16885         this_ptr_conv.is_owned = false;
16886         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
16887         return ret_val;
16888 }
16889
16890 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
16891         LDKAcceptChannel this_ptr_conv;
16892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16893         this_ptr_conv.is_owned = false;
16894         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
16895 }
16896
16897 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
16898         LDKAcceptChannel this_ptr_conv;
16899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16900         this_ptr_conv.is_owned = false;
16901         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
16902         return ret_val;
16903 }
16904
16905 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
16906         LDKAcceptChannel this_ptr_conv;
16907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16908         this_ptr_conv.is_owned = false;
16909         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
16910 }
16911
16912 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
16913         LDKAcceptChannel this_ptr_conv;
16914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16915         this_ptr_conv.is_owned = false;
16916         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
16917         return ret_val;
16918 }
16919
16920 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
16921         LDKAcceptChannel this_ptr_conv;
16922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16923         this_ptr_conv.is_owned = false;
16924         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
16925 }
16926
16927 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
16928         LDKAcceptChannel this_ptr_conv;
16929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16930         this_ptr_conv.is_owned = false;
16931         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
16932         return ret_val;
16933 }
16934
16935 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
16936         LDKAcceptChannel this_ptr_conv;
16937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16938         this_ptr_conv.is_owned = false;
16939         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
16940 }
16941
16942 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
16943         LDKAcceptChannel this_ptr_conv;
16944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16945         this_ptr_conv.is_owned = false;
16946         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
16947         return ret_val;
16948 }
16949
16950 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
16951         LDKAcceptChannel this_ptr_conv;
16952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16953         this_ptr_conv.is_owned = false;
16954         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
16955 }
16956
16957 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
16958         LDKAcceptChannel this_ptr_conv;
16959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16960         this_ptr_conv.is_owned = false;
16961         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16962         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
16963         return ret_arr;
16964 }
16965
16966 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
16967         LDKAcceptChannel this_ptr_conv;
16968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16969         this_ptr_conv.is_owned = false;
16970         LDKPublicKey val_ref;
16971         CHECK(*((uint32_t*)val) == 33);
16972         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16973         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
16974 }
16975
16976 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
16977         LDKAcceptChannel this_ptr_conv;
16978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16979         this_ptr_conv.is_owned = false;
16980         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
16981         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
16982         return ret_arr;
16983 }
16984
16985 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
16986         LDKAcceptChannel this_ptr_conv;
16987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16988         this_ptr_conv.is_owned = false;
16989         LDKPublicKey val_ref;
16990         CHECK(*((uint32_t*)val) == 33);
16991         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
16992         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
16993 }
16994
16995 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
16996         LDKAcceptChannel this_ptr_conv;
16997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16998         this_ptr_conv.is_owned = false;
16999         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17000         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
17001         return ret_arr;
17002 }
17003
17004 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
17005         LDKAcceptChannel this_ptr_conv;
17006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17007         this_ptr_conv.is_owned = false;
17008         LDKPublicKey val_ref;
17009         CHECK(*((uint32_t*)val) == 33);
17010         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17011         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
17012 }
17013
17014 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
17015         LDKAcceptChannel this_ptr_conv;
17016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17017         this_ptr_conv.is_owned = false;
17018         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17019         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
17020         return ret_arr;
17021 }
17022
17023 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
17024         LDKAcceptChannel this_ptr_conv;
17025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17026         this_ptr_conv.is_owned = false;
17027         LDKPublicKey val_ref;
17028         CHECK(*((uint32_t*)val) == 33);
17029         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17030         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
17031 }
17032
17033 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
17034         LDKAcceptChannel this_ptr_conv;
17035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17036         this_ptr_conv.is_owned = false;
17037         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17038         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
17039         return ret_arr;
17040 }
17041
17042 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
17043         LDKAcceptChannel this_ptr_conv;
17044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17045         this_ptr_conv.is_owned = false;
17046         LDKPublicKey val_ref;
17047         CHECK(*((uint32_t*)val) == 33);
17048         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17049         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
17050 }
17051
17052 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
17053         LDKAcceptChannel this_ptr_conv;
17054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17055         this_ptr_conv.is_owned = false;
17056         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17057         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
17058         return ret_arr;
17059 }
17060
17061 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
17062         LDKAcceptChannel this_ptr_conv;
17063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17064         this_ptr_conv.is_owned = false;
17065         LDKPublicKey val_ref;
17066         CHECK(*((uint32_t*)val) == 33);
17067         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17068         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
17069 }
17070
17071 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
17072         LDKAcceptChannel orig_conv;
17073         orig_conv.inner = (void*)(orig & (~1));
17074         orig_conv.is_owned = false;
17075         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
17076         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17077         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17078         uint64_t ret_ref = (uint64_t)ret_var.inner;
17079         if (ret_var.is_owned) {
17080                 ret_ref |= 1;
17081         }
17082         return ret_ref;
17083 }
17084
17085 void  __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_obj) {
17086         LDKFundingCreated this_obj_conv;
17087         this_obj_conv.inner = (void*)(this_obj & (~1));
17088         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17089         FundingCreated_free(this_obj_conv);
17090 }
17091
17092 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
17093         LDKFundingCreated this_ptr_conv;
17094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17095         this_ptr_conv.is_owned = false;
17096         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17097         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
17098         return ret_arr;
17099 }
17100
17101 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
17102         LDKFundingCreated this_ptr_conv;
17103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17104         this_ptr_conv.is_owned = false;
17105         LDKThirtyTwoBytes val_ref;
17106         CHECK(*((uint32_t*)val) == 32);
17107         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17108         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
17109 }
17110
17111 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
17112         LDKFundingCreated this_ptr_conv;
17113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17114         this_ptr_conv.is_owned = false;
17115         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17116         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
17117         return ret_arr;
17118 }
17119
17120 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
17121         LDKFundingCreated this_ptr_conv;
17122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17123         this_ptr_conv.is_owned = false;
17124         LDKThirtyTwoBytes val_ref;
17125         CHECK(*((uint32_t*)val) == 32);
17126         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17127         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
17128 }
17129
17130 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
17131         LDKFundingCreated this_ptr_conv;
17132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17133         this_ptr_conv.is_owned = false;
17134         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
17135         return ret_val;
17136 }
17137
17138 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
17139         LDKFundingCreated this_ptr_conv;
17140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17141         this_ptr_conv.is_owned = false;
17142         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
17143 }
17144
17145 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
17146         LDKFundingCreated this_ptr_conv;
17147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17148         this_ptr_conv.is_owned = false;
17149         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17150         memcpy((uint8_t*)(ret_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
17151         return ret_arr;
17152 }
17153
17154 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
17155         LDKFundingCreated this_ptr_conv;
17156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17157         this_ptr_conv.is_owned = false;
17158         LDKSignature val_ref;
17159         CHECK(*((uint32_t*)val) == 64);
17160         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17161         FundingCreated_set_signature(&this_ptr_conv, val_ref);
17162 }
17163
17164 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) {
17165         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
17166         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
17167         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
17168         LDKThirtyTwoBytes funding_txid_arg_ref;
17169         CHECK(*((uint32_t*)funding_txid_arg) == 32);
17170         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
17171         LDKSignature signature_arg_ref;
17172         CHECK(*((uint32_t*)signature_arg) == 64);
17173         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
17174         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
17175         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17176         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17177         uint64_t ret_ref = (uint64_t)ret_var.inner;
17178         if (ret_var.is_owned) {
17179                 ret_ref |= 1;
17180         }
17181         return ret_ref;
17182 }
17183
17184 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
17185         LDKFundingCreated orig_conv;
17186         orig_conv.inner = (void*)(orig & (~1));
17187         orig_conv.is_owned = false;
17188         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
17189         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17190         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17191         uint64_t ret_ref = (uint64_t)ret_var.inner;
17192         if (ret_var.is_owned) {
17193                 ret_ref |= 1;
17194         }
17195         return ret_ref;
17196 }
17197
17198 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_obj) {
17199         LDKFundingSigned this_obj_conv;
17200         this_obj_conv.inner = (void*)(this_obj & (~1));
17201         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17202         FundingSigned_free(this_obj_conv);
17203 }
17204
17205 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
17206         LDKFundingSigned this_ptr_conv;
17207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17208         this_ptr_conv.is_owned = false;
17209         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17210         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
17211         return ret_arr;
17212 }
17213
17214 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17215         LDKFundingSigned this_ptr_conv;
17216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17217         this_ptr_conv.is_owned = false;
17218         LDKThirtyTwoBytes val_ref;
17219         CHECK(*((uint32_t*)val) == 32);
17220         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17221         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
17222 }
17223
17224 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
17225         LDKFundingSigned this_ptr_conv;
17226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17227         this_ptr_conv.is_owned = false;
17228         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17229         memcpy((uint8_t*)(ret_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
17230         return ret_arr;
17231 }
17232
17233 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
17234         LDKFundingSigned this_ptr_conv;
17235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17236         this_ptr_conv.is_owned = false;
17237         LDKSignature val_ref;
17238         CHECK(*((uint32_t*)val) == 64);
17239         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17240         FundingSigned_set_signature(&this_ptr_conv, val_ref);
17241 }
17242
17243 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
17244         LDKThirtyTwoBytes channel_id_arg_ref;
17245         CHECK(*((uint32_t*)channel_id_arg) == 32);
17246         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17247         LDKSignature signature_arg_ref;
17248         CHECK(*((uint32_t*)signature_arg) == 64);
17249         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
17250         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
17251         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17252         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17253         uint64_t ret_ref = (uint64_t)ret_var.inner;
17254         if (ret_var.is_owned) {
17255                 ret_ref |= 1;
17256         }
17257         return ret_ref;
17258 }
17259
17260 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
17261         LDKFundingSigned orig_conv;
17262         orig_conv.inner = (void*)(orig & (~1));
17263         orig_conv.is_owned = false;
17264         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
17265         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17266         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17267         uint64_t ret_ref = (uint64_t)ret_var.inner;
17268         if (ret_var.is_owned) {
17269                 ret_ref |= 1;
17270         }
17271         return ret_ref;
17272 }
17273
17274 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_obj) {
17275         LDKFundingLocked this_obj_conv;
17276         this_obj_conv.inner = (void*)(this_obj & (~1));
17277         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17278         FundingLocked_free(this_obj_conv);
17279 }
17280
17281 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
17282         LDKFundingLocked this_ptr_conv;
17283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17284         this_ptr_conv.is_owned = false;
17285         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17286         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
17287         return ret_arr;
17288 }
17289
17290 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17291         LDKFundingLocked this_ptr_conv;
17292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17293         this_ptr_conv.is_owned = false;
17294         LDKThirtyTwoBytes val_ref;
17295         CHECK(*((uint32_t*)val) == 32);
17296         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17297         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
17298 }
17299
17300 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
17301         LDKFundingLocked this_ptr_conv;
17302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17303         this_ptr_conv.is_owned = false;
17304         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
17305         memcpy((uint8_t*)(ret_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
17306         return ret_arr;
17307 }
17308
17309 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
17310         LDKFundingLocked this_ptr_conv;
17311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17312         this_ptr_conv.is_owned = false;
17313         LDKPublicKey val_ref;
17314         CHECK(*((uint32_t*)val) == 33);
17315         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
17316         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
17317 }
17318
17319 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
17320         LDKThirtyTwoBytes channel_id_arg_ref;
17321         CHECK(*((uint32_t*)channel_id_arg) == 32);
17322         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17323         LDKPublicKey next_per_commitment_point_arg_ref;
17324         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
17325         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
17326         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
17327         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17328         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17329         uint64_t ret_ref = (uint64_t)ret_var.inner;
17330         if (ret_var.is_owned) {
17331                 ret_ref |= 1;
17332         }
17333         return ret_ref;
17334 }
17335
17336 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
17337         LDKFundingLocked orig_conv;
17338         orig_conv.inner = (void*)(orig & (~1));
17339         orig_conv.is_owned = false;
17340         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
17341         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17342         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17343         uint64_t ret_ref = (uint64_t)ret_var.inner;
17344         if (ret_var.is_owned) {
17345                 ret_ref |= 1;
17346         }
17347         return ret_ref;
17348 }
17349
17350 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_obj) {
17351         LDKShutdown this_obj_conv;
17352         this_obj_conv.inner = (void*)(this_obj & (~1));
17353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17354         Shutdown_free(this_obj_conv);
17355 }
17356
17357 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
17358         LDKShutdown this_ptr_conv;
17359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17360         this_ptr_conv.is_owned = false;
17361         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17362         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
17363         return ret_arr;
17364 }
17365
17366 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17367         LDKShutdown this_ptr_conv;
17368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17369         this_ptr_conv.is_owned = false;
17370         LDKThirtyTwoBytes val_ref;
17371         CHECK(*((uint32_t*)val) == 32);
17372         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17373         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
17374 }
17375
17376 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
17377         LDKShutdown this_ptr_conv;
17378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17379         this_ptr_conv.is_owned = false;
17380         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
17381         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
17382         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
17383         return ret_arr;
17384 }
17385
17386 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
17387         LDKShutdown this_ptr_conv;
17388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17389         this_ptr_conv.is_owned = false;
17390         LDKCVec_u8Z val_ref;
17391         val_ref.datalen = *((uint32_t*)val);
17392         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
17393         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
17394         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
17395 }
17396
17397 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
17398         LDKThirtyTwoBytes channel_id_arg_ref;
17399         CHECK(*((uint32_t*)channel_id_arg) == 32);
17400         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17401         LDKCVec_u8Z scriptpubkey_arg_ref;
17402         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
17403         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
17404         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
17405         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
17406         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17407         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17408         uint64_t ret_ref = (uint64_t)ret_var.inner;
17409         if (ret_var.is_owned) {
17410                 ret_ref |= 1;
17411         }
17412         return ret_ref;
17413 }
17414
17415 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
17416         LDKShutdown orig_conv;
17417         orig_conv.inner = (void*)(orig & (~1));
17418         orig_conv.is_owned = false;
17419         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
17420         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17421         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17422         uint64_t ret_ref = (uint64_t)ret_var.inner;
17423         if (ret_var.is_owned) {
17424                 ret_ref |= 1;
17425         }
17426         return ret_ref;
17427 }
17428
17429 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
17430         LDKClosingSignedFeeRange this_obj_conv;
17431         this_obj_conv.inner = (void*)(this_obj & (~1));
17432         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17433         ClosingSignedFeeRange_free(this_obj_conv);
17434 }
17435
17436 int64_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
17437         LDKClosingSignedFeeRange this_ptr_conv;
17438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17439         this_ptr_conv.is_owned = false;
17440         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
17441         return ret_val;
17442 }
17443
17444 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
17445         LDKClosingSignedFeeRange this_ptr_conv;
17446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17447         this_ptr_conv.is_owned = false;
17448         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
17449 }
17450
17451 int64_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
17452         LDKClosingSignedFeeRange this_ptr_conv;
17453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17454         this_ptr_conv.is_owned = false;
17455         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
17456         return ret_val;
17457 }
17458
17459 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
17460         LDKClosingSignedFeeRange this_ptr_conv;
17461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17462         this_ptr_conv.is_owned = false;
17463         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
17464 }
17465
17466 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
17467         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
17468         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17469         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17470         uint64_t ret_ref = (uint64_t)ret_var.inner;
17471         if (ret_var.is_owned) {
17472                 ret_ref |= 1;
17473         }
17474         return ret_ref;
17475 }
17476
17477 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
17478         LDKClosingSignedFeeRange orig_conv;
17479         orig_conv.inner = (void*)(orig & (~1));
17480         orig_conv.is_owned = false;
17481         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
17482         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17483         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17484         uint64_t ret_ref = (uint64_t)ret_var.inner;
17485         if (ret_var.is_owned) {
17486                 ret_ref |= 1;
17487         }
17488         return ret_ref;
17489 }
17490
17491 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_obj) {
17492         LDKClosingSigned this_obj_conv;
17493         this_obj_conv.inner = (void*)(this_obj & (~1));
17494         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17495         ClosingSigned_free(this_obj_conv);
17496 }
17497
17498 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
17499         LDKClosingSigned this_ptr_conv;
17500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17501         this_ptr_conv.is_owned = false;
17502         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17503         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
17504         return ret_arr;
17505 }
17506
17507 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17508         LDKClosingSigned this_ptr_conv;
17509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17510         this_ptr_conv.is_owned = false;
17511         LDKThirtyTwoBytes val_ref;
17512         CHECK(*((uint32_t*)val) == 32);
17513         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17514         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
17515 }
17516
17517 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
17518         LDKClosingSigned this_ptr_conv;
17519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17520         this_ptr_conv.is_owned = false;
17521         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
17522         return ret_val;
17523 }
17524
17525 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
17526         LDKClosingSigned this_ptr_conv;
17527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17528         this_ptr_conv.is_owned = false;
17529         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
17530 }
17531
17532 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
17533         LDKClosingSigned this_ptr_conv;
17534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17535         this_ptr_conv.is_owned = false;
17536         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17537         memcpy((uint8_t*)(ret_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
17538         return ret_arr;
17539 }
17540
17541 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
17542         LDKClosingSigned this_ptr_conv;
17543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17544         this_ptr_conv.is_owned = false;
17545         LDKSignature val_ref;
17546         CHECK(*((uint32_t*)val) == 64);
17547         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17548         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
17549 }
17550
17551 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
17552         LDKClosingSigned this_ptr_conv;
17553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17554         this_ptr_conv.is_owned = false;
17555         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
17556         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17557         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17558         uint64_t ret_ref = (uint64_t)ret_var.inner;
17559         if (ret_var.is_owned) {
17560                 ret_ref |= 1;
17561         }
17562         return ret_ref;
17563 }
17564
17565 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
17566         LDKClosingSigned this_ptr_conv;
17567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17568         this_ptr_conv.is_owned = false;
17569         LDKClosingSignedFeeRange val_conv;
17570         val_conv.inner = (void*)(val & (~1));
17571         val_conv.is_owned = (val & 1) || (val == 0);
17572         val_conv = ClosingSignedFeeRange_clone(&val_conv);
17573         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
17574 }
17575
17576 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) {
17577         LDKThirtyTwoBytes channel_id_arg_ref;
17578         CHECK(*((uint32_t*)channel_id_arg) == 32);
17579         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17580         LDKSignature signature_arg_ref;
17581         CHECK(*((uint32_t*)signature_arg) == 64);
17582         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
17583         LDKClosingSignedFeeRange fee_range_arg_conv;
17584         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
17585         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
17586         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
17587         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
17588         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17589         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17590         uint64_t ret_ref = (uint64_t)ret_var.inner;
17591         if (ret_var.is_owned) {
17592                 ret_ref |= 1;
17593         }
17594         return ret_ref;
17595 }
17596
17597 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
17598         LDKClosingSigned orig_conv;
17599         orig_conv.inner = (void*)(orig & (~1));
17600         orig_conv.is_owned = false;
17601         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
17602         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17603         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17604         uint64_t ret_ref = (uint64_t)ret_var.inner;
17605         if (ret_var.is_owned) {
17606                 ret_ref |= 1;
17607         }
17608         return ret_ref;
17609 }
17610
17611 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
17612         LDKUpdateAddHTLC this_obj_conv;
17613         this_obj_conv.inner = (void*)(this_obj & (~1));
17614         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17615         UpdateAddHTLC_free(this_obj_conv);
17616 }
17617
17618 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
17619         LDKUpdateAddHTLC this_ptr_conv;
17620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17621         this_ptr_conv.is_owned = false;
17622         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17623         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
17624         return ret_arr;
17625 }
17626
17627 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17628         LDKUpdateAddHTLC this_ptr_conv;
17629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17630         this_ptr_conv.is_owned = false;
17631         LDKThirtyTwoBytes val_ref;
17632         CHECK(*((uint32_t*)val) == 32);
17633         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17634         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
17635 }
17636
17637 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
17638         LDKUpdateAddHTLC this_ptr_conv;
17639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17640         this_ptr_conv.is_owned = false;
17641         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
17642         return ret_val;
17643 }
17644
17645 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
17646         LDKUpdateAddHTLC this_ptr_conv;
17647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17648         this_ptr_conv.is_owned = false;
17649         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
17650 }
17651
17652 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
17653         LDKUpdateAddHTLC this_ptr_conv;
17654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17655         this_ptr_conv.is_owned = false;
17656         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
17657         return ret_val;
17658 }
17659
17660 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
17661         LDKUpdateAddHTLC this_ptr_conv;
17662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17663         this_ptr_conv.is_owned = false;
17664         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
17665 }
17666
17667 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
17668         LDKUpdateAddHTLC this_ptr_conv;
17669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17670         this_ptr_conv.is_owned = false;
17671         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17672         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
17673         return ret_arr;
17674 }
17675
17676 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
17677         LDKUpdateAddHTLC this_ptr_conv;
17678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17679         this_ptr_conv.is_owned = false;
17680         LDKThirtyTwoBytes val_ref;
17681         CHECK(*((uint32_t*)val) == 32);
17682         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17683         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
17684 }
17685
17686 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
17687         LDKUpdateAddHTLC this_ptr_conv;
17688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17689         this_ptr_conv.is_owned = false;
17690         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
17691         return ret_val;
17692 }
17693
17694 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
17695         LDKUpdateAddHTLC this_ptr_conv;
17696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17697         this_ptr_conv.is_owned = false;
17698         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
17699 }
17700
17701 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
17702         LDKUpdateAddHTLC orig_conv;
17703         orig_conv.inner = (void*)(orig & (~1));
17704         orig_conv.is_owned = false;
17705         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
17706         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17707         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17708         uint64_t ret_ref = (uint64_t)ret_var.inner;
17709         if (ret_var.is_owned) {
17710                 ret_ref |= 1;
17711         }
17712         return ret_ref;
17713 }
17714
17715 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
17716         LDKUpdateFulfillHTLC this_obj_conv;
17717         this_obj_conv.inner = (void*)(this_obj & (~1));
17718         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17719         UpdateFulfillHTLC_free(this_obj_conv);
17720 }
17721
17722 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
17723         LDKUpdateFulfillHTLC this_ptr_conv;
17724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17725         this_ptr_conv.is_owned = false;
17726         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17727         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
17728         return ret_arr;
17729 }
17730
17731 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17732         LDKUpdateFulfillHTLC this_ptr_conv;
17733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17734         this_ptr_conv.is_owned = false;
17735         LDKThirtyTwoBytes val_ref;
17736         CHECK(*((uint32_t*)val) == 32);
17737         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17738         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
17739 }
17740
17741 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
17742         LDKUpdateFulfillHTLC this_ptr_conv;
17743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17744         this_ptr_conv.is_owned = false;
17745         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
17746         return ret_val;
17747 }
17748
17749 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
17750         LDKUpdateFulfillHTLC this_ptr_conv;
17751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17752         this_ptr_conv.is_owned = false;
17753         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
17754 }
17755
17756 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
17757         LDKUpdateFulfillHTLC this_ptr_conv;
17758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17759         this_ptr_conv.is_owned = false;
17760         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17761         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
17762         return ret_arr;
17763 }
17764
17765 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
17766         LDKUpdateFulfillHTLC this_ptr_conv;
17767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17768         this_ptr_conv.is_owned = false;
17769         LDKThirtyTwoBytes val_ref;
17770         CHECK(*((uint32_t*)val) == 32);
17771         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17772         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
17773 }
17774
17775 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
17776         LDKThirtyTwoBytes channel_id_arg_ref;
17777         CHECK(*((uint32_t*)channel_id_arg) == 32);
17778         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
17779         LDKThirtyTwoBytes payment_preimage_arg_ref;
17780         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
17781         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
17782         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
17783         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17784         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17785         uint64_t ret_ref = (uint64_t)ret_var.inner;
17786         if (ret_var.is_owned) {
17787                 ret_ref |= 1;
17788         }
17789         return ret_ref;
17790 }
17791
17792 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
17793         LDKUpdateFulfillHTLC orig_conv;
17794         orig_conv.inner = (void*)(orig & (~1));
17795         orig_conv.is_owned = false;
17796         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
17797         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17798         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17799         uint64_t ret_ref = (uint64_t)ret_var.inner;
17800         if (ret_var.is_owned) {
17801                 ret_ref |= 1;
17802         }
17803         return ret_ref;
17804 }
17805
17806 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
17807         LDKUpdateFailHTLC this_obj_conv;
17808         this_obj_conv.inner = (void*)(this_obj & (~1));
17809         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17810         UpdateFailHTLC_free(this_obj_conv);
17811 }
17812
17813 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
17814         LDKUpdateFailHTLC this_ptr_conv;
17815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17816         this_ptr_conv.is_owned = false;
17817         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17818         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
17819         return ret_arr;
17820 }
17821
17822 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17823         LDKUpdateFailHTLC this_ptr_conv;
17824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17825         this_ptr_conv.is_owned = false;
17826         LDKThirtyTwoBytes val_ref;
17827         CHECK(*((uint32_t*)val) == 32);
17828         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17829         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
17830 }
17831
17832 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
17833         LDKUpdateFailHTLC this_ptr_conv;
17834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17835         this_ptr_conv.is_owned = false;
17836         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
17837         return ret_val;
17838 }
17839
17840 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
17841         LDKUpdateFailHTLC this_ptr_conv;
17842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17843         this_ptr_conv.is_owned = false;
17844         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
17845 }
17846
17847 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
17848         LDKUpdateFailHTLC orig_conv;
17849         orig_conv.inner = (void*)(orig & (~1));
17850         orig_conv.is_owned = false;
17851         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
17852         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17853         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17854         uint64_t ret_ref = (uint64_t)ret_var.inner;
17855         if (ret_var.is_owned) {
17856                 ret_ref |= 1;
17857         }
17858         return ret_ref;
17859 }
17860
17861 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
17862         LDKUpdateFailMalformedHTLC this_obj_conv;
17863         this_obj_conv.inner = (void*)(this_obj & (~1));
17864         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17865         UpdateFailMalformedHTLC_free(this_obj_conv);
17866 }
17867
17868 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
17869         LDKUpdateFailMalformedHTLC this_ptr_conv;
17870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17871         this_ptr_conv.is_owned = false;
17872         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17873         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
17874         return ret_arr;
17875 }
17876
17877 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17878         LDKUpdateFailMalformedHTLC this_ptr_conv;
17879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17880         this_ptr_conv.is_owned = false;
17881         LDKThirtyTwoBytes val_ref;
17882         CHECK(*((uint32_t*)val) == 32);
17883         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17884         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
17885 }
17886
17887 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
17888         LDKUpdateFailMalformedHTLC this_ptr_conv;
17889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17890         this_ptr_conv.is_owned = false;
17891         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
17892         return ret_val;
17893 }
17894
17895 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
17896         LDKUpdateFailMalformedHTLC this_ptr_conv;
17897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17898         this_ptr_conv.is_owned = false;
17899         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
17900 }
17901
17902 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
17903         LDKUpdateFailMalformedHTLC this_ptr_conv;
17904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17905         this_ptr_conv.is_owned = false;
17906         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
17907         return ret_val;
17908 }
17909
17910 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
17911         LDKUpdateFailMalformedHTLC this_ptr_conv;
17912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17913         this_ptr_conv.is_owned = false;
17914         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
17915 }
17916
17917 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
17918         LDKUpdateFailMalformedHTLC orig_conv;
17919         orig_conv.inner = (void*)(orig & (~1));
17920         orig_conv.is_owned = false;
17921         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
17922         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17923         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17924         uint64_t ret_ref = (uint64_t)ret_var.inner;
17925         if (ret_var.is_owned) {
17926                 ret_ref |= 1;
17927         }
17928         return ret_ref;
17929 }
17930
17931 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_obj) {
17932         LDKCommitmentSigned this_obj_conv;
17933         this_obj_conv.inner = (void*)(this_obj & (~1));
17934         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17935         CommitmentSigned_free(this_obj_conv);
17936 }
17937
17938 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
17939         LDKCommitmentSigned this_ptr_conv;
17940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17941         this_ptr_conv.is_owned = false;
17942         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
17943         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
17944         return ret_arr;
17945 }
17946
17947 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
17948         LDKCommitmentSigned this_ptr_conv;
17949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17950         this_ptr_conv.is_owned = false;
17951         LDKThirtyTwoBytes val_ref;
17952         CHECK(*((uint32_t*)val) == 32);
17953         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
17954         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
17955 }
17956
17957 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
17958         LDKCommitmentSigned this_ptr_conv;
17959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17960         this_ptr_conv.is_owned = false;
17961         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
17962         memcpy((uint8_t*)(ret_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
17963         return ret_arr;
17964 }
17965
17966 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
17967         LDKCommitmentSigned this_ptr_conv;
17968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17969         this_ptr_conv.is_owned = false;
17970         LDKSignature val_ref;
17971         CHECK(*((uint32_t*)val) == 64);
17972         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
17973         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
17974 }
17975
17976 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
17977         LDKCommitmentSigned this_ptr_conv;
17978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17979         this_ptr_conv.is_owned = false;
17980         LDKCVec_SignatureZ val_constr;
17981         val_constr.datalen = *((uint32_t*)val);
17982         if (val_constr.datalen > 0)
17983                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
17984         else
17985                 val_constr.data = NULL;
17986         int8_tArray* val_vals = (int8_tArray*)(val + 4);
17987         for (size_t m = 0; m < val_constr.datalen; m++) {
17988                 int8_tArray val_conv_12 = val_vals[m];
17989                 LDKSignature val_conv_12_ref;
17990                 CHECK(*((uint32_t*)val_conv_12) == 64);
17991                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
17992                 val_constr.data[m] = val_conv_12_ref;
17993         }
17994         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
17995 }
17996
17997 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
17998         LDKThirtyTwoBytes channel_id_arg_ref;
17999         CHECK(*((uint32_t*)channel_id_arg) == 32);
18000         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
18001         LDKSignature signature_arg_ref;
18002         CHECK(*((uint32_t*)signature_arg) == 64);
18003         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
18004         LDKCVec_SignatureZ htlc_signatures_arg_constr;
18005         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
18006         if (htlc_signatures_arg_constr.datalen > 0)
18007                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18008         else
18009                 htlc_signatures_arg_constr.data = NULL;
18010         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
18011         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
18012                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
18013                 LDKSignature htlc_signatures_arg_conv_12_ref;
18014                 CHECK(*((uint32_t*)htlc_signatures_arg_conv_12) == 64);
18015                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, (uint8_t*)(htlc_signatures_arg_conv_12 + 4), 64);
18016                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
18017         }
18018         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
18019         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18020         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18021         uint64_t ret_ref = (uint64_t)ret_var.inner;
18022         if (ret_var.is_owned) {
18023                 ret_ref |= 1;
18024         }
18025         return ret_ref;
18026 }
18027
18028 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
18029         LDKCommitmentSigned orig_conv;
18030         orig_conv.inner = (void*)(orig & (~1));
18031         orig_conv.is_owned = false;
18032         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
18033         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18034         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18035         uint64_t ret_ref = (uint64_t)ret_var.inner;
18036         if (ret_var.is_owned) {
18037                 ret_ref |= 1;
18038         }
18039         return ret_ref;
18040 }
18041
18042 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_obj) {
18043         LDKRevokeAndACK this_obj_conv;
18044         this_obj_conv.inner = (void*)(this_obj & (~1));
18045         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18046         RevokeAndACK_free(this_obj_conv);
18047 }
18048
18049 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
18050         LDKRevokeAndACK this_ptr_conv;
18051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18052         this_ptr_conv.is_owned = false;
18053         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18054         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
18055         return ret_arr;
18056 }
18057
18058 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18059         LDKRevokeAndACK this_ptr_conv;
18060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18061         this_ptr_conv.is_owned = false;
18062         LDKThirtyTwoBytes val_ref;
18063         CHECK(*((uint32_t*)val) == 32);
18064         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18065         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
18066 }
18067
18068 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
18069         LDKRevokeAndACK this_ptr_conv;
18070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18071         this_ptr_conv.is_owned = false;
18072         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18073         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
18074         return ret_arr;
18075 }
18076
18077 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
18078         LDKRevokeAndACK this_ptr_conv;
18079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18080         this_ptr_conv.is_owned = false;
18081         LDKThirtyTwoBytes val_ref;
18082         CHECK(*((uint32_t*)val) == 32);
18083         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18084         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
18085 }
18086
18087 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
18088         LDKRevokeAndACK this_ptr_conv;
18089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18090         this_ptr_conv.is_owned = false;
18091         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18092         memcpy((uint8_t*)(ret_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
18093         return ret_arr;
18094 }
18095
18096 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
18097         LDKRevokeAndACK this_ptr_conv;
18098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18099         this_ptr_conv.is_owned = false;
18100         LDKPublicKey val_ref;
18101         CHECK(*((uint32_t*)val) == 33);
18102         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18103         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
18104 }
18105
18106 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) {
18107         LDKThirtyTwoBytes channel_id_arg_ref;
18108         CHECK(*((uint32_t*)channel_id_arg) == 32);
18109         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
18110         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
18111         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
18112         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
18113         LDKPublicKey next_per_commitment_point_arg_ref;
18114         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
18115         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
18116         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
18117         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18118         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18119         uint64_t 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 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
18127         LDKRevokeAndACK orig_conv;
18128         orig_conv.inner = (void*)(orig & (~1));
18129         orig_conv.is_owned = false;
18130         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
18131         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18132         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18133         uint64_t ret_ref = (uint64_t)ret_var.inner;
18134         if (ret_var.is_owned) {
18135                 ret_ref |= 1;
18136         }
18137         return ret_ref;
18138 }
18139
18140 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_obj) {
18141         LDKUpdateFee this_obj_conv;
18142         this_obj_conv.inner = (void*)(this_obj & (~1));
18143         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18144         UpdateFee_free(this_obj_conv);
18145 }
18146
18147 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
18148         LDKUpdateFee this_ptr_conv;
18149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18150         this_ptr_conv.is_owned = false;
18151         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18152         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
18153         return ret_arr;
18154 }
18155
18156 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18157         LDKUpdateFee this_ptr_conv;
18158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18159         this_ptr_conv.is_owned = false;
18160         LDKThirtyTwoBytes val_ref;
18161         CHECK(*((uint32_t*)val) == 32);
18162         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18163         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
18164 }
18165
18166 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
18167         LDKUpdateFee this_ptr_conv;
18168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18169         this_ptr_conv.is_owned = false;
18170         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
18171         return ret_val;
18172 }
18173
18174 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
18175         LDKUpdateFee this_ptr_conv;
18176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18177         this_ptr_conv.is_owned = false;
18178         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
18179 }
18180
18181 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
18182         LDKThirtyTwoBytes channel_id_arg_ref;
18183         CHECK(*((uint32_t*)channel_id_arg) == 32);
18184         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
18185         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
18186         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18187         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18188         uint64_t ret_ref = (uint64_t)ret_var.inner;
18189         if (ret_var.is_owned) {
18190                 ret_ref |= 1;
18191         }
18192         return ret_ref;
18193 }
18194
18195 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
18196         LDKUpdateFee orig_conv;
18197         orig_conv.inner = (void*)(orig & (~1));
18198         orig_conv.is_owned = false;
18199         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
18200         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18201         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18202         uint64_t ret_ref = (uint64_t)ret_var.inner;
18203         if (ret_var.is_owned) {
18204                 ret_ref |= 1;
18205         }
18206         return ret_ref;
18207 }
18208
18209 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_obj) {
18210         LDKDataLossProtect this_obj_conv;
18211         this_obj_conv.inner = (void*)(this_obj & (~1));
18212         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18213         DataLossProtect_free(this_obj_conv);
18214 }
18215
18216 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
18217         LDKDataLossProtect this_ptr_conv;
18218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18219         this_ptr_conv.is_owned = false;
18220         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18221         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
18222         return ret_arr;
18223 }
18224
18225 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
18226         LDKDataLossProtect this_ptr_conv;
18227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18228         this_ptr_conv.is_owned = false;
18229         LDKThirtyTwoBytes val_ref;
18230         CHECK(*((uint32_t*)val) == 32);
18231         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18232         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
18233 }
18234
18235 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
18236         LDKDataLossProtect this_ptr_conv;
18237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18238         this_ptr_conv.is_owned = false;
18239         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18240         memcpy((uint8_t*)(ret_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
18241         return ret_arr;
18242 }
18243
18244 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
18245         LDKDataLossProtect this_ptr_conv;
18246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18247         this_ptr_conv.is_owned = false;
18248         LDKPublicKey val_ref;
18249         CHECK(*((uint32_t*)val) == 33);
18250         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18251         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
18252 }
18253
18254 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
18255         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
18256         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
18257         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
18258         LDKPublicKey my_current_per_commitment_point_arg_ref;
18259         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
18260         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
18261         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
18262         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18263         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18264         uint64_t ret_ref = (uint64_t)ret_var.inner;
18265         if (ret_var.is_owned) {
18266                 ret_ref |= 1;
18267         }
18268         return ret_ref;
18269 }
18270
18271 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
18272         LDKDataLossProtect orig_conv;
18273         orig_conv.inner = (void*)(orig & (~1));
18274         orig_conv.is_owned = false;
18275         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
18276         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18277         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18278         uint64_t ret_ref = (uint64_t)ret_var.inner;
18279         if (ret_var.is_owned) {
18280                 ret_ref |= 1;
18281         }
18282         return ret_ref;
18283 }
18284
18285 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_obj) {
18286         LDKChannelReestablish this_obj_conv;
18287         this_obj_conv.inner = (void*)(this_obj & (~1));
18288         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18289         ChannelReestablish_free(this_obj_conv);
18290 }
18291
18292 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
18293         LDKChannelReestablish this_ptr_conv;
18294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18295         this_ptr_conv.is_owned = false;
18296         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18297         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
18298         return ret_arr;
18299 }
18300
18301 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18302         LDKChannelReestablish this_ptr_conv;
18303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18304         this_ptr_conv.is_owned = false;
18305         LDKThirtyTwoBytes val_ref;
18306         CHECK(*((uint32_t*)val) == 32);
18307         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18308         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
18309 }
18310
18311 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
18312         LDKChannelReestablish this_ptr_conv;
18313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18314         this_ptr_conv.is_owned = false;
18315         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
18316         return ret_val;
18317 }
18318
18319 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
18320         LDKChannelReestablish this_ptr_conv;
18321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18322         this_ptr_conv.is_owned = false;
18323         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
18324 }
18325
18326 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
18327         LDKChannelReestablish this_ptr_conv;
18328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18329         this_ptr_conv.is_owned = false;
18330         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
18331         return ret_val;
18332 }
18333
18334 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
18335         LDKChannelReestablish this_ptr_conv;
18336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18337         this_ptr_conv.is_owned = false;
18338         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
18339 }
18340
18341 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
18342         LDKChannelReestablish orig_conv;
18343         orig_conv.inner = (void*)(orig & (~1));
18344         orig_conv.is_owned = false;
18345         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
18346         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18347         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18348         uint64_t ret_ref = (uint64_t)ret_var.inner;
18349         if (ret_var.is_owned) {
18350                 ret_ref |= 1;
18351         }
18352         return ret_ref;
18353 }
18354
18355 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
18356         LDKAnnouncementSignatures this_obj_conv;
18357         this_obj_conv.inner = (void*)(this_obj & (~1));
18358         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18359         AnnouncementSignatures_free(this_obj_conv);
18360 }
18361
18362 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
18363         LDKAnnouncementSignatures this_ptr_conv;
18364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18365         this_ptr_conv.is_owned = false;
18366         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18367         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
18368         return ret_arr;
18369 }
18370
18371 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
18372         LDKAnnouncementSignatures this_ptr_conv;
18373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18374         this_ptr_conv.is_owned = false;
18375         LDKThirtyTwoBytes val_ref;
18376         CHECK(*((uint32_t*)val) == 32);
18377         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18378         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
18379 }
18380
18381 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
18382         LDKAnnouncementSignatures this_ptr_conv;
18383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18384         this_ptr_conv.is_owned = false;
18385         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
18386         return ret_val;
18387 }
18388
18389 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
18390         LDKAnnouncementSignatures this_ptr_conv;
18391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18392         this_ptr_conv.is_owned = false;
18393         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
18394 }
18395
18396 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
18397         LDKAnnouncementSignatures this_ptr_conv;
18398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18399         this_ptr_conv.is_owned = false;
18400         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18401         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
18402         return ret_arr;
18403 }
18404
18405 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
18406         LDKAnnouncementSignatures this_ptr_conv;
18407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18408         this_ptr_conv.is_owned = false;
18409         LDKSignature val_ref;
18410         CHECK(*((uint32_t*)val) == 64);
18411         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
18412         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
18413 }
18414
18415 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
18416         LDKAnnouncementSignatures this_ptr_conv;
18417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18418         this_ptr_conv.is_owned = false;
18419         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18420         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
18421         return ret_arr;
18422 }
18423
18424 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
18425         LDKAnnouncementSignatures this_ptr_conv;
18426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18427         this_ptr_conv.is_owned = false;
18428         LDKSignature val_ref;
18429         CHECK(*((uint32_t*)val) == 64);
18430         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
18431         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
18432 }
18433
18434 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) {
18435         LDKThirtyTwoBytes channel_id_arg_ref;
18436         CHECK(*((uint32_t*)channel_id_arg) == 32);
18437         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
18438         LDKSignature node_signature_arg_ref;
18439         CHECK(*((uint32_t*)node_signature_arg) == 64);
18440         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
18441         LDKSignature bitcoin_signature_arg_ref;
18442         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
18443         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
18444         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
18445         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18446         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18447         uint64_t ret_ref = (uint64_t)ret_var.inner;
18448         if (ret_var.is_owned) {
18449                 ret_ref |= 1;
18450         }
18451         return ret_ref;
18452 }
18453
18454 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
18455         LDKAnnouncementSignatures orig_conv;
18456         orig_conv.inner = (void*)(orig & (~1));
18457         orig_conv.is_owned = false;
18458         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
18459         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18460         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18461         uint64_t 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 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
18469         if ((this_ptr & 1) != 0) return;
18470         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
18471         FREE((void*)this_ptr);
18472         NetAddress_free(this_ptr_conv);
18473 }
18474
18475 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
18476         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
18477         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
18478         *ret_copy = NetAddress_clone(orig_conv);
18479         uint64_t ret_ref = (uint64_t)ret_copy;
18480         return ret_ref;
18481 }
18482
18483 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
18484         LDKFourBytes addr_ref;
18485         CHECK(*((uint32_t*)addr) == 4);
18486         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 4);
18487         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
18488         *ret_copy = NetAddress_ipv4(addr_ref, port);
18489         uint64_t ret_ref = (uint64_t)ret_copy;
18490         return ret_ref;
18491 }
18492
18493 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
18494         LDKSixteenBytes addr_ref;
18495         CHECK(*((uint32_t*)addr) == 16);
18496         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 16);
18497         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
18498         *ret_copy = NetAddress_ipv6(addr_ref, port);
18499         uint64_t ret_ref = (uint64_t)ret_copy;
18500         return ret_ref;
18501 }
18502
18503 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_onion_v2(int8_tArray addr, int16_t port) {
18504         LDKTenBytes addr_ref;
18505         CHECK(*((uint32_t*)addr) == 10);
18506         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 10);
18507         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
18508         *ret_copy = NetAddress_onion_v2(addr_ref, port);
18509         uint64_t ret_ref = (uint64_t)ret_copy;
18510         return ret_ref;
18511 }
18512
18513 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_onion_v3(int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
18514         LDKThirtyTwoBytes ed25519_pubkey_ref;
18515         CHECK(*((uint32_t*)ed25519_pubkey) == 32);
18516         memcpy(ed25519_pubkey_ref.data, (uint8_t*)(ed25519_pubkey + 4), 32);
18517         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
18518         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
18519         uint64_t ret_ref = (uint64_t)ret_copy;
18520         return ret_ref;
18521 }
18522
18523 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
18524         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
18525         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
18526         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18527         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18528         CVec_u8Z_free(ret_var);
18529         return ret_arr;
18530 }
18531
18532 uint32_t  __attribute__((visibility("default"))) TS_Result_read(int8_tArray ser) {
18533         LDKu8slice ser_ref;
18534         ser_ref.datalen = *((uint32_t*)ser);
18535         ser_ref.data = (int8_t*)(ser + 4);
18536         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
18537         *ret_conv = Result_read(ser_ref);
18538         return (uint64_t)ret_conv;
18539 }
18540
18541 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_read(int8_tArray ser) {
18542         LDKu8slice ser_ref;
18543         ser_ref.datalen = *((uint32_t*)ser);
18544         ser_ref.data = (int8_t*)(ser + 4);
18545         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18546         *ret_conv = NetAddress_read(ser_ref);
18547         return (uint64_t)ret_conv;
18548 }
18549
18550 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
18551         LDKUnsignedNodeAnnouncement this_obj_conv;
18552         this_obj_conv.inner = (void*)(this_obj & (~1));
18553         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18554         UnsignedNodeAnnouncement_free(this_obj_conv);
18555 }
18556
18557 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
18558         LDKUnsignedNodeAnnouncement this_ptr_conv;
18559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18560         this_ptr_conv.is_owned = false;
18561         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
18562         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18563         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18564         uint64_t ret_ref = (uint64_t)ret_var.inner;
18565         if (ret_var.is_owned) {
18566                 ret_ref |= 1;
18567         }
18568         return ret_ref;
18569 }
18570
18571 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
18572         LDKUnsignedNodeAnnouncement this_ptr_conv;
18573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18574         this_ptr_conv.is_owned = false;
18575         LDKNodeFeatures val_conv;
18576         val_conv.inner = (void*)(val & (~1));
18577         val_conv.is_owned = (val & 1) || (val == 0);
18578         val_conv = NodeFeatures_clone(&val_conv);
18579         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
18580 }
18581
18582 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
18583         LDKUnsignedNodeAnnouncement this_ptr_conv;
18584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18585         this_ptr_conv.is_owned = false;
18586         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
18587         return ret_val;
18588 }
18589
18590 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
18591         LDKUnsignedNodeAnnouncement this_ptr_conv;
18592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18593         this_ptr_conv.is_owned = false;
18594         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
18595 }
18596
18597 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
18598         LDKUnsignedNodeAnnouncement this_ptr_conv;
18599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18600         this_ptr_conv.is_owned = false;
18601         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18602         memcpy((uint8_t*)(ret_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
18603         return ret_arr;
18604 }
18605
18606 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
18607         LDKUnsignedNodeAnnouncement this_ptr_conv;
18608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18609         this_ptr_conv.is_owned = false;
18610         LDKPublicKey val_ref;
18611         CHECK(*((uint32_t*)val) == 33);
18612         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18613         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
18614 }
18615
18616 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
18617         LDKUnsignedNodeAnnouncement this_ptr_conv;
18618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18619         this_ptr_conv.is_owned = false;
18620         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
18621         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
18622         return ret_arr;
18623 }
18624
18625 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
18626         LDKUnsignedNodeAnnouncement this_ptr_conv;
18627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18628         this_ptr_conv.is_owned = false;
18629         LDKThreeBytes val_ref;
18630         CHECK(*((uint32_t*)val) == 3);
18631         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
18632         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
18633 }
18634
18635 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
18636         LDKUnsignedNodeAnnouncement this_ptr_conv;
18637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18638         this_ptr_conv.is_owned = false;
18639         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18640         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
18641         return ret_arr;
18642 }
18643
18644 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
18645         LDKUnsignedNodeAnnouncement this_ptr_conv;
18646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18647         this_ptr_conv.is_owned = false;
18648         LDKThirtyTwoBytes val_ref;
18649         CHECK(*((uint32_t*)val) == 32);
18650         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18651         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
18652 }
18653
18654 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
18655         LDKUnsignedNodeAnnouncement this_ptr_conv;
18656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18657         this_ptr_conv.is_owned = false;
18658         LDKCVec_NetAddressZ val_constr;
18659         val_constr.datalen = *((uint32_t*)val);
18660         if (val_constr.datalen > 0)
18661                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18662         else
18663                 val_constr.data = NULL;
18664         uint32_t* val_vals = (uint32_t*)(val + 4);
18665         for (size_t m = 0; m < val_constr.datalen; m++) {
18666                 uint32_t val_conv_12 = val_vals[m];
18667                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
18668                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
18669                 val_constr.data[m] = val_conv_12_conv;
18670         }
18671         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
18672 }
18673
18674 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
18675         LDKUnsignedNodeAnnouncement orig_conv;
18676         orig_conv.inner = (void*)(orig & (~1));
18677         orig_conv.is_owned = false;
18678         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
18679         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18680         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18681         uint64_t ret_ref = (uint64_t)ret_var.inner;
18682         if (ret_var.is_owned) {
18683                 ret_ref |= 1;
18684         }
18685         return ret_ref;
18686 }
18687
18688 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
18689         LDKNodeAnnouncement this_obj_conv;
18690         this_obj_conv.inner = (void*)(this_obj & (~1));
18691         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18692         NodeAnnouncement_free(this_obj_conv);
18693 }
18694
18695 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
18696         LDKNodeAnnouncement this_ptr_conv;
18697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18698         this_ptr_conv.is_owned = false;
18699         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18700         memcpy((uint8_t*)(ret_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
18701         return ret_arr;
18702 }
18703
18704 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
18705         LDKNodeAnnouncement this_ptr_conv;
18706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18707         this_ptr_conv.is_owned = false;
18708         LDKSignature val_ref;
18709         CHECK(*((uint32_t*)val) == 64);
18710         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
18711         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
18712 }
18713
18714 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
18715         LDKNodeAnnouncement this_ptr_conv;
18716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18717         this_ptr_conv.is_owned = false;
18718         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
18719         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18720         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18721         uint64_t ret_ref = (uint64_t)ret_var.inner;
18722         if (ret_var.is_owned) {
18723                 ret_ref |= 1;
18724         }
18725         return ret_ref;
18726 }
18727
18728 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
18729         LDKNodeAnnouncement this_ptr_conv;
18730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18731         this_ptr_conv.is_owned = false;
18732         LDKUnsignedNodeAnnouncement val_conv;
18733         val_conv.inner = (void*)(val & (~1));
18734         val_conv.is_owned = (val & 1) || (val == 0);
18735         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
18736         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
18737 }
18738
18739 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
18740         LDKSignature signature_arg_ref;
18741         CHECK(*((uint32_t*)signature_arg) == 64);
18742         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
18743         LDKUnsignedNodeAnnouncement contents_arg_conv;
18744         contents_arg_conv.inner = (void*)(contents_arg & (~1));
18745         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
18746         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
18747         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
18748         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18749         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18750         uint64_t ret_ref = (uint64_t)ret_var.inner;
18751         if (ret_var.is_owned) {
18752                 ret_ref |= 1;
18753         }
18754         return ret_ref;
18755 }
18756
18757 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint32_t orig) {
18758         LDKNodeAnnouncement orig_conv;
18759         orig_conv.inner = (void*)(orig & (~1));
18760         orig_conv.is_owned = false;
18761         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
18762         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18763         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18764         uint64_t ret_ref = (uint64_t)ret_var.inner;
18765         if (ret_var.is_owned) {
18766                 ret_ref |= 1;
18767         }
18768         return ret_ref;
18769 }
18770
18771 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
18772         LDKUnsignedChannelAnnouncement this_obj_conv;
18773         this_obj_conv.inner = (void*)(this_obj & (~1));
18774         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18775         UnsignedChannelAnnouncement_free(this_obj_conv);
18776 }
18777
18778 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
18779         LDKUnsignedChannelAnnouncement this_ptr_conv;
18780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18781         this_ptr_conv.is_owned = false;
18782         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
18783         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18784         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18785         uint64_t ret_ref = (uint64_t)ret_var.inner;
18786         if (ret_var.is_owned) {
18787                 ret_ref |= 1;
18788         }
18789         return ret_ref;
18790 }
18791
18792 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
18793         LDKUnsignedChannelAnnouncement this_ptr_conv;
18794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18795         this_ptr_conv.is_owned = false;
18796         LDKChannelFeatures val_conv;
18797         val_conv.inner = (void*)(val & (~1));
18798         val_conv.is_owned = (val & 1) || (val == 0);
18799         val_conv = ChannelFeatures_clone(&val_conv);
18800         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
18801 }
18802
18803 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
18804         LDKUnsignedChannelAnnouncement this_ptr_conv;
18805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18806         this_ptr_conv.is_owned = false;
18807         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18808         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
18809         return ret_arr;
18810 }
18811
18812 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
18813         LDKUnsignedChannelAnnouncement this_ptr_conv;
18814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18815         this_ptr_conv.is_owned = false;
18816         LDKThirtyTwoBytes val_ref;
18817         CHECK(*((uint32_t*)val) == 32);
18818         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18819         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
18820 }
18821
18822 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
18823         LDKUnsignedChannelAnnouncement this_ptr_conv;
18824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18825         this_ptr_conv.is_owned = false;
18826         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
18827         return ret_val;
18828 }
18829
18830 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
18831         LDKUnsignedChannelAnnouncement this_ptr_conv;
18832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18833         this_ptr_conv.is_owned = false;
18834         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
18835 }
18836
18837 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
18838         LDKUnsignedChannelAnnouncement this_ptr_conv;
18839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18840         this_ptr_conv.is_owned = false;
18841         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18842         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
18843         return ret_arr;
18844 }
18845
18846 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
18847         LDKUnsignedChannelAnnouncement this_ptr_conv;
18848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18849         this_ptr_conv.is_owned = false;
18850         LDKPublicKey val_ref;
18851         CHECK(*((uint32_t*)val) == 33);
18852         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18853         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
18854 }
18855
18856 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
18857         LDKUnsignedChannelAnnouncement this_ptr_conv;
18858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18859         this_ptr_conv.is_owned = false;
18860         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18861         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
18862         return ret_arr;
18863 }
18864
18865 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
18866         LDKUnsignedChannelAnnouncement this_ptr_conv;
18867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18868         this_ptr_conv.is_owned = false;
18869         LDKPublicKey val_ref;
18870         CHECK(*((uint32_t*)val) == 33);
18871         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18872         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
18873 }
18874
18875 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
18876         LDKUnsignedChannelAnnouncement this_ptr_conv;
18877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18878         this_ptr_conv.is_owned = false;
18879         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18880         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
18881         return ret_arr;
18882 }
18883
18884 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
18885         LDKUnsignedChannelAnnouncement this_ptr_conv;
18886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18887         this_ptr_conv.is_owned = false;
18888         LDKPublicKey val_ref;
18889         CHECK(*((uint32_t*)val) == 33);
18890         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18891         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
18892 }
18893
18894 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
18895         LDKUnsignedChannelAnnouncement this_ptr_conv;
18896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18897         this_ptr_conv.is_owned = false;
18898         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
18899         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
18900         return ret_arr;
18901 }
18902
18903 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
18904         LDKUnsignedChannelAnnouncement this_ptr_conv;
18905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18906         this_ptr_conv.is_owned = false;
18907         LDKPublicKey val_ref;
18908         CHECK(*((uint32_t*)val) == 33);
18909         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
18910         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
18911 }
18912
18913 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
18914         LDKUnsignedChannelAnnouncement orig_conv;
18915         orig_conv.inner = (void*)(orig & (~1));
18916         orig_conv.is_owned = false;
18917         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
18918         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18919         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18920         uint64_t ret_ref = (uint64_t)ret_var.inner;
18921         if (ret_var.is_owned) {
18922                 ret_ref |= 1;
18923         }
18924         return ret_ref;
18925 }
18926
18927 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
18928         LDKChannelAnnouncement this_obj_conv;
18929         this_obj_conv.inner = (void*)(this_obj & (~1));
18930         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18931         ChannelAnnouncement_free(this_obj_conv);
18932 }
18933
18934 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
18935         LDKChannelAnnouncement this_ptr_conv;
18936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18937         this_ptr_conv.is_owned = false;
18938         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18939         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
18940         return ret_arr;
18941 }
18942
18943 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
18944         LDKChannelAnnouncement this_ptr_conv;
18945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18946         this_ptr_conv.is_owned = false;
18947         LDKSignature val_ref;
18948         CHECK(*((uint32_t*)val) == 64);
18949         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
18950         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
18951 }
18952
18953 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
18954         LDKChannelAnnouncement this_ptr_conv;
18955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18956         this_ptr_conv.is_owned = false;
18957         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18958         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
18959         return ret_arr;
18960 }
18961
18962 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
18963         LDKChannelAnnouncement this_ptr_conv;
18964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18965         this_ptr_conv.is_owned = false;
18966         LDKSignature val_ref;
18967         CHECK(*((uint32_t*)val) == 64);
18968         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
18969         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
18970 }
18971
18972 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
18973         LDKChannelAnnouncement this_ptr_conv;
18974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18975         this_ptr_conv.is_owned = false;
18976         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18977         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
18978         return ret_arr;
18979 }
18980
18981 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
18982         LDKChannelAnnouncement this_ptr_conv;
18983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18984         this_ptr_conv.is_owned = false;
18985         LDKSignature val_ref;
18986         CHECK(*((uint32_t*)val) == 64);
18987         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
18988         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
18989 }
18990
18991 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
18992         LDKChannelAnnouncement this_ptr_conv;
18993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18994         this_ptr_conv.is_owned = false;
18995         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
18996         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
18997         return ret_arr;
18998 }
18999
19000 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
19001         LDKChannelAnnouncement this_ptr_conv;
19002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19003         this_ptr_conv.is_owned = false;
19004         LDKSignature val_ref;
19005         CHECK(*((uint32_t*)val) == 64);
19006         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19007         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
19008 }
19009
19010 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
19011         LDKChannelAnnouncement this_ptr_conv;
19012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19013         this_ptr_conv.is_owned = false;
19014         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
19015         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19016         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19017         uint64_t ret_ref = (uint64_t)ret_var.inner;
19018         if (ret_var.is_owned) {
19019                 ret_ref |= 1;
19020         }
19021         return ret_ref;
19022 }
19023
19024 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
19025         LDKChannelAnnouncement this_ptr_conv;
19026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19027         this_ptr_conv.is_owned = false;
19028         LDKUnsignedChannelAnnouncement val_conv;
19029         val_conv.inner = (void*)(val & (~1));
19030         val_conv.is_owned = (val & 1) || (val == 0);
19031         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
19032         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
19033 }
19034
19035 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) {
19036         LDKSignature node_signature_1_arg_ref;
19037         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
19038         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
19039         LDKSignature node_signature_2_arg_ref;
19040         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
19041         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
19042         LDKSignature bitcoin_signature_1_arg_ref;
19043         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
19044         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
19045         LDKSignature bitcoin_signature_2_arg_ref;
19046         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
19047         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
19048         LDKUnsignedChannelAnnouncement contents_arg_conv;
19049         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19050         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19051         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
19052         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);
19053         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19054         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19055         uint64_t ret_ref = (uint64_t)ret_var.inner;
19056         if (ret_var.is_owned) {
19057                 ret_ref |= 1;
19058         }
19059         return ret_ref;
19060 }
19061
19062 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
19063         LDKChannelAnnouncement orig_conv;
19064         orig_conv.inner = (void*)(orig & (~1));
19065         orig_conv.is_owned = false;
19066         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
19067         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19068         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19069         uint64_t ret_ref = (uint64_t)ret_var.inner;
19070         if (ret_var.is_owned) {
19071                 ret_ref |= 1;
19072         }
19073         return ret_ref;
19074 }
19075
19076 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
19077         LDKUnsignedChannelUpdate this_obj_conv;
19078         this_obj_conv.inner = (void*)(this_obj & (~1));
19079         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19080         UnsignedChannelUpdate_free(this_obj_conv);
19081 }
19082
19083 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
19084         LDKUnsignedChannelUpdate this_ptr_conv;
19085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19086         this_ptr_conv.is_owned = false;
19087         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19088         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
19089         return ret_arr;
19090 }
19091
19092 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
19093         LDKUnsignedChannelUpdate this_ptr_conv;
19094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19095         this_ptr_conv.is_owned = false;
19096         LDKThirtyTwoBytes val_ref;
19097         CHECK(*((uint32_t*)val) == 32);
19098         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19099         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
19100 }
19101
19102 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
19103         LDKUnsignedChannelUpdate this_ptr_conv;
19104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19105         this_ptr_conv.is_owned = false;
19106         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
19107         return ret_val;
19108 }
19109
19110 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
19111         LDKUnsignedChannelUpdate this_ptr_conv;
19112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19113         this_ptr_conv.is_owned = false;
19114         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
19115 }
19116
19117 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
19118         LDKUnsignedChannelUpdate this_ptr_conv;
19119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19120         this_ptr_conv.is_owned = false;
19121         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
19122         return ret_val;
19123 }
19124
19125 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
19126         LDKUnsignedChannelUpdate this_ptr_conv;
19127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19128         this_ptr_conv.is_owned = false;
19129         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
19130 }
19131
19132 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
19133         LDKUnsignedChannelUpdate this_ptr_conv;
19134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19135         this_ptr_conv.is_owned = false;
19136         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
19137         return ret_val;
19138 }
19139
19140 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
19141         LDKUnsignedChannelUpdate this_ptr_conv;
19142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19143         this_ptr_conv.is_owned = false;
19144         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
19145 }
19146
19147 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
19148         LDKUnsignedChannelUpdate this_ptr_conv;
19149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19150         this_ptr_conv.is_owned = false;
19151         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
19152         return ret_val;
19153 }
19154
19155 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
19156         LDKUnsignedChannelUpdate this_ptr_conv;
19157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19158         this_ptr_conv.is_owned = false;
19159         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
19160 }
19161
19162 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
19163         LDKUnsignedChannelUpdate this_ptr_conv;
19164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19165         this_ptr_conv.is_owned = false;
19166         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
19167         return ret_val;
19168 }
19169
19170 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
19171         LDKUnsignedChannelUpdate this_ptr_conv;
19172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19173         this_ptr_conv.is_owned = false;
19174         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
19175 }
19176
19177 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
19178         LDKUnsignedChannelUpdate this_ptr_conv;
19179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19180         this_ptr_conv.is_owned = false;
19181         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
19182         return ret_val;
19183 }
19184
19185 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
19186         LDKUnsignedChannelUpdate this_ptr_conv;
19187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19188         this_ptr_conv.is_owned = false;
19189         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
19190 }
19191
19192 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
19193         LDKUnsignedChannelUpdate this_ptr_conv;
19194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19195         this_ptr_conv.is_owned = false;
19196         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
19197         return ret_val;
19198 }
19199
19200 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
19201         LDKUnsignedChannelUpdate this_ptr_conv;
19202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19203         this_ptr_conv.is_owned = false;
19204         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
19205 }
19206
19207 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
19208         LDKUnsignedChannelUpdate orig_conv;
19209         orig_conv.inner = (void*)(orig & (~1));
19210         orig_conv.is_owned = false;
19211         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
19212         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19213         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19214         uint64_t ret_ref = (uint64_t)ret_var.inner;
19215         if (ret_var.is_owned) {
19216                 ret_ref |= 1;
19217         }
19218         return ret_ref;
19219 }
19220
19221 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_obj) {
19222         LDKChannelUpdate this_obj_conv;
19223         this_obj_conv.inner = (void*)(this_obj & (~1));
19224         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19225         ChannelUpdate_free(this_obj_conv);
19226 }
19227
19228 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
19229         LDKChannelUpdate this_ptr_conv;
19230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19231         this_ptr_conv.is_owned = false;
19232         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
19233         memcpy((uint8_t*)(ret_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
19234         return ret_arr;
19235 }
19236
19237 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
19238         LDKChannelUpdate this_ptr_conv;
19239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19240         this_ptr_conv.is_owned = false;
19241         LDKSignature val_ref;
19242         CHECK(*((uint32_t*)val) == 64);
19243         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
19244         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
19245 }
19246
19247 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
19248         LDKChannelUpdate this_ptr_conv;
19249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19250         this_ptr_conv.is_owned = false;
19251         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
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         uint64_t ret_ref = (uint64_t)ret_var.inner;
19255         if (ret_var.is_owned) {
19256                 ret_ref |= 1;
19257         }
19258         return ret_ref;
19259 }
19260
19261 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
19262         LDKChannelUpdate this_ptr_conv;
19263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19264         this_ptr_conv.is_owned = false;
19265         LDKUnsignedChannelUpdate val_conv;
19266         val_conv.inner = (void*)(val & (~1));
19267         val_conv.is_owned = (val & 1) || (val == 0);
19268         val_conv = UnsignedChannelUpdate_clone(&val_conv);
19269         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
19270 }
19271
19272 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
19273         LDKSignature signature_arg_ref;
19274         CHECK(*((uint32_t*)signature_arg) == 64);
19275         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
19276         LDKUnsignedChannelUpdate contents_arg_conv;
19277         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19278         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19279         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
19280         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
19281         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19282         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19283         uint64_t ret_ref = (uint64_t)ret_var.inner;
19284         if (ret_var.is_owned) {
19285                 ret_ref |= 1;
19286         }
19287         return ret_ref;
19288 }
19289
19290 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
19291         LDKChannelUpdate orig_conv;
19292         orig_conv.inner = (void*)(orig & (~1));
19293         orig_conv.is_owned = false;
19294         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
19295         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19296         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19297         uint64_t ret_ref = (uint64_t)ret_var.inner;
19298         if (ret_var.is_owned) {
19299                 ret_ref |= 1;
19300         }
19301         return ret_ref;
19302 }
19303
19304 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_obj) {
19305         LDKQueryChannelRange this_obj_conv;
19306         this_obj_conv.inner = (void*)(this_obj & (~1));
19307         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19308         QueryChannelRange_free(this_obj_conv);
19309 }
19310
19311 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
19312         LDKQueryChannelRange this_ptr_conv;
19313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19314         this_ptr_conv.is_owned = false;
19315         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19316         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
19317         return ret_arr;
19318 }
19319
19320 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
19321         LDKQueryChannelRange this_ptr_conv;
19322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19323         this_ptr_conv.is_owned = false;
19324         LDKThirtyTwoBytes val_ref;
19325         CHECK(*((uint32_t*)val) == 32);
19326         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19327         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19328 }
19329
19330 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
19331         LDKQueryChannelRange this_ptr_conv;
19332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19333         this_ptr_conv.is_owned = false;
19334         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
19335         return ret_val;
19336 }
19337
19338 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
19339         LDKQueryChannelRange this_ptr_conv;
19340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19341         this_ptr_conv.is_owned = false;
19342         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
19343 }
19344
19345 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
19346         LDKQueryChannelRange this_ptr_conv;
19347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19348         this_ptr_conv.is_owned = false;
19349         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
19350         return ret_val;
19351 }
19352
19353 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
19354         LDKQueryChannelRange this_ptr_conv;
19355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19356         this_ptr_conv.is_owned = false;
19357         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19358 }
19359
19360 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
19361         LDKThirtyTwoBytes chain_hash_arg_ref;
19362         CHECK(*((uint32_t*)chain_hash_arg) == 32);
19363         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
19364         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
19365         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19366         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19367         uint64_t ret_ref = (uint64_t)ret_var.inner;
19368         if (ret_var.is_owned) {
19369                 ret_ref |= 1;
19370         }
19371         return ret_ref;
19372 }
19373
19374 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
19375         LDKQueryChannelRange orig_conv;
19376         orig_conv.inner = (void*)(orig & (~1));
19377         orig_conv.is_owned = false;
19378         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
19379         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19380         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19381         uint64_t ret_ref = (uint64_t)ret_var.inner;
19382         if (ret_var.is_owned) {
19383                 ret_ref |= 1;
19384         }
19385         return ret_ref;
19386 }
19387
19388 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
19389         LDKReplyChannelRange this_obj_conv;
19390         this_obj_conv.inner = (void*)(this_obj & (~1));
19391         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19392         ReplyChannelRange_free(this_obj_conv);
19393 }
19394
19395 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
19396         LDKReplyChannelRange this_ptr_conv;
19397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19398         this_ptr_conv.is_owned = false;
19399         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19400         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
19401         return ret_arr;
19402 }
19403
19404 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
19405         LDKReplyChannelRange this_ptr_conv;
19406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19407         this_ptr_conv.is_owned = false;
19408         LDKThirtyTwoBytes val_ref;
19409         CHECK(*((uint32_t*)val) == 32);
19410         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19411         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
19412 }
19413
19414 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
19415         LDKReplyChannelRange this_ptr_conv;
19416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19417         this_ptr_conv.is_owned = false;
19418         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
19419         return ret_val;
19420 }
19421
19422 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
19423         LDKReplyChannelRange this_ptr_conv;
19424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19425         this_ptr_conv.is_owned = false;
19426         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
19427 }
19428
19429 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
19430         LDKReplyChannelRange this_ptr_conv;
19431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19432         this_ptr_conv.is_owned = false;
19433         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
19434         return ret_val;
19435 }
19436
19437 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
19438         LDKReplyChannelRange this_ptr_conv;
19439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19440         this_ptr_conv.is_owned = false;
19441         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
19442 }
19443
19444 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
19445         LDKReplyChannelRange this_ptr_conv;
19446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19447         this_ptr_conv.is_owned = false;
19448         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
19449         return ret_val;
19450 }
19451
19452 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
19453         LDKReplyChannelRange this_ptr_conv;
19454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19455         this_ptr_conv.is_owned = false;
19456         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
19457 }
19458
19459 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
19460         LDKReplyChannelRange this_ptr_conv;
19461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19462         this_ptr_conv.is_owned = false;
19463         LDKCVec_u64Z val_constr;
19464         val_constr.datalen = *((uint32_t*)val);
19465         if (val_constr.datalen > 0)
19466                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19467         else
19468                 val_constr.data = NULL;
19469         int64_t* val_vals = (int64_t*)(val + 4);
19470         for (size_t i = 0; i < val_constr.datalen; i++) {
19471                 int64_t val_conv_8 = val_vals[i];
19472                 val_constr.data[i] = val_conv_8;
19473         }
19474         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
19475 }
19476
19477 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) {
19478         LDKThirtyTwoBytes chain_hash_arg_ref;
19479         CHECK(*((uint32_t*)chain_hash_arg) == 32);
19480         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
19481         LDKCVec_u64Z short_channel_ids_arg_constr;
19482         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
19483         if (short_channel_ids_arg_constr.datalen > 0)
19484                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19485         else
19486                 short_channel_ids_arg_constr.data = NULL;
19487         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
19488         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
19489                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
19490                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
19491         }
19492         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
19493         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19494         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19495         uint64_t ret_ref = (uint64_t)ret_var.inner;
19496         if (ret_var.is_owned) {
19497                 ret_ref |= 1;
19498         }
19499         return ret_ref;
19500 }
19501
19502 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
19503         LDKReplyChannelRange orig_conv;
19504         orig_conv.inner = (void*)(orig & (~1));
19505         orig_conv.is_owned = false;
19506         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
19507         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19508         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19509         uint64_t ret_ref = (uint64_t)ret_var.inner;
19510         if (ret_var.is_owned) {
19511                 ret_ref |= 1;
19512         }
19513         return ret_ref;
19514 }
19515
19516 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
19517         LDKQueryShortChannelIds this_obj_conv;
19518         this_obj_conv.inner = (void*)(this_obj & (~1));
19519         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19520         QueryShortChannelIds_free(this_obj_conv);
19521 }
19522
19523 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
19524         LDKQueryShortChannelIds this_ptr_conv;
19525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19526         this_ptr_conv.is_owned = false;
19527         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19528         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
19529         return ret_arr;
19530 }
19531
19532 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
19533         LDKQueryShortChannelIds this_ptr_conv;
19534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19535         this_ptr_conv.is_owned = false;
19536         LDKThirtyTwoBytes val_ref;
19537         CHECK(*((uint32_t*)val) == 32);
19538         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19539         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
19540 }
19541
19542 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
19543         LDKQueryShortChannelIds this_ptr_conv;
19544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19545         this_ptr_conv.is_owned = false;
19546         LDKCVec_u64Z val_constr;
19547         val_constr.datalen = *((uint32_t*)val);
19548         if (val_constr.datalen > 0)
19549                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19550         else
19551                 val_constr.data = NULL;
19552         int64_t* val_vals = (int64_t*)(val + 4);
19553         for (size_t i = 0; i < val_constr.datalen; i++) {
19554                 int64_t val_conv_8 = val_vals[i];
19555                 val_constr.data[i] = val_conv_8;
19556         }
19557         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
19558 }
19559
19560 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
19561         LDKThirtyTwoBytes chain_hash_arg_ref;
19562         CHECK(*((uint32_t*)chain_hash_arg) == 32);
19563         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
19564         LDKCVec_u64Z short_channel_ids_arg_constr;
19565         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
19566         if (short_channel_ids_arg_constr.datalen > 0)
19567                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19568         else
19569                 short_channel_ids_arg_constr.data = NULL;
19570         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
19571         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
19572                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
19573                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
19574         }
19575         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
19576         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19577         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19578         uint64_t ret_ref = (uint64_t)ret_var.inner;
19579         if (ret_var.is_owned) {
19580                 ret_ref |= 1;
19581         }
19582         return ret_ref;
19583 }
19584
19585 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
19586         LDKQueryShortChannelIds orig_conv;
19587         orig_conv.inner = (void*)(orig & (~1));
19588         orig_conv.is_owned = false;
19589         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
19590         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19591         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19592         uint64_t ret_ref = (uint64_t)ret_var.inner;
19593         if (ret_var.is_owned) {
19594                 ret_ref |= 1;
19595         }
19596         return ret_ref;
19597 }
19598
19599 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
19600         LDKReplyShortChannelIdsEnd this_obj_conv;
19601         this_obj_conv.inner = (void*)(this_obj & (~1));
19602         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19603         ReplyShortChannelIdsEnd_free(this_obj_conv);
19604 }
19605
19606 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
19607         LDKReplyShortChannelIdsEnd this_ptr_conv;
19608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19609         this_ptr_conv.is_owned = false;
19610         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19611         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
19612         return ret_arr;
19613 }
19614
19615 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
19616         LDKReplyShortChannelIdsEnd this_ptr_conv;
19617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19618         this_ptr_conv.is_owned = false;
19619         LDKThirtyTwoBytes val_ref;
19620         CHECK(*((uint32_t*)val) == 32);
19621         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19622         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
19623 }
19624
19625 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
19626         LDKReplyShortChannelIdsEnd this_ptr_conv;
19627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19628         this_ptr_conv.is_owned = false;
19629         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
19630         return ret_val;
19631 }
19632
19633 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
19634         LDKReplyShortChannelIdsEnd this_ptr_conv;
19635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19636         this_ptr_conv.is_owned = false;
19637         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
19638 }
19639
19640 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
19641         LDKThirtyTwoBytes chain_hash_arg_ref;
19642         CHECK(*((uint32_t*)chain_hash_arg) == 32);
19643         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
19644         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
19645         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19646         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19647         uint64_t ret_ref = (uint64_t)ret_var.inner;
19648         if (ret_var.is_owned) {
19649                 ret_ref |= 1;
19650         }
19651         return ret_ref;
19652 }
19653
19654 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
19655         LDKReplyShortChannelIdsEnd orig_conv;
19656         orig_conv.inner = (void*)(orig & (~1));
19657         orig_conv.is_owned = false;
19658         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
19659         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19660         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19661         uint64_t ret_ref = (uint64_t)ret_var.inner;
19662         if (ret_var.is_owned) {
19663                 ret_ref |= 1;
19664         }
19665         return ret_ref;
19666 }
19667
19668 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
19669         LDKGossipTimestampFilter this_obj_conv;
19670         this_obj_conv.inner = (void*)(this_obj & (~1));
19671         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19672         GossipTimestampFilter_free(this_obj_conv);
19673 }
19674
19675 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
19676         LDKGossipTimestampFilter this_ptr_conv;
19677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19678         this_ptr_conv.is_owned = false;
19679         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19680         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
19681         return ret_arr;
19682 }
19683
19684 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
19685         LDKGossipTimestampFilter this_ptr_conv;
19686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19687         this_ptr_conv.is_owned = false;
19688         LDKThirtyTwoBytes val_ref;
19689         CHECK(*((uint32_t*)val) == 32);
19690         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19691         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
19692 }
19693
19694 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
19695         LDKGossipTimestampFilter this_ptr_conv;
19696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19697         this_ptr_conv.is_owned = false;
19698         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
19699         return ret_val;
19700 }
19701
19702 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
19703         LDKGossipTimestampFilter this_ptr_conv;
19704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19705         this_ptr_conv.is_owned = false;
19706         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
19707 }
19708
19709 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
19710         LDKGossipTimestampFilter this_ptr_conv;
19711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19712         this_ptr_conv.is_owned = false;
19713         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
19714         return ret_val;
19715 }
19716
19717 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
19718         LDKGossipTimestampFilter this_ptr_conv;
19719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19720         this_ptr_conv.is_owned = false;
19721         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
19722 }
19723
19724 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
19725         LDKThirtyTwoBytes chain_hash_arg_ref;
19726         CHECK(*((uint32_t*)chain_hash_arg) == 32);
19727         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
19728         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
19729         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19730         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19731         uint64_t ret_ref = (uint64_t)ret_var.inner;
19732         if (ret_var.is_owned) {
19733                 ret_ref |= 1;
19734         }
19735         return ret_ref;
19736 }
19737
19738 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
19739         LDKGossipTimestampFilter orig_conv;
19740         orig_conv.inner = (void*)(orig & (~1));
19741         orig_conv.is_owned = false;
19742         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
19743         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19744         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19745         uint64_t ret_ref = (uint64_t)ret_var.inner;
19746         if (ret_var.is_owned) {
19747                 ret_ref |= 1;
19748         }
19749         return ret_ref;
19750 }
19751
19752 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
19753         if ((this_ptr & 1) != 0) return;
19754         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
19755         FREE((void*)this_ptr);
19756         ErrorAction_free(this_ptr_conv);
19757 }
19758
19759 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
19760         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
19761         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19762         *ret_copy = ErrorAction_clone(orig_conv);
19763         uint64_t ret_ref = (uint64_t)ret_copy;
19764         return ret_ref;
19765 }
19766
19767 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
19768         LDKErrorMessage msg_conv;
19769         msg_conv.inner = (void*)(msg & (~1));
19770         msg_conv.is_owned = (msg & 1) || (msg == 0);
19771         msg_conv = ErrorMessage_clone(&msg_conv);
19772         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19773         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
19774         uint64_t ret_ref = (uint64_t)ret_copy;
19775         return ret_ref;
19776 }
19777
19778 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_ignore_error() {
19779         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19780         *ret_copy = ErrorAction_ignore_error();
19781         uint64_t ret_ref = (uint64_t)ret_copy;
19782         return ret_ref;
19783 }
19784
19785 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
19786         LDKLevel a_conv = LDKLevel_from_js(a);
19787         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19788         *ret_copy = ErrorAction_ignore_and_log(a_conv);
19789         uint64_t ret_ref = (uint64_t)ret_copy;
19790         return ret_ref;
19791 }
19792
19793 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_send_error_message(uint32_t msg) {
19794         LDKErrorMessage msg_conv;
19795         msg_conv.inner = (void*)(msg & (~1));
19796         msg_conv.is_owned = (msg & 1) || (msg == 0);
19797         msg_conv = ErrorMessage_clone(&msg_conv);
19798         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19799         *ret_copy = ErrorAction_send_error_message(msg_conv);
19800         uint64_t ret_ref = (uint64_t)ret_copy;
19801         return ret_ref;
19802 }
19803
19804 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_obj) {
19805         LDKLightningError this_obj_conv;
19806         this_obj_conv.inner = (void*)(this_obj & (~1));
19807         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19808         LightningError_free(this_obj_conv);
19809 }
19810
19811 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
19812         LDKLightningError this_ptr_conv;
19813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19814         this_ptr_conv.is_owned = false;
19815         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
19816         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
19817         Str_free(ret_str);
19818         return ret_conv;
19819 }
19820
19821 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
19822         LDKLightningError this_ptr_conv;
19823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19824         this_ptr_conv.is_owned = false;
19825         LDKStr val_conv = str_ref_to_owned_c(val);
19826         LightningError_set_err(&this_ptr_conv, val_conv);
19827 }
19828
19829 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
19830         LDKLightningError this_ptr_conv;
19831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19832         this_ptr_conv.is_owned = false;
19833         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
19834         *ret_copy = LightningError_get_action(&this_ptr_conv);
19835         uint64_t ret_ref = (uint64_t)ret_copy;
19836         return ret_ref;
19837 }
19838
19839 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
19840         LDKLightningError this_ptr_conv;
19841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19842         this_ptr_conv.is_owned = false;
19843         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
19844         val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1));
19845         LightningError_set_action(&this_ptr_conv, val_conv);
19846 }
19847
19848 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
19849         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
19850         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
19851         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
19852         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
19853         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19854         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19855         uint64_t ret_ref = (uint64_t)ret_var.inner;
19856         if (ret_var.is_owned) {
19857                 ret_ref |= 1;
19858         }
19859         return ret_ref;
19860 }
19861
19862 uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_t orig) {
19863         LDKLightningError orig_conv;
19864         orig_conv.inner = (void*)(orig & (~1));
19865         orig_conv.is_owned = false;
19866         LDKLightningError ret_var = LightningError_clone(&orig_conv);
19867         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19868         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19869         uint64_t ret_ref = (uint64_t)ret_var.inner;
19870         if (ret_var.is_owned) {
19871                 ret_ref |= 1;
19872         }
19873         return ret_ref;
19874 }
19875
19876 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
19877         LDKCommitmentUpdate this_obj_conv;
19878         this_obj_conv.inner = (void*)(this_obj & (~1));
19879         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19880         CommitmentUpdate_free(this_obj_conv);
19881 }
19882
19883 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
19884         LDKCommitmentUpdate this_ptr_conv;
19885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19886         this_ptr_conv.is_owned = false;
19887         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
19888         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19889         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19890         for (size_t p = 0; p < ret_var.datalen; p++) {
19891                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
19892                 CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19893                 CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19894                 uint64_t ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner;
19895                 if (ret_conv_15_var.is_owned) {
19896                         ret_conv_15_ref |= 1;
19897                 }
19898                 ret_arr_ptr[p] = ret_conv_15_ref;
19899         }
19900         FREE(ret_var.data);
19901         return ret_arr;
19902 }
19903
19904 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
19905         LDKCommitmentUpdate this_ptr_conv;
19906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19907         this_ptr_conv.is_owned = false;
19908         LDKCVec_UpdateAddHTLCZ val_constr;
19909         val_constr.datalen = *((uint32_t*)val);
19910         if (val_constr.datalen > 0)
19911                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
19912         else
19913                 val_constr.data = NULL;
19914         uint32_t* val_vals = (uint32_t*)(val + 4);
19915         for (size_t p = 0; p < val_constr.datalen; p++) {
19916                 uint32_t val_conv_15 = val_vals[p];
19917                 LDKUpdateAddHTLC val_conv_15_conv;
19918                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
19919                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
19920                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
19921                 val_constr.data[p] = val_conv_15_conv;
19922         }
19923         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
19924 }
19925
19926 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
19927         LDKCommitmentUpdate this_ptr_conv;
19928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19929         this_ptr_conv.is_owned = false;
19930         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
19931         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19932         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19933         for (size_t t = 0; t < ret_var.datalen; t++) {
19934                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
19935                 CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19936                 CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19937                 uint64_t ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner;
19938                 if (ret_conv_19_var.is_owned) {
19939                         ret_conv_19_ref |= 1;
19940                 }
19941                 ret_arr_ptr[t] = ret_conv_19_ref;
19942         }
19943         FREE(ret_var.data);
19944         return ret_arr;
19945 }
19946
19947 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
19948         LDKCommitmentUpdate this_ptr_conv;
19949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19950         this_ptr_conv.is_owned = false;
19951         LDKCVec_UpdateFulfillHTLCZ val_constr;
19952         val_constr.datalen = *((uint32_t*)val);
19953         if (val_constr.datalen > 0)
19954                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
19955         else
19956                 val_constr.data = NULL;
19957         uint32_t* val_vals = (uint32_t*)(val + 4);
19958         for (size_t t = 0; t < val_constr.datalen; t++) {
19959                 uint32_t val_conv_19 = val_vals[t];
19960                 LDKUpdateFulfillHTLC val_conv_19_conv;
19961                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
19962                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
19963                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
19964                 val_constr.data[t] = val_conv_19_conv;
19965         }
19966         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
19967 }
19968
19969 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
19970         LDKCommitmentUpdate this_ptr_conv;
19971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19972         this_ptr_conv.is_owned = false;
19973         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
19974         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19975         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19976         for (size_t q = 0; q < ret_var.datalen; q++) {
19977                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
19978                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19979                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19980                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
19981                 if (ret_conv_16_var.is_owned) {
19982                         ret_conv_16_ref |= 1;
19983                 }
19984                 ret_arr_ptr[q] = ret_conv_16_ref;
19985         }
19986         FREE(ret_var.data);
19987         return ret_arr;
19988 }
19989
19990 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
19991         LDKCommitmentUpdate this_ptr_conv;
19992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19993         this_ptr_conv.is_owned = false;
19994         LDKCVec_UpdateFailHTLCZ val_constr;
19995         val_constr.datalen = *((uint32_t*)val);
19996         if (val_constr.datalen > 0)
19997                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
19998         else
19999                 val_constr.data = NULL;
20000         uint32_t* val_vals = (uint32_t*)(val + 4);
20001         for (size_t q = 0; q < val_constr.datalen; q++) {
20002                 uint32_t val_conv_16 = val_vals[q];
20003                 LDKUpdateFailHTLC val_conv_16_conv;
20004                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
20005                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
20006                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
20007                 val_constr.data[q] = val_conv_16_conv;
20008         }
20009         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
20010 }
20011
20012 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
20013         LDKCommitmentUpdate this_ptr_conv;
20014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20015         this_ptr_conv.is_owned = false;
20016         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
20017         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
20018         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
20019         for (size_t z = 0; z < ret_var.datalen; z++) {
20020                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
20021                 CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20022                 CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20023                 uint64_t ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner;
20024                 if (ret_conv_25_var.is_owned) {
20025                         ret_conv_25_ref |= 1;
20026                 }
20027                 ret_arr_ptr[z] = ret_conv_25_ref;
20028         }
20029         FREE(ret_var.data);
20030         return ret_arr;
20031 }
20032
20033 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
20034         LDKCommitmentUpdate this_ptr_conv;
20035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20036         this_ptr_conv.is_owned = false;
20037         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
20038         val_constr.datalen = *((uint32_t*)val);
20039         if (val_constr.datalen > 0)
20040                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
20041         else
20042                 val_constr.data = NULL;
20043         uint32_t* val_vals = (uint32_t*)(val + 4);
20044         for (size_t z = 0; z < val_constr.datalen; z++) {
20045                 uint32_t val_conv_25 = val_vals[z];
20046                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
20047                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
20048                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
20049                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
20050                 val_constr.data[z] = val_conv_25_conv;
20051         }
20052         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
20053 }
20054
20055 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
20056         LDKCommitmentUpdate this_ptr_conv;
20057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20058         this_ptr_conv.is_owned = false;
20059         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
20060         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20061         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20062         uint64_t ret_ref = (uint64_t)ret_var.inner;
20063         if (ret_var.is_owned) {
20064                 ret_ref |= 1;
20065         }
20066         return ret_ref;
20067 }
20068
20069 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
20070         LDKCommitmentUpdate this_ptr_conv;
20071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20072         this_ptr_conv.is_owned = false;
20073         LDKUpdateFee val_conv;
20074         val_conv.inner = (void*)(val & (~1));
20075         val_conv.is_owned = (val & 1) || (val == 0);
20076         val_conv = UpdateFee_clone(&val_conv);
20077         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
20078 }
20079
20080 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
20081         LDKCommitmentUpdate this_ptr_conv;
20082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20083         this_ptr_conv.is_owned = false;
20084         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
20085         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20086         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20087         uint64_t ret_ref = (uint64_t)ret_var.inner;
20088         if (ret_var.is_owned) {
20089                 ret_ref |= 1;
20090         }
20091         return ret_ref;
20092 }
20093
20094 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
20095         LDKCommitmentUpdate this_ptr_conv;
20096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20097         this_ptr_conv.is_owned = false;
20098         LDKCommitmentSigned val_conv;
20099         val_conv.inner = (void*)(val & (~1));
20100         val_conv.is_owned = (val & 1) || (val == 0);
20101         val_conv = CommitmentSigned_clone(&val_conv);
20102         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
20103 }
20104
20105 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) {
20106         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
20107         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
20108         if (update_add_htlcs_arg_constr.datalen > 0)
20109                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
20110         else
20111                 update_add_htlcs_arg_constr.data = NULL;
20112         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
20113         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
20114                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
20115                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
20116                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
20117                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
20118                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
20119                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
20120         }
20121         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
20122         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
20123         if (update_fulfill_htlcs_arg_constr.datalen > 0)
20124                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
20125         else
20126                 update_fulfill_htlcs_arg_constr.data = NULL;
20127         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
20128         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
20129                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
20130                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
20131                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
20132                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
20133                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
20134                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
20135         }
20136         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
20137         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
20138         if (update_fail_htlcs_arg_constr.datalen > 0)
20139                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
20140         else
20141                 update_fail_htlcs_arg_constr.data = NULL;
20142         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
20143         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
20144                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
20145                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
20146                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
20147                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
20148                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
20149                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
20150         }
20151         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
20152         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
20153         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
20154                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
20155         else
20156                 update_fail_malformed_htlcs_arg_constr.data = NULL;
20157         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
20158         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
20159                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
20160                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
20161                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
20162                 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);
20163                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
20164                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
20165         }
20166         LDKUpdateFee update_fee_arg_conv;
20167         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
20168         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
20169         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
20170         LDKCommitmentSigned commitment_signed_arg_conv;
20171         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
20172         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
20173         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
20174         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);
20175         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20176         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20177         uint64_t ret_ref = (uint64_t)ret_var.inner;
20178         if (ret_var.is_owned) {
20179                 ret_ref |= 1;
20180         }
20181         return ret_ref;
20182 }
20183
20184 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
20185         LDKCommitmentUpdate orig_conv;
20186         orig_conv.inner = (void*)(orig & (~1));
20187         orig_conv.is_owned = false;
20188         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
20189         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20190         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20191         uint64_t ret_ref = (uint64_t)ret_var.inner;
20192         if (ret_var.is_owned) {
20193                 ret_ref |= 1;
20194         }
20195         return ret_ref;
20196 }
20197
20198 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
20199         if ((this_ptr & 1) != 0) return;
20200         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
20201         FREE((void*)this_ptr);
20202         ChannelMessageHandler_free(this_ptr_conv);
20203 }
20204
20205 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
20206         if ((this_ptr & 1) != 0) return;
20207         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
20208         FREE((void*)this_ptr);
20209         RoutingMessageHandler_free(this_ptr_conv);
20210 }
20211
20212 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
20213         LDKAcceptChannel obj_conv;
20214         obj_conv.inner = (void*)(obj & (~1));
20215         obj_conv.is_owned = false;
20216         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
20217         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20218         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20219         CVec_u8Z_free(ret_var);
20220         return ret_arr;
20221 }
20222
20223 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
20224         LDKu8slice ser_ref;
20225         ser_ref.datalen = *((uint32_t*)ser);
20226         ser_ref.data = (int8_t*)(ser + 4);
20227         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
20228         *ret_conv = AcceptChannel_read(ser_ref);
20229         return (uint64_t)ret_conv;
20230 }
20231
20232 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
20233         LDKAnnouncementSignatures obj_conv;
20234         obj_conv.inner = (void*)(obj & (~1));
20235         obj_conv.is_owned = false;
20236         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
20237         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20238         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20239         CVec_u8Z_free(ret_var);
20240         return ret_arr;
20241 }
20242
20243 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
20244         LDKu8slice ser_ref;
20245         ser_ref.datalen = *((uint32_t*)ser);
20246         ser_ref.data = (int8_t*)(ser + 4);
20247         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
20248         *ret_conv = AnnouncementSignatures_read(ser_ref);
20249         return (uint64_t)ret_conv;
20250 }
20251
20252 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
20253         LDKChannelReestablish obj_conv;
20254         obj_conv.inner = (void*)(obj & (~1));
20255         obj_conv.is_owned = false;
20256         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
20257         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20258         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20259         CVec_u8Z_free(ret_var);
20260         return ret_arr;
20261 }
20262
20263 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
20264         LDKu8slice ser_ref;
20265         ser_ref.datalen = *((uint32_t*)ser);
20266         ser_ref.data = (int8_t*)(ser + 4);
20267         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
20268         *ret_conv = ChannelReestablish_read(ser_ref);
20269         return (uint64_t)ret_conv;
20270 }
20271
20272 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
20273         LDKClosingSigned obj_conv;
20274         obj_conv.inner = (void*)(obj & (~1));
20275         obj_conv.is_owned = false;
20276         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
20277         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20278         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20279         CVec_u8Z_free(ret_var);
20280         return ret_arr;
20281 }
20282
20283 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
20284         LDKu8slice ser_ref;
20285         ser_ref.datalen = *((uint32_t*)ser);
20286         ser_ref.data = (int8_t*)(ser + 4);
20287         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
20288         *ret_conv = ClosingSigned_read(ser_ref);
20289         return (uint64_t)ret_conv;
20290 }
20291
20292 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
20293         LDKClosingSignedFeeRange obj_conv;
20294         obj_conv.inner = (void*)(obj & (~1));
20295         obj_conv.is_owned = false;
20296         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
20297         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20298         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20299         CVec_u8Z_free(ret_var);
20300         return ret_arr;
20301 }
20302
20303 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
20304         LDKu8slice ser_ref;
20305         ser_ref.datalen = *((uint32_t*)ser);
20306         ser_ref.data = (int8_t*)(ser + 4);
20307         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
20308         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
20309         return (uint64_t)ret_conv;
20310 }
20311
20312 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
20313         LDKCommitmentSigned obj_conv;
20314         obj_conv.inner = (void*)(obj & (~1));
20315         obj_conv.is_owned = false;
20316         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
20317         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20318         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20319         CVec_u8Z_free(ret_var);
20320         return ret_arr;
20321 }
20322
20323 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
20324         LDKu8slice ser_ref;
20325         ser_ref.datalen = *((uint32_t*)ser);
20326         ser_ref.data = (int8_t*)(ser + 4);
20327         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
20328         *ret_conv = CommitmentSigned_read(ser_ref);
20329         return (uint64_t)ret_conv;
20330 }
20331
20332 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
20333         LDKFundingCreated obj_conv;
20334         obj_conv.inner = (void*)(obj & (~1));
20335         obj_conv.is_owned = false;
20336         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
20337         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20338         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20339         CVec_u8Z_free(ret_var);
20340         return ret_arr;
20341 }
20342
20343 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
20344         LDKu8slice ser_ref;
20345         ser_ref.datalen = *((uint32_t*)ser);
20346         ser_ref.data = (int8_t*)(ser + 4);
20347         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
20348         *ret_conv = FundingCreated_read(ser_ref);
20349         return (uint64_t)ret_conv;
20350 }
20351
20352 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
20353         LDKFundingSigned obj_conv;
20354         obj_conv.inner = (void*)(obj & (~1));
20355         obj_conv.is_owned = false;
20356         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
20357         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20358         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20359         CVec_u8Z_free(ret_var);
20360         return ret_arr;
20361 }
20362
20363 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
20364         LDKu8slice ser_ref;
20365         ser_ref.datalen = *((uint32_t*)ser);
20366         ser_ref.data = (int8_t*)(ser + 4);
20367         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
20368         *ret_conv = FundingSigned_read(ser_ref);
20369         return (uint64_t)ret_conv;
20370 }
20371
20372 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
20373         LDKFundingLocked obj_conv;
20374         obj_conv.inner = (void*)(obj & (~1));
20375         obj_conv.is_owned = false;
20376         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
20377         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20378         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20379         CVec_u8Z_free(ret_var);
20380         return ret_arr;
20381 }
20382
20383 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
20384         LDKu8slice ser_ref;
20385         ser_ref.datalen = *((uint32_t*)ser);
20386         ser_ref.data = (int8_t*)(ser + 4);
20387         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
20388         *ret_conv = FundingLocked_read(ser_ref);
20389         return (uint64_t)ret_conv;
20390 }
20391
20392 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
20393         LDKInit obj_conv;
20394         obj_conv.inner = (void*)(obj & (~1));
20395         obj_conv.is_owned = false;
20396         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
20397         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20398         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20399         CVec_u8Z_free(ret_var);
20400         return ret_arr;
20401 }
20402
20403 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
20404         LDKu8slice ser_ref;
20405         ser_ref.datalen = *((uint32_t*)ser);
20406         ser_ref.data = (int8_t*)(ser + 4);
20407         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
20408         *ret_conv = Init_read(ser_ref);
20409         return (uint64_t)ret_conv;
20410 }
20411
20412 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
20413         LDKOpenChannel obj_conv;
20414         obj_conv.inner = (void*)(obj & (~1));
20415         obj_conv.is_owned = false;
20416         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
20417         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20418         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20419         CVec_u8Z_free(ret_var);
20420         return ret_arr;
20421 }
20422
20423 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
20424         LDKu8slice ser_ref;
20425         ser_ref.datalen = *((uint32_t*)ser);
20426         ser_ref.data = (int8_t*)(ser + 4);
20427         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
20428         *ret_conv = OpenChannel_read(ser_ref);
20429         return (uint64_t)ret_conv;
20430 }
20431
20432 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
20433         LDKRevokeAndACK obj_conv;
20434         obj_conv.inner = (void*)(obj & (~1));
20435         obj_conv.is_owned = false;
20436         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
20437         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20438         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20439         CVec_u8Z_free(ret_var);
20440         return ret_arr;
20441 }
20442
20443 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
20444         LDKu8slice ser_ref;
20445         ser_ref.datalen = *((uint32_t*)ser);
20446         ser_ref.data = (int8_t*)(ser + 4);
20447         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
20448         *ret_conv = RevokeAndACK_read(ser_ref);
20449         return (uint64_t)ret_conv;
20450 }
20451
20452 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
20453         LDKShutdown obj_conv;
20454         obj_conv.inner = (void*)(obj & (~1));
20455         obj_conv.is_owned = false;
20456         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
20457         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20458         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20459         CVec_u8Z_free(ret_var);
20460         return ret_arr;
20461 }
20462
20463 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
20464         LDKu8slice ser_ref;
20465         ser_ref.datalen = *((uint32_t*)ser);
20466         ser_ref.data = (int8_t*)(ser + 4);
20467         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
20468         *ret_conv = Shutdown_read(ser_ref);
20469         return (uint64_t)ret_conv;
20470 }
20471
20472 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
20473         LDKUpdateFailHTLC obj_conv;
20474         obj_conv.inner = (void*)(obj & (~1));
20475         obj_conv.is_owned = false;
20476         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
20477         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20478         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20479         CVec_u8Z_free(ret_var);
20480         return ret_arr;
20481 }
20482
20483 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
20484         LDKu8slice ser_ref;
20485         ser_ref.datalen = *((uint32_t*)ser);
20486         ser_ref.data = (int8_t*)(ser + 4);
20487         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
20488         *ret_conv = UpdateFailHTLC_read(ser_ref);
20489         return (uint64_t)ret_conv;
20490 }
20491
20492 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
20493         LDKUpdateFailMalformedHTLC obj_conv;
20494         obj_conv.inner = (void*)(obj & (~1));
20495         obj_conv.is_owned = false;
20496         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
20497         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20498         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20499         CVec_u8Z_free(ret_var);
20500         return ret_arr;
20501 }
20502
20503 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
20504         LDKu8slice ser_ref;
20505         ser_ref.datalen = *((uint32_t*)ser);
20506         ser_ref.data = (int8_t*)(ser + 4);
20507         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
20508         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
20509         return (uint64_t)ret_conv;
20510 }
20511
20512 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
20513         LDKUpdateFee obj_conv;
20514         obj_conv.inner = (void*)(obj & (~1));
20515         obj_conv.is_owned = false;
20516         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
20517         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20518         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20519         CVec_u8Z_free(ret_var);
20520         return ret_arr;
20521 }
20522
20523 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
20524         LDKu8slice ser_ref;
20525         ser_ref.datalen = *((uint32_t*)ser);
20526         ser_ref.data = (int8_t*)(ser + 4);
20527         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
20528         *ret_conv = UpdateFee_read(ser_ref);
20529         return (uint64_t)ret_conv;
20530 }
20531
20532 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
20533         LDKUpdateFulfillHTLC obj_conv;
20534         obj_conv.inner = (void*)(obj & (~1));
20535         obj_conv.is_owned = false;
20536         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
20537         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20538         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20539         CVec_u8Z_free(ret_var);
20540         return ret_arr;
20541 }
20542
20543 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
20544         LDKu8slice ser_ref;
20545         ser_ref.datalen = *((uint32_t*)ser);
20546         ser_ref.data = (int8_t*)(ser + 4);
20547         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
20548         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
20549         return (uint64_t)ret_conv;
20550 }
20551
20552 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
20553         LDKUpdateAddHTLC obj_conv;
20554         obj_conv.inner = (void*)(obj & (~1));
20555         obj_conv.is_owned = false;
20556         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
20557         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20558         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20559         CVec_u8Z_free(ret_var);
20560         return ret_arr;
20561 }
20562
20563 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
20564         LDKu8slice ser_ref;
20565         ser_ref.datalen = *((uint32_t*)ser);
20566         ser_ref.data = (int8_t*)(ser + 4);
20567         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
20568         *ret_conv = UpdateAddHTLC_read(ser_ref);
20569         return (uint64_t)ret_conv;
20570 }
20571
20572 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
20573         LDKPing obj_conv;
20574         obj_conv.inner = (void*)(obj & (~1));
20575         obj_conv.is_owned = false;
20576         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
20577         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20578         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20579         CVec_u8Z_free(ret_var);
20580         return ret_arr;
20581 }
20582
20583 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
20584         LDKu8slice ser_ref;
20585         ser_ref.datalen = *((uint32_t*)ser);
20586         ser_ref.data = (int8_t*)(ser + 4);
20587         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
20588         *ret_conv = Ping_read(ser_ref);
20589         return (uint64_t)ret_conv;
20590 }
20591
20592 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
20593         LDKPong obj_conv;
20594         obj_conv.inner = (void*)(obj & (~1));
20595         obj_conv.is_owned = false;
20596         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
20597         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20598         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20599         CVec_u8Z_free(ret_var);
20600         return ret_arr;
20601 }
20602
20603 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
20604         LDKu8slice ser_ref;
20605         ser_ref.datalen = *((uint32_t*)ser);
20606         ser_ref.data = (int8_t*)(ser + 4);
20607         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
20608         *ret_conv = Pong_read(ser_ref);
20609         return (uint64_t)ret_conv;
20610 }
20611
20612 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
20613         LDKUnsignedChannelAnnouncement obj_conv;
20614         obj_conv.inner = (void*)(obj & (~1));
20615         obj_conv.is_owned = false;
20616         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
20617         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20618         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20619         CVec_u8Z_free(ret_var);
20620         return ret_arr;
20621 }
20622
20623 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
20624         LDKu8slice ser_ref;
20625         ser_ref.datalen = *((uint32_t*)ser);
20626         ser_ref.data = (int8_t*)(ser + 4);
20627         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
20628         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
20629         return (uint64_t)ret_conv;
20630 }
20631
20632 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
20633         LDKChannelAnnouncement obj_conv;
20634         obj_conv.inner = (void*)(obj & (~1));
20635         obj_conv.is_owned = false;
20636         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
20637         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20638         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20639         CVec_u8Z_free(ret_var);
20640         return ret_arr;
20641 }
20642
20643 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
20644         LDKu8slice ser_ref;
20645         ser_ref.datalen = *((uint32_t*)ser);
20646         ser_ref.data = (int8_t*)(ser + 4);
20647         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
20648         *ret_conv = ChannelAnnouncement_read(ser_ref);
20649         return (uint64_t)ret_conv;
20650 }
20651
20652 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
20653         LDKUnsignedChannelUpdate obj_conv;
20654         obj_conv.inner = (void*)(obj & (~1));
20655         obj_conv.is_owned = false;
20656         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
20657         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20658         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20659         CVec_u8Z_free(ret_var);
20660         return ret_arr;
20661 }
20662
20663 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
20664         LDKu8slice ser_ref;
20665         ser_ref.datalen = *((uint32_t*)ser);
20666         ser_ref.data = (int8_t*)(ser + 4);
20667         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
20668         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
20669         return (uint64_t)ret_conv;
20670 }
20671
20672 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
20673         LDKChannelUpdate obj_conv;
20674         obj_conv.inner = (void*)(obj & (~1));
20675         obj_conv.is_owned = false;
20676         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
20677         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20678         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20679         CVec_u8Z_free(ret_var);
20680         return ret_arr;
20681 }
20682
20683 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
20684         LDKu8slice ser_ref;
20685         ser_ref.datalen = *((uint32_t*)ser);
20686         ser_ref.data = (int8_t*)(ser + 4);
20687         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20688         *ret_conv = ChannelUpdate_read(ser_ref);
20689         return (uint64_t)ret_conv;
20690 }
20691
20692 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
20693         LDKErrorMessage obj_conv;
20694         obj_conv.inner = (void*)(obj & (~1));
20695         obj_conv.is_owned = false;
20696         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
20697         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20698         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20699         CVec_u8Z_free(ret_var);
20700         return ret_arr;
20701 }
20702
20703 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
20704         LDKu8slice ser_ref;
20705         ser_ref.datalen = *((uint32_t*)ser);
20706         ser_ref.data = (int8_t*)(ser + 4);
20707         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20708         *ret_conv = ErrorMessage_read(ser_ref);
20709         return (uint64_t)ret_conv;
20710 }
20711
20712 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
20713         LDKUnsignedNodeAnnouncement obj_conv;
20714         obj_conv.inner = (void*)(obj & (~1));
20715         obj_conv.is_owned = false;
20716         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
20717         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20718         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20719         CVec_u8Z_free(ret_var);
20720         return ret_arr;
20721 }
20722
20723 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
20724         LDKu8slice ser_ref;
20725         ser_ref.datalen = *((uint32_t*)ser);
20726         ser_ref.data = (int8_t*)(ser + 4);
20727         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20728         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
20729         return (uint64_t)ret_conv;
20730 }
20731
20732 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
20733         LDKNodeAnnouncement obj_conv;
20734         obj_conv.inner = (void*)(obj & (~1));
20735         obj_conv.is_owned = false;
20736         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
20737         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20738         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20739         CVec_u8Z_free(ret_var);
20740         return ret_arr;
20741 }
20742
20743 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
20744         LDKu8slice ser_ref;
20745         ser_ref.datalen = *((uint32_t*)ser);
20746         ser_ref.data = (int8_t*)(ser + 4);
20747         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20748         *ret_conv = NodeAnnouncement_read(ser_ref);
20749         return (uint64_t)ret_conv;
20750 }
20751
20752 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
20753         LDKu8slice ser_ref;
20754         ser_ref.datalen = *((uint32_t*)ser);
20755         ser_ref.data = (int8_t*)(ser + 4);
20756         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20757         *ret_conv = QueryShortChannelIds_read(ser_ref);
20758         return (uint64_t)ret_conv;
20759 }
20760
20761 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
20762         LDKQueryShortChannelIds obj_conv;
20763         obj_conv.inner = (void*)(obj & (~1));
20764         obj_conv.is_owned = false;
20765         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
20766         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20767         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20768         CVec_u8Z_free(ret_var);
20769         return ret_arr;
20770 }
20771
20772 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
20773         LDKReplyShortChannelIdsEnd obj_conv;
20774         obj_conv.inner = (void*)(obj & (~1));
20775         obj_conv.is_owned = false;
20776         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
20777         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20778         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20779         CVec_u8Z_free(ret_var);
20780         return ret_arr;
20781 }
20782
20783 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
20784         LDKu8slice ser_ref;
20785         ser_ref.datalen = *((uint32_t*)ser);
20786         ser_ref.data = (int8_t*)(ser + 4);
20787         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20788         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
20789         return (uint64_t)ret_conv;
20790 }
20791
20792 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
20793         LDKQueryChannelRange this_arg_conv;
20794         this_arg_conv.inner = (void*)(this_arg & (~1));
20795         this_arg_conv.is_owned = false;
20796         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
20797         return ret_val;
20798 }
20799
20800 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
20801         LDKQueryChannelRange obj_conv;
20802         obj_conv.inner = (void*)(obj & (~1));
20803         obj_conv.is_owned = false;
20804         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
20805         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20806         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20807         CVec_u8Z_free(ret_var);
20808         return ret_arr;
20809 }
20810
20811 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
20812         LDKu8slice ser_ref;
20813         ser_ref.datalen = *((uint32_t*)ser);
20814         ser_ref.data = (int8_t*)(ser + 4);
20815         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20816         *ret_conv = QueryChannelRange_read(ser_ref);
20817         return (uint64_t)ret_conv;
20818 }
20819
20820 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
20821         LDKu8slice ser_ref;
20822         ser_ref.datalen = *((uint32_t*)ser);
20823         ser_ref.data = (int8_t*)(ser + 4);
20824         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20825         *ret_conv = ReplyChannelRange_read(ser_ref);
20826         return (uint64_t)ret_conv;
20827 }
20828
20829 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
20830         LDKReplyChannelRange obj_conv;
20831         obj_conv.inner = (void*)(obj & (~1));
20832         obj_conv.is_owned = false;
20833         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
20834         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20835         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20836         CVec_u8Z_free(ret_var);
20837         return ret_arr;
20838 }
20839
20840 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
20841         LDKGossipTimestampFilter obj_conv;
20842         obj_conv.inner = (void*)(obj & (~1));
20843         obj_conv.is_owned = false;
20844         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
20845         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20846         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20847         CVec_u8Z_free(ret_var);
20848         return ret_arr;
20849 }
20850
20851 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
20852         LDKu8slice ser_ref;
20853         ser_ref.datalen = *((uint32_t*)ser);
20854         ser_ref.data = (int8_t*)(ser + 4);
20855         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20856         *ret_conv = GossipTimestampFilter_read(ser_ref);
20857         return (uint64_t)ret_conv;
20858 }
20859
20860 void  __attribute__((visibility("default"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
20861         if ((this_ptr & 1) != 0) return;
20862         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(((uint64_t)this_ptr) & ~1);
20863         FREE((void*)this_ptr);
20864         CustomMessageHandler_free(this_ptr_conv);
20865 }
20866
20867 void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
20868         LDKIgnoringMessageHandler this_obj_conv;
20869         this_obj_conv.inner = (void*)(this_obj & (~1));
20870         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20871         IgnoringMessageHandler_free(this_obj_conv);
20872 }
20873
20874 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
20875         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
20876         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20877         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20878         uint64_t ret_ref = (uint64_t)ret_var.inner;
20879         if (ret_var.is_owned) {
20880                 ret_ref |= 1;
20881         }
20882         return ret_ref;
20883 }
20884
20885 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
20886         LDKIgnoringMessageHandler this_arg_conv;
20887         this_arg_conv.inner = (void*)(this_arg & (~1));
20888         this_arg_conv.is_owned = false;
20889         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20890         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
20891         return (uint64_t)ret_ret;
20892 }
20893
20894 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
20895         LDKIgnoringMessageHandler this_arg_conv;
20896         this_arg_conv.inner = (void*)(this_arg & (~1));
20897         this_arg_conv.is_owned = false;
20898         LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
20899         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
20900         return (uint64_t)ret_ret;
20901 }
20902
20903 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
20904         LDKIgnoringMessageHandler this_arg_conv;
20905         this_arg_conv.inner = (void*)(this_arg & (~1));
20906         this_arg_conv.is_owned = false;
20907         LDKCustomMessageReader* ret_ret =MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
20908         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
20909         return (uint64_t)ret_ret;
20910 }
20911
20912 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
20913         LDKIgnoringMessageHandler this_arg_conv;
20914         this_arg_conv.inner = (void*)(this_arg & (~1));
20915         this_arg_conv.is_owned = false;
20916         LDKCustomMessageHandler* ret_ret =MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
20917         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
20918         return (uint64_t)ret_ret;
20919 }
20920
20921 void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
20922         LDKErroringMessageHandler this_obj_conv;
20923         this_obj_conv.inner = (void*)(this_obj & (~1));
20924         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20925         ErroringMessageHandler_free(this_obj_conv);
20926 }
20927
20928 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
20929         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
20930         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20931         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20932         uint64_t ret_ref = (uint64_t)ret_var.inner;
20933         if (ret_var.is_owned) {
20934                 ret_ref |= 1;
20935         }
20936         return ret_ref;
20937 }
20938
20939 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
20940         LDKErroringMessageHandler this_arg_conv;
20941         this_arg_conv.inner = (void*)(this_arg & (~1));
20942         this_arg_conv.is_owned = false;
20943         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
20944         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
20945         return (uint64_t)ret_ret;
20946 }
20947
20948 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
20949         LDKErroringMessageHandler this_arg_conv;
20950         this_arg_conv.inner = (void*)(this_arg & (~1));
20951         this_arg_conv.is_owned = false;
20952         LDKChannelMessageHandler* ret_ret =MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
20953         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
20954         return (uint64_t)ret_ret;
20955 }
20956
20957 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) {
20958         LDKMessageHandler this_obj_conv;
20959         this_obj_conv.inner = (void*)(this_obj & (~1));
20960         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20961         MessageHandler_free(this_obj_conv);
20962 }
20963
20964 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
20965         LDKMessageHandler this_ptr_conv;
20966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20967         this_ptr_conv.is_owned = false;
20968         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
20969         return ret_ret;
20970 }
20971
20972 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
20973         LDKMessageHandler this_ptr_conv;
20974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20975         this_ptr_conv.is_owned = false;
20976         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
20977         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
20978 }
20979
20980 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
20981         LDKMessageHandler this_ptr_conv;
20982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20983         this_ptr_conv.is_owned = false;
20984         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
20985         return ret_ret;
20986 }
20987
20988 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
20989         LDKMessageHandler this_ptr_conv;
20990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20991         this_ptr_conv.is_owned = false;
20992         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
20993         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
20994 }
20995
20996 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
20997         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
20998         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
20999         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
21000         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21001         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21002         uint64_t ret_ref = (uint64_t)ret_var.inner;
21003         if (ret_var.is_owned) {
21004                 ret_ref |= 1;
21005         }
21006         return ret_ref;
21007 }
21008
21009 uint32_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
21010         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
21011         LDKSocketDescriptor* ret_ret =MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
21012         *ret_ret = SocketDescriptor_clone(orig_conv);
21013         return (uint64_t)ret_ret;
21014 }
21015
21016 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
21017         if ((this_ptr & 1) != 0) return;
21018         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
21019         FREE((void*)this_ptr);
21020         SocketDescriptor_free(this_ptr_conv);
21021 }
21022
21023 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_obj) {
21024         LDKPeerHandleError this_obj_conv;
21025         this_obj_conv.inner = (void*)(this_obj & (~1));
21026         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21027         PeerHandleError_free(this_obj_conv);
21028 }
21029
21030 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
21031         LDKPeerHandleError this_ptr_conv;
21032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21033         this_ptr_conv.is_owned = false;
21034         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
21035         return ret_val;
21036 }
21037
21038 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
21039         LDKPeerHandleError this_ptr_conv;
21040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21041         this_ptr_conv.is_owned = false;
21042         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
21043 }
21044
21045 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
21046         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
21047         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21048         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21049         uint64_t ret_ref = (uint64_t)ret_var.inner;
21050         if (ret_var.is_owned) {
21051                 ret_ref |= 1;
21052         }
21053         return ret_ref;
21054 }
21055
21056 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32_t orig) {
21057         LDKPeerHandleError orig_conv;
21058         orig_conv.inner = (void*)(orig & (~1));
21059         orig_conv.is_owned = false;
21060         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
21061         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21062         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21063         uint64_t ret_ref = (uint64_t)ret_var.inner;
21064         if (ret_var.is_owned) {
21065                 ret_ref |= 1;
21066         }
21067         return ret_ref;
21068 }
21069
21070 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_obj) {
21071         LDKPeerManager this_obj_conv;
21072         this_obj_conv.inner = (void*)(this_obj & (~1));
21073         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21074         PeerManager_free(this_obj_conv);
21075 }
21076
21077 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) {
21078         LDKMessageHandler message_handler_conv;
21079         message_handler_conv.inner = (void*)(message_handler & (~1));
21080         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
21081         // Warning: we need a move here but no clone is available for LDKMessageHandler
21082         LDKSecretKey our_node_secret_ref;
21083         CHECK(*((uint32_t*)our_node_secret) == 32);
21084         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
21085         unsigned char ephemeral_random_data_arr[32];
21086         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
21087         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
21088         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
21089         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
21090         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(((uint64_t)custom_message_handler) & ~1);
21091         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
21092         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21093         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21094         uint64_t ret_ref = (uint64_t)ret_var.inner;
21095         if (ret_var.is_owned) {
21096                 ret_ref |= 1;
21097         }
21098         return ret_ref;
21099 }
21100
21101 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
21102         LDKPeerManager this_arg_conv;
21103         this_arg_conv.inner = (void*)(this_arg & (~1));
21104         this_arg_conv.is_owned = false;
21105         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
21106         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
21107         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
21108         for (size_t m = 0; m < ret_var.datalen; m++) {
21109                 int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21110                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
21111                 ret_arr_ptr[m] = ret_conv_12_arr;
21112         }
21113         FREE(ret_var.data);
21114         return ret_arr;
21115 }
21116
21117 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
21118         LDKPeerManager this_arg_conv;
21119         this_arg_conv.inner = (void*)(this_arg & (~1));
21120         this_arg_conv.is_owned = false;
21121         LDKPublicKey their_node_id_ref;
21122         CHECK(*((uint32_t*)their_node_id) == 33);
21123         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
21124         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21125         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21126         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
21127         return (uint64_t)ret_conv;
21128 }
21129
21130 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
21131         LDKPeerManager this_arg_conv;
21132         this_arg_conv.inner = (void*)(this_arg & (~1));
21133         this_arg_conv.is_owned = false;
21134         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21135         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21136         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
21137         return (uint64_t)ret_conv;
21138 }
21139
21140 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
21141         LDKPeerManager this_arg_conv;
21142         this_arg_conv.inner = (void*)(this_arg & (~1));
21143         this_arg_conv.is_owned = false;
21144         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21145         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21146         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
21147         return (uint64_t)ret_conv;
21148 }
21149
21150 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
21151         LDKPeerManager this_arg_conv;
21152         this_arg_conv.inner = (void*)(this_arg & (~1));
21153         this_arg_conv.is_owned = false;
21154         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
21155         LDKu8slice data_ref;
21156         data_ref.datalen = *((uint32_t*)data);
21157         data_ref.data = (int8_t*)(data + 4);
21158         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21159         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
21160         return (uint64_t)ret_conv;
21161 }
21162
21163 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
21164         LDKPeerManager this_arg_conv;
21165         this_arg_conv.inner = (void*)(this_arg & (~1));
21166         this_arg_conv.is_owned = false;
21167         PeerManager_process_events(&this_arg_conv);
21168 }
21169
21170 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
21171         LDKPeerManager this_arg_conv;
21172         this_arg_conv.inner = (void*)(this_arg & (~1));
21173         this_arg_conv.is_owned = false;
21174         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
21175         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
21176 }
21177
21178 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
21179         LDKPeerManager this_arg_conv;
21180         this_arg_conv.inner = (void*)(this_arg & (~1));
21181         this_arg_conv.is_owned = false;
21182         LDKPublicKey node_id_ref;
21183         CHECK(*((uint32_t*)node_id) == 33);
21184         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
21185         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
21186 }
21187
21188 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
21189         LDKPeerManager this_arg_conv;
21190         this_arg_conv.inner = (void*)(this_arg & (~1));
21191         this_arg_conv.is_owned = false;
21192         PeerManager_timer_tick_occurred(&this_arg_conv);
21193 }
21194
21195 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
21196         unsigned char commitment_seed_arr[32];
21197         CHECK(*((uint32_t*)commitment_seed) == 32);
21198         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
21199         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
21200         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21201         memcpy((uint8_t*)(ret_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
21202         return ret_arr;
21203 }
21204
21205 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) {
21206         LDKCVec_u8Z to_holder_script_ref;
21207         to_holder_script_ref.datalen = *((uint32_t*)to_holder_script);
21208         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
21209         memcpy(to_holder_script_ref.data, (uint8_t*)(to_holder_script + 4), to_holder_script_ref.datalen);
21210         LDKCVec_u8Z to_counterparty_script_ref;
21211         to_counterparty_script_ref.datalen = *((uint32_t*)to_counterparty_script);
21212         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
21213         memcpy(to_counterparty_script_ref.data, (uint8_t*)(to_counterparty_script + 4), to_counterparty_script_ref.datalen);
21214         LDKOutPoint funding_outpoint_conv;
21215         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
21216         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
21217         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
21218         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);
21219         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21220         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21221         Transaction_free(ret_var);
21222         return ret_arr;
21223 }
21224
21225 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
21226         LDKPublicKey per_commitment_point_ref;
21227         CHECK(*((uint32_t*)per_commitment_point) == 33);
21228         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
21229         unsigned char base_secret_arr[32];
21230         CHECK(*((uint32_t*)base_secret) == 32);
21231         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
21232         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
21233         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
21234         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
21235         return (uint64_t)ret_conv;
21236 }
21237
21238 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
21239         LDKPublicKey per_commitment_point_ref;
21240         CHECK(*((uint32_t*)per_commitment_point) == 33);
21241         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
21242         LDKPublicKey base_point_ref;
21243         CHECK(*((uint32_t*)base_point) == 33);
21244         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
21245         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21246         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
21247         return (uint64_t)ret_conv;
21248 }
21249
21250 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
21251         unsigned char per_commitment_secret_arr[32];
21252         CHECK(*((uint32_t*)per_commitment_secret) == 32);
21253         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
21254         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
21255         unsigned char countersignatory_revocation_base_secret_arr[32];
21256         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
21257         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
21258         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
21259         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
21260         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
21261         return (uint64_t)ret_conv;
21262 }
21263
21264 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
21265         LDKPublicKey per_commitment_point_ref;
21266         CHECK(*((uint32_t*)per_commitment_point) == 33);
21267         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
21268         LDKPublicKey countersignatory_revocation_base_point_ref;
21269         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
21270         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
21271         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21272         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
21273         return (uint64_t)ret_conv;
21274 }
21275
21276 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_obj) {
21277         LDKTxCreationKeys this_obj_conv;
21278         this_obj_conv.inner = (void*)(this_obj & (~1));
21279         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21280         TxCreationKeys_free(this_obj_conv);
21281 }
21282
21283 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
21284         LDKTxCreationKeys this_ptr_conv;
21285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21286         this_ptr_conv.is_owned = false;
21287         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21288         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
21289         return ret_arr;
21290 }
21291
21292 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
21293         LDKTxCreationKeys this_ptr_conv;
21294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21295         this_ptr_conv.is_owned = false;
21296         LDKPublicKey val_ref;
21297         CHECK(*((uint32_t*)val) == 33);
21298         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21299         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
21300 }
21301
21302 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
21303         LDKTxCreationKeys this_ptr_conv;
21304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21305         this_ptr_conv.is_owned = false;
21306         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21307         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
21308         return ret_arr;
21309 }
21310
21311 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
21312         LDKTxCreationKeys this_ptr_conv;
21313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21314         this_ptr_conv.is_owned = false;
21315         LDKPublicKey val_ref;
21316         CHECK(*((uint32_t*)val) == 33);
21317         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21318         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
21319 }
21320
21321 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
21322         LDKTxCreationKeys this_ptr_conv;
21323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21324         this_ptr_conv.is_owned = false;
21325         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21326         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
21327         return ret_arr;
21328 }
21329
21330 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
21331         LDKTxCreationKeys this_ptr_conv;
21332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21333         this_ptr_conv.is_owned = false;
21334         LDKPublicKey val_ref;
21335         CHECK(*((uint32_t*)val) == 33);
21336         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21337         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
21338 }
21339
21340 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
21341         LDKTxCreationKeys this_ptr_conv;
21342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21343         this_ptr_conv.is_owned = false;
21344         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21345         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
21346         return ret_arr;
21347 }
21348
21349 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
21350         LDKTxCreationKeys this_ptr_conv;
21351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21352         this_ptr_conv.is_owned = false;
21353         LDKPublicKey val_ref;
21354         CHECK(*((uint32_t*)val) == 33);
21355         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21356         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
21357 }
21358
21359 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
21360         LDKTxCreationKeys this_ptr_conv;
21361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21362         this_ptr_conv.is_owned = false;
21363         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21364         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
21365         return ret_arr;
21366 }
21367
21368 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
21369         LDKTxCreationKeys this_ptr_conv;
21370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21371         this_ptr_conv.is_owned = false;
21372         LDKPublicKey val_ref;
21373         CHECK(*((uint32_t*)val) == 33);
21374         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21375         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
21376 }
21377
21378 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) {
21379         LDKPublicKey per_commitment_point_arg_ref;
21380         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
21381         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
21382         LDKPublicKey revocation_key_arg_ref;
21383         CHECK(*((uint32_t*)revocation_key_arg) == 33);
21384         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
21385         LDKPublicKey broadcaster_htlc_key_arg_ref;
21386         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
21387         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
21388         LDKPublicKey countersignatory_htlc_key_arg_ref;
21389         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
21390         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
21391         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
21392         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
21393         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
21394         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);
21395         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21396         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21397         uint64_t ret_ref = (uint64_t)ret_var.inner;
21398         if (ret_var.is_owned) {
21399                 ret_ref |= 1;
21400         }
21401         return ret_ref;
21402 }
21403
21404 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
21405         LDKTxCreationKeys orig_conv;
21406         orig_conv.inner = (void*)(orig & (~1));
21407         orig_conv.is_owned = false;
21408         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
21409         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21410         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21411         uint64_t ret_ref = (uint64_t)ret_var.inner;
21412         if (ret_var.is_owned) {
21413                 ret_ref |= 1;
21414         }
21415         return ret_ref;
21416 }
21417
21418 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
21419         LDKTxCreationKeys obj_conv;
21420         obj_conv.inner = (void*)(obj & (~1));
21421         obj_conv.is_owned = false;
21422         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
21423         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21424         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21425         CVec_u8Z_free(ret_var);
21426         return ret_arr;
21427 }
21428
21429 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
21430         LDKu8slice ser_ref;
21431         ser_ref.datalen = *((uint32_t*)ser);
21432         ser_ref.data = (int8_t*)(ser + 4);
21433         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
21434         *ret_conv = TxCreationKeys_read(ser_ref);
21435         return (uint64_t)ret_conv;
21436 }
21437
21438 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
21439         LDKChannelPublicKeys this_obj_conv;
21440         this_obj_conv.inner = (void*)(this_obj & (~1));
21441         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21442         ChannelPublicKeys_free(this_obj_conv);
21443 }
21444
21445 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
21446         LDKChannelPublicKeys this_ptr_conv;
21447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21448         this_ptr_conv.is_owned = false;
21449         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21450         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
21451         return ret_arr;
21452 }
21453
21454 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
21455         LDKChannelPublicKeys this_ptr_conv;
21456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21457         this_ptr_conv.is_owned = false;
21458         LDKPublicKey val_ref;
21459         CHECK(*((uint32_t*)val) == 33);
21460         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21461         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
21462 }
21463
21464 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
21465         LDKChannelPublicKeys this_ptr_conv;
21466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21467         this_ptr_conv.is_owned = false;
21468         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21469         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
21470         return ret_arr;
21471 }
21472
21473 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
21474         LDKChannelPublicKeys this_ptr_conv;
21475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21476         this_ptr_conv.is_owned = false;
21477         LDKPublicKey val_ref;
21478         CHECK(*((uint32_t*)val) == 33);
21479         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21480         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
21481 }
21482
21483 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
21484         LDKChannelPublicKeys this_ptr_conv;
21485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21486         this_ptr_conv.is_owned = false;
21487         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21488         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
21489         return ret_arr;
21490 }
21491
21492 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
21493         LDKChannelPublicKeys this_ptr_conv;
21494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21495         this_ptr_conv.is_owned = false;
21496         LDKPublicKey val_ref;
21497         CHECK(*((uint32_t*)val) == 33);
21498         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21499         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
21500 }
21501
21502 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
21503         LDKChannelPublicKeys this_ptr_conv;
21504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21505         this_ptr_conv.is_owned = false;
21506         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21507         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
21508         return ret_arr;
21509 }
21510
21511 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
21512         LDKChannelPublicKeys this_ptr_conv;
21513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21514         this_ptr_conv.is_owned = false;
21515         LDKPublicKey val_ref;
21516         CHECK(*((uint32_t*)val) == 33);
21517         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21518         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
21519 }
21520
21521 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
21522         LDKChannelPublicKeys this_ptr_conv;
21523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21524         this_ptr_conv.is_owned = false;
21525         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21526         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
21527         return ret_arr;
21528 }
21529
21530 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
21531         LDKChannelPublicKeys this_ptr_conv;
21532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21533         this_ptr_conv.is_owned = false;
21534         LDKPublicKey val_ref;
21535         CHECK(*((uint32_t*)val) == 33);
21536         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21537         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
21538 }
21539
21540 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) {
21541         LDKPublicKey funding_pubkey_arg_ref;
21542         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
21543         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
21544         LDKPublicKey revocation_basepoint_arg_ref;
21545         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
21546         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
21547         LDKPublicKey payment_point_arg_ref;
21548         CHECK(*((uint32_t*)payment_point_arg) == 33);
21549         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
21550         LDKPublicKey delayed_payment_basepoint_arg_ref;
21551         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
21552         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
21553         LDKPublicKey htlc_basepoint_arg_ref;
21554         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
21555         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
21556         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);
21557         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21558         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21559         uint64_t ret_ref = (uint64_t)ret_var.inner;
21560         if (ret_var.is_owned) {
21561                 ret_ref |= 1;
21562         }
21563         return ret_ref;
21564 }
21565
21566 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
21567         LDKChannelPublicKeys orig_conv;
21568         orig_conv.inner = (void*)(orig & (~1));
21569         orig_conv.is_owned = false;
21570         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
21571         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21572         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21573         uint64_t ret_ref = (uint64_t)ret_var.inner;
21574         if (ret_var.is_owned) {
21575                 ret_ref |= 1;
21576         }
21577         return ret_ref;
21578 }
21579
21580 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
21581         LDKChannelPublicKeys obj_conv;
21582         obj_conv.inner = (void*)(obj & (~1));
21583         obj_conv.is_owned = false;
21584         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
21585         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21586         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21587         CVec_u8Z_free(ret_var);
21588         return ret_arr;
21589 }
21590
21591 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
21592         LDKu8slice ser_ref;
21593         ser_ref.datalen = *((uint32_t*)ser);
21594         ser_ref.data = (int8_t*)(ser + 4);
21595         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
21596         *ret_conv = ChannelPublicKeys_read(ser_ref);
21597         return (uint64_t)ret_conv;
21598 }
21599
21600 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) {
21601         LDKPublicKey per_commitment_point_ref;
21602         CHECK(*((uint32_t*)per_commitment_point) == 33);
21603         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
21604         LDKPublicKey broadcaster_delayed_payment_base_ref;
21605         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
21606         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
21607         LDKPublicKey broadcaster_htlc_base_ref;
21608         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
21609         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
21610         LDKPublicKey countersignatory_revocation_base_ref;
21611         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
21612         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
21613         LDKPublicKey countersignatory_htlc_base_ref;
21614         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
21615         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
21616         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
21617         *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);
21618         return (uint64_t)ret_conv;
21619 }
21620
21621 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
21622         LDKPublicKey per_commitment_point_ref;
21623         CHECK(*((uint32_t*)per_commitment_point) == 33);
21624         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
21625         LDKChannelPublicKeys broadcaster_keys_conv;
21626         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
21627         broadcaster_keys_conv.is_owned = false;
21628         LDKChannelPublicKeys countersignatory_keys_conv;
21629         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
21630         countersignatory_keys_conv.is_owned = false;
21631         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
21632         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
21633         return (uint64_t)ret_conv;
21634 }
21635
21636 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
21637         LDKPublicKey revocation_key_ref;
21638         CHECK(*((uint32_t*)revocation_key) == 33);
21639         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
21640         LDKPublicKey broadcaster_delayed_payment_key_ref;
21641         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
21642         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
21643         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
21644         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21645         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21646         CVec_u8Z_free(ret_var);
21647         return ret_arr;
21648 }
21649
21650 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
21651         LDKHTLCOutputInCommitment this_obj_conv;
21652         this_obj_conv.inner = (void*)(this_obj & (~1));
21653         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21654         HTLCOutputInCommitment_free(this_obj_conv);
21655 }
21656
21657 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
21658         LDKHTLCOutputInCommitment this_ptr_conv;
21659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21660         this_ptr_conv.is_owned = false;
21661         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
21662         return ret_val;
21663 }
21664
21665 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
21666         LDKHTLCOutputInCommitment this_ptr_conv;
21667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21668         this_ptr_conv.is_owned = false;
21669         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
21670 }
21671
21672 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
21673         LDKHTLCOutputInCommitment this_ptr_conv;
21674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21675         this_ptr_conv.is_owned = false;
21676         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
21677         return ret_val;
21678 }
21679
21680 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
21681         LDKHTLCOutputInCommitment this_ptr_conv;
21682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21683         this_ptr_conv.is_owned = false;
21684         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
21685 }
21686
21687 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
21688         LDKHTLCOutputInCommitment this_ptr_conv;
21689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21690         this_ptr_conv.is_owned = false;
21691         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
21692         return ret_val;
21693 }
21694
21695 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
21696         LDKHTLCOutputInCommitment this_ptr_conv;
21697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21698         this_ptr_conv.is_owned = false;
21699         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
21700 }
21701
21702 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
21703         LDKHTLCOutputInCommitment this_ptr_conv;
21704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21705         this_ptr_conv.is_owned = false;
21706         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21707         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
21708         return ret_arr;
21709 }
21710
21711 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
21712         LDKHTLCOutputInCommitment this_ptr_conv;
21713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21714         this_ptr_conv.is_owned = false;
21715         LDKThirtyTwoBytes val_ref;
21716         CHECK(*((uint32_t*)val) == 32);
21717         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
21718         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
21719 }
21720
21721 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
21722         LDKHTLCOutputInCommitment this_ptr_conv;
21723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21724         this_ptr_conv.is_owned = false;
21725         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
21726         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
21727         uint64_t ret_ref = (uint64_t)ret_copy;
21728         return ret_ref;
21729 }
21730
21731 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
21732         LDKHTLCOutputInCommitment this_ptr_conv;
21733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21734         this_ptr_conv.is_owned = false;
21735         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
21736         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
21737         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
21738 }
21739
21740 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) {
21741         LDKThirtyTwoBytes payment_hash_arg_ref;
21742         CHECK(*((uint32_t*)payment_hash_arg) == 32);
21743         memcpy(payment_hash_arg_ref.data, (uint8_t*)(payment_hash_arg + 4), 32);
21744         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
21745         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1));
21746         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
21747         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21748         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21749         uint64_t ret_ref = (uint64_t)ret_var.inner;
21750         if (ret_var.is_owned) {
21751                 ret_ref |= 1;
21752         }
21753         return ret_ref;
21754 }
21755
21756 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
21757         LDKHTLCOutputInCommitment orig_conv;
21758         orig_conv.inner = (void*)(orig & (~1));
21759         orig_conv.is_owned = false;
21760         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
21761         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21762         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21763         uint64_t ret_ref = (uint64_t)ret_var.inner;
21764         if (ret_var.is_owned) {
21765                 ret_ref |= 1;
21766         }
21767         return ret_ref;
21768 }
21769
21770 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
21771         LDKHTLCOutputInCommitment obj_conv;
21772         obj_conv.inner = (void*)(obj & (~1));
21773         obj_conv.is_owned = false;
21774         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
21775         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21776         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21777         CVec_u8Z_free(ret_var);
21778         return ret_arr;
21779 }
21780
21781 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
21782         LDKu8slice ser_ref;
21783         ser_ref.datalen = *((uint32_t*)ser);
21784         ser_ref.data = (int8_t*)(ser + 4);
21785         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
21786         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
21787         return (uint64_t)ret_conv;
21788 }
21789
21790 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
21791         LDKHTLCOutputInCommitment htlc_conv;
21792         htlc_conv.inner = (void*)(htlc & (~1));
21793         htlc_conv.is_owned = false;
21794         LDKTxCreationKeys keys_conv;
21795         keys_conv.inner = (void*)(keys & (~1));
21796         keys_conv.is_owned = false;
21797         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
21798         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21799         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21800         CVec_u8Z_free(ret_var);
21801         return ret_arr;
21802 }
21803
21804 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
21805         LDKPublicKey broadcaster_ref;
21806         CHECK(*((uint32_t*)broadcaster) == 33);
21807         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
21808         LDKPublicKey countersignatory_ref;
21809         CHECK(*((uint32_t*)countersignatory) == 33);
21810         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
21811         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
21812         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21813         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21814         CVec_u8Z_free(ret_var);
21815         return ret_arr;
21816 }
21817
21818 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) {
21819         unsigned char commitment_txid_arr[32];
21820         CHECK(*((uint32_t*)commitment_txid) == 32);
21821         memcpy(commitment_txid_arr, (uint8_t*)(commitment_txid + 4), 32);
21822         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
21823         LDKHTLCOutputInCommitment htlc_conv;
21824         htlc_conv.inner = (void*)(htlc & (~1));
21825         htlc_conv.is_owned = false;
21826         LDKPublicKey broadcaster_delayed_payment_key_ref;
21827         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
21828         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
21829         LDKPublicKey revocation_key_ref;
21830         CHECK(*((uint32_t*)revocation_key) == 33);
21831         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
21832         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
21833         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
21834         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
21835         Transaction_free(ret_var);
21836         return ret_arr;
21837 }
21838
21839 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
21840         LDKChannelTransactionParameters this_obj_conv;
21841         this_obj_conv.inner = (void*)(this_obj & (~1));
21842         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21843         ChannelTransactionParameters_free(this_obj_conv);
21844 }
21845
21846 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
21847         LDKChannelTransactionParameters this_ptr_conv;
21848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21849         this_ptr_conv.is_owned = false;
21850         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
21851         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21852         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21853         uint64_t ret_ref = (uint64_t)ret_var.inner;
21854         if (ret_var.is_owned) {
21855                 ret_ref |= 1;
21856         }
21857         return ret_ref;
21858 }
21859
21860 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
21861         LDKChannelTransactionParameters this_ptr_conv;
21862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21863         this_ptr_conv.is_owned = false;
21864         LDKChannelPublicKeys val_conv;
21865         val_conv.inner = (void*)(val & (~1));
21866         val_conv.is_owned = (val & 1) || (val == 0);
21867         val_conv = ChannelPublicKeys_clone(&val_conv);
21868         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
21869 }
21870
21871 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
21872         LDKChannelTransactionParameters this_ptr_conv;
21873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21874         this_ptr_conv.is_owned = false;
21875         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
21876         return ret_val;
21877 }
21878
21879 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
21880         LDKChannelTransactionParameters this_ptr_conv;
21881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21882         this_ptr_conv.is_owned = false;
21883         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
21884 }
21885
21886 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
21887         LDKChannelTransactionParameters this_ptr_conv;
21888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21889         this_ptr_conv.is_owned = false;
21890         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
21891         return ret_val;
21892 }
21893
21894 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
21895         LDKChannelTransactionParameters this_ptr_conv;
21896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21897         this_ptr_conv.is_owned = false;
21898         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
21899 }
21900
21901 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
21902         LDKChannelTransactionParameters this_ptr_conv;
21903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21904         this_ptr_conv.is_owned = false;
21905         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
21906         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21907         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21908         uint64_t ret_ref = (uint64_t)ret_var.inner;
21909         if (ret_var.is_owned) {
21910                 ret_ref |= 1;
21911         }
21912         return ret_ref;
21913 }
21914
21915 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
21916         LDKChannelTransactionParameters this_ptr_conv;
21917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21918         this_ptr_conv.is_owned = false;
21919         LDKCounterpartyChannelTransactionParameters val_conv;
21920         val_conv.inner = (void*)(val & (~1));
21921         val_conv.is_owned = (val & 1) || (val == 0);
21922         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
21923         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
21924 }
21925
21926 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
21927         LDKChannelTransactionParameters this_ptr_conv;
21928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21929         this_ptr_conv.is_owned = false;
21930         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
21931         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21932         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21933         uint64_t ret_ref = (uint64_t)ret_var.inner;
21934         if (ret_var.is_owned) {
21935                 ret_ref |= 1;
21936         }
21937         return ret_ref;
21938 }
21939
21940 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
21941         LDKChannelTransactionParameters this_ptr_conv;
21942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21943         this_ptr_conv.is_owned = false;
21944         LDKOutPoint val_conv;
21945         val_conv.inner = (void*)(val & (~1));
21946         val_conv.is_owned = (val & 1) || (val == 0);
21947         val_conv = OutPoint_clone(&val_conv);
21948         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
21949 }
21950
21951 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) {
21952         LDKChannelPublicKeys holder_pubkeys_arg_conv;
21953         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
21954         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
21955         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
21956         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
21957         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
21958         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
21959         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
21960         LDKOutPoint funding_outpoint_arg_conv;
21961         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
21962         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
21963         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
21964         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);
21965         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21966         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21967         uint64_t ret_ref = (uint64_t)ret_var.inner;
21968         if (ret_var.is_owned) {
21969                 ret_ref |= 1;
21970         }
21971         return ret_ref;
21972 }
21973
21974 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
21975         LDKChannelTransactionParameters orig_conv;
21976         orig_conv.inner = (void*)(orig & (~1));
21977         orig_conv.is_owned = false;
21978         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
21979         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21980         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21981         uint64_t ret_ref = (uint64_t)ret_var.inner;
21982         if (ret_var.is_owned) {
21983                 ret_ref |= 1;
21984         }
21985         return ret_ref;
21986 }
21987
21988 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
21989         LDKCounterpartyChannelTransactionParameters this_obj_conv;
21990         this_obj_conv.inner = (void*)(this_obj & (~1));
21991         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21992         CounterpartyChannelTransactionParameters_free(this_obj_conv);
21993 }
21994
21995 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
21996         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
21997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21998         this_ptr_conv.is_owned = false;
21999         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
22000         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22001         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22002         uint64_t ret_ref = (uint64_t)ret_var.inner;
22003         if (ret_var.is_owned) {
22004                 ret_ref |= 1;
22005         }
22006         return ret_ref;
22007 }
22008
22009 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
22010         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22012         this_ptr_conv.is_owned = false;
22013         LDKChannelPublicKeys val_conv;
22014         val_conv.inner = (void*)(val & (~1));
22015         val_conv.is_owned = (val & 1) || (val == 0);
22016         val_conv = ChannelPublicKeys_clone(&val_conv);
22017         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
22018 }
22019
22020 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
22021         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22023         this_ptr_conv.is_owned = false;
22024         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
22025         return ret_val;
22026 }
22027
22028 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
22029         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22031         this_ptr_conv.is_owned = false;
22032         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
22033 }
22034
22035 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
22036         LDKChannelPublicKeys pubkeys_arg_conv;
22037         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
22038         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
22039         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
22040         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
22041         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22042         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22043         uint64_t ret_ref = (uint64_t)ret_var.inner;
22044         if (ret_var.is_owned) {
22045                 ret_ref |= 1;
22046         }
22047         return ret_ref;
22048 }
22049
22050 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
22051         LDKCounterpartyChannelTransactionParameters orig_conv;
22052         orig_conv.inner = (void*)(orig & (~1));
22053         orig_conv.is_owned = false;
22054         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
22055         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22056         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22057         uint64_t ret_ref = (uint64_t)ret_var.inner;
22058         if (ret_var.is_owned) {
22059                 ret_ref |= 1;
22060         }
22061         return ret_ref;
22062 }
22063
22064 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
22065         LDKChannelTransactionParameters this_arg_conv;
22066         this_arg_conv.inner = (void*)(this_arg & (~1));
22067         this_arg_conv.is_owned = false;
22068         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
22069         return ret_val;
22070 }
22071
22072 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
22073         LDKChannelTransactionParameters this_arg_conv;
22074         this_arg_conv.inner = (void*)(this_arg & (~1));
22075         this_arg_conv.is_owned = false;
22076         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
22077         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22078         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22079         uint64_t ret_ref = (uint64_t)ret_var.inner;
22080         if (ret_var.is_owned) {
22081                 ret_ref |= 1;
22082         }
22083         return ret_ref;
22084 }
22085
22086 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
22087         LDKChannelTransactionParameters this_arg_conv;
22088         this_arg_conv.inner = (void*)(this_arg & (~1));
22089         this_arg_conv.is_owned = false;
22090         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
22091         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22092         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22093         uint64_t ret_ref = (uint64_t)ret_var.inner;
22094         if (ret_var.is_owned) {
22095                 ret_ref |= 1;
22096         }
22097         return ret_ref;
22098 }
22099
22100 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
22101         LDKCounterpartyChannelTransactionParameters obj_conv;
22102         obj_conv.inner = (void*)(obj & (~1));
22103         obj_conv.is_owned = false;
22104         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
22105         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22106         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22107         CVec_u8Z_free(ret_var);
22108         return ret_arr;
22109 }
22110
22111 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
22112         LDKu8slice ser_ref;
22113         ser_ref.datalen = *((uint32_t*)ser);
22114         ser_ref.data = (int8_t*)(ser + 4);
22115         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
22116         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
22117         return (uint64_t)ret_conv;
22118 }
22119
22120 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
22121         LDKChannelTransactionParameters obj_conv;
22122         obj_conv.inner = (void*)(obj & (~1));
22123         obj_conv.is_owned = false;
22124         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
22125         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22126         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22127         CVec_u8Z_free(ret_var);
22128         return ret_arr;
22129 }
22130
22131 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
22132         LDKu8slice ser_ref;
22133         ser_ref.datalen = *((uint32_t*)ser);
22134         ser_ref.data = (int8_t*)(ser + 4);
22135         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
22136         *ret_conv = ChannelTransactionParameters_read(ser_ref);
22137         return (uint64_t)ret_conv;
22138 }
22139
22140 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
22141         LDKDirectedChannelTransactionParameters 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         DirectedChannelTransactionParameters_free(this_obj_conv);
22145 }
22146
22147 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
22148         LDKDirectedChannelTransactionParameters this_arg_conv;
22149         this_arg_conv.inner = (void*)(this_arg & (~1));
22150         this_arg_conv.is_owned = false;
22151         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
22152         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22153         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22154         uint64_t ret_ref = (uint64_t)ret_var.inner;
22155         if (ret_var.is_owned) {
22156                 ret_ref |= 1;
22157         }
22158         return ret_ref;
22159 }
22160
22161 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
22162         LDKDirectedChannelTransactionParameters this_arg_conv;
22163         this_arg_conv.inner = (void*)(this_arg & (~1));
22164         this_arg_conv.is_owned = false;
22165         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
22166         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22167         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22168         uint64_t ret_ref = (uint64_t)ret_var.inner;
22169         if (ret_var.is_owned) {
22170                 ret_ref |= 1;
22171         }
22172         return ret_ref;
22173 }
22174
22175 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
22176         LDKDirectedChannelTransactionParameters this_arg_conv;
22177         this_arg_conv.inner = (void*)(this_arg & (~1));
22178         this_arg_conv.is_owned = false;
22179         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
22180         return ret_val;
22181 }
22182
22183 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
22184         LDKDirectedChannelTransactionParameters this_arg_conv;
22185         this_arg_conv.inner = (void*)(this_arg & (~1));
22186         this_arg_conv.is_owned = false;
22187         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
22188         return ret_val;
22189 }
22190
22191 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
22192         LDKDirectedChannelTransactionParameters this_arg_conv;
22193         this_arg_conv.inner = (void*)(this_arg & (~1));
22194         this_arg_conv.is_owned = false;
22195         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
22196         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22197         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22198         uint64_t ret_ref = (uint64_t)ret_var.inner;
22199         if (ret_var.is_owned) {
22200                 ret_ref |= 1;
22201         }
22202         return ret_ref;
22203 }
22204
22205 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
22206         LDKHolderCommitmentTransaction this_obj_conv;
22207         this_obj_conv.inner = (void*)(this_obj & (~1));
22208         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22209         HolderCommitmentTransaction_free(this_obj_conv);
22210 }
22211
22212 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
22213         LDKHolderCommitmentTransaction this_ptr_conv;
22214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22215         this_ptr_conv.is_owned = false;
22216         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
22217         memcpy((uint8_t*)(ret_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
22218         return ret_arr;
22219 }
22220
22221 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
22222         LDKHolderCommitmentTransaction this_ptr_conv;
22223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22224         this_ptr_conv.is_owned = false;
22225         LDKSignature val_ref;
22226         CHECK(*((uint32_t*)val) == 64);
22227         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
22228         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
22229 }
22230
22231 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
22232         LDKHolderCommitmentTransaction this_ptr_conv;
22233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22234         this_ptr_conv.is_owned = false;
22235         LDKCVec_SignatureZ val_constr;
22236         val_constr.datalen = *((uint32_t*)val);
22237         if (val_constr.datalen > 0)
22238                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
22239         else
22240                 val_constr.data = NULL;
22241         int8_tArray* val_vals = (int8_tArray*)(val + 4);
22242         for (size_t m = 0; m < val_constr.datalen; m++) {
22243                 int8_tArray val_conv_12 = val_vals[m];
22244                 LDKSignature val_conv_12_ref;
22245                 CHECK(*((uint32_t*)val_conv_12) == 64);
22246                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
22247                 val_constr.data[m] = val_conv_12_ref;
22248         }
22249         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
22250 }
22251
22252 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
22253         LDKHolderCommitmentTransaction orig_conv;
22254         orig_conv.inner = (void*)(orig & (~1));
22255         orig_conv.is_owned = false;
22256         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
22257         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22258         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22259         uint64_t ret_ref = (uint64_t)ret_var.inner;
22260         if (ret_var.is_owned) {
22261                 ret_ref |= 1;
22262         }
22263         return ret_ref;
22264 }
22265
22266 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
22267         LDKHolderCommitmentTransaction obj_conv;
22268         obj_conv.inner = (void*)(obj & (~1));
22269         obj_conv.is_owned = false;
22270         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
22271         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22272         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22273         CVec_u8Z_free(ret_var);
22274         return ret_arr;
22275 }
22276
22277 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
22278         LDKu8slice ser_ref;
22279         ser_ref.datalen = *((uint32_t*)ser);
22280         ser_ref.data = (int8_t*)(ser + 4);
22281         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
22282         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
22283         return (uint64_t)ret_conv;
22284 }
22285
22286 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) {
22287         LDKCommitmentTransaction commitment_tx_conv;
22288         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
22289         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
22290         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
22291         LDKSignature counterparty_sig_ref;
22292         CHECK(*((uint32_t*)counterparty_sig) == 64);
22293         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
22294         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
22295         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
22296         if (counterparty_htlc_sigs_constr.datalen > 0)
22297                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
22298         else
22299                 counterparty_htlc_sigs_constr.data = NULL;
22300         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
22301         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
22302                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
22303                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
22304                 CHECK(*((uint32_t*)counterparty_htlc_sigs_conv_12) == 64);
22305                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, (uint8_t*)(counterparty_htlc_sigs_conv_12 + 4), 64);
22306                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
22307         }
22308         LDKPublicKey holder_funding_key_ref;
22309         CHECK(*((uint32_t*)holder_funding_key) == 33);
22310         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
22311         LDKPublicKey counterparty_funding_key_ref;
22312         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
22313         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
22314         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
22315         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22316         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22317         uint64_t ret_ref = (uint64_t)ret_var.inner;
22318         if (ret_var.is_owned) {
22319                 ret_ref |= 1;
22320         }
22321         return ret_ref;
22322 }
22323
22324 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
22325         LDKBuiltCommitmentTransaction this_obj_conv;
22326         this_obj_conv.inner = (void*)(this_obj & (~1));
22327         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22328         BuiltCommitmentTransaction_free(this_obj_conv);
22329 }
22330
22331 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
22332         LDKBuiltCommitmentTransaction this_ptr_conv;
22333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22334         this_ptr_conv.is_owned = false;
22335         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
22336         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22337         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22338         Transaction_free(ret_var);
22339         return ret_arr;
22340 }
22341
22342 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
22343         LDKBuiltCommitmentTransaction this_ptr_conv;
22344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22345         this_ptr_conv.is_owned = false;
22346         LDKTransaction val_ref;
22347         val_ref.datalen = *((uint32_t*)val);
22348         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
22349         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
22350         val_ref.data_is_owned = true;
22351         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
22352 }
22353
22354 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
22355         LDKBuiltCommitmentTransaction this_ptr_conv;
22356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22357         this_ptr_conv.is_owned = false;
22358         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22359         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
22360         return ret_arr;
22361 }
22362
22363 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
22364         LDKBuiltCommitmentTransaction this_ptr_conv;
22365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22366         this_ptr_conv.is_owned = false;
22367         LDKThirtyTwoBytes val_ref;
22368         CHECK(*((uint32_t*)val) == 32);
22369         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
22370         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
22371 }
22372
22373 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
22374         LDKTransaction transaction_arg_ref;
22375         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
22376         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
22377         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
22378         transaction_arg_ref.data_is_owned = true;
22379         LDKThirtyTwoBytes txid_arg_ref;
22380         CHECK(*((uint32_t*)txid_arg) == 32);
22381         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
22382         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
22383         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22384         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22385         uint64_t ret_ref = (uint64_t)ret_var.inner;
22386         if (ret_var.is_owned) {
22387                 ret_ref |= 1;
22388         }
22389         return ret_ref;
22390 }
22391
22392 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
22393         LDKBuiltCommitmentTransaction orig_conv;
22394         orig_conv.inner = (void*)(orig & (~1));
22395         orig_conv.is_owned = false;
22396         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
22397         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22398         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22399         uint64_t ret_ref = (uint64_t)ret_var.inner;
22400         if (ret_var.is_owned) {
22401                 ret_ref |= 1;
22402         }
22403         return ret_ref;
22404 }
22405
22406 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
22407         LDKBuiltCommitmentTransaction obj_conv;
22408         obj_conv.inner = (void*)(obj & (~1));
22409         obj_conv.is_owned = false;
22410         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
22411         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22412         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22413         CVec_u8Z_free(ret_var);
22414         return ret_arr;
22415 }
22416
22417 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
22418         LDKu8slice ser_ref;
22419         ser_ref.datalen = *((uint32_t*)ser);
22420         ser_ref.data = (int8_t*)(ser + 4);
22421         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
22422         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
22423         return (uint64_t)ret_conv;
22424 }
22425
22426 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
22427         LDKBuiltCommitmentTransaction this_arg_conv;
22428         this_arg_conv.inner = (void*)(this_arg & (~1));
22429         this_arg_conv.is_owned = false;
22430         LDKu8slice funding_redeemscript_ref;
22431         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
22432         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
22433         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22434         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
22435         return ret_arr;
22436 }
22437
22438 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) {
22439         LDKBuiltCommitmentTransaction this_arg_conv;
22440         this_arg_conv.inner = (void*)(this_arg & (~1));
22441         this_arg_conv.is_owned = false;
22442         unsigned char funding_key_arr[32];
22443         CHECK(*((uint32_t*)funding_key) == 32);
22444         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
22445         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
22446         LDKu8slice funding_redeemscript_ref;
22447         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
22448         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
22449         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
22450         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
22451         return ret_arr;
22452 }
22453
22454 void  __attribute__((visibility("default"))) TS_ClosingTransaction_free(uint32_t this_obj) {
22455         LDKClosingTransaction this_obj_conv;
22456         this_obj_conv.inner = (void*)(this_obj & (~1));
22457         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22458         ClosingTransaction_free(this_obj_conv);
22459 }
22460
22461 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) {
22462         LDKCVec_u8Z to_holder_script_ref;
22463         to_holder_script_ref.datalen = *((uint32_t*)to_holder_script);
22464         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
22465         memcpy(to_holder_script_ref.data, (uint8_t*)(to_holder_script + 4), to_holder_script_ref.datalen);
22466         LDKCVec_u8Z to_counterparty_script_ref;
22467         to_counterparty_script_ref.datalen = *((uint32_t*)to_counterparty_script);
22468         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
22469         memcpy(to_counterparty_script_ref.data, (uint8_t*)(to_counterparty_script + 4), to_counterparty_script_ref.datalen);
22470         LDKOutPoint funding_outpoint_conv;
22471         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
22472         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
22473         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
22474         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
22475         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22476         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22477         uint64_t ret_ref = (uint64_t)ret_var.inner;
22478         if (ret_var.is_owned) {
22479                 ret_ref |= 1;
22480         }
22481         return ret_ref;
22482 }
22483
22484 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
22485         LDKClosingTransaction this_arg_conv;
22486         this_arg_conv.inner = (void*)(this_arg & (~1));
22487         this_arg_conv.is_owned = false;
22488         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
22489         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22490         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22491         uint64_t ret_ref = (uint64_t)ret_var.inner;
22492         if (ret_var.is_owned) {
22493                 ret_ref |= 1;
22494         }
22495         return ret_ref;
22496 }
22497
22498 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
22499         LDKClosingTransaction this_arg_conv;
22500         this_arg_conv.inner = (void*)(this_arg & (~1));
22501         this_arg_conv.is_owned = false;
22502         LDKOutPoint funding_outpoint_conv;
22503         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
22504         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
22505         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
22506         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
22507         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
22508         return (uint64_t)ret_conv;
22509 }
22510
22511 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
22512         LDKClosingTransaction this_arg_conv;
22513         this_arg_conv.inner = (void*)(this_arg & (~1));
22514         this_arg_conv.is_owned = false;
22515         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
22516         return ret_val;
22517 }
22518
22519 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
22520         LDKClosingTransaction this_arg_conv;
22521         this_arg_conv.inner = (void*)(this_arg & (~1));
22522         this_arg_conv.is_owned = false;
22523         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
22524         return ret_val;
22525 }
22526
22527 int8_tArray  __attribute__((visibility("default"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
22528         LDKClosingTransaction this_arg_conv;
22529         this_arg_conv.inner = (void*)(this_arg & (~1));
22530         this_arg_conv.is_owned = false;
22531         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
22532         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22533         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22534         return ret_arr;
22535 }
22536
22537 int8_tArray  __attribute__((visibility("default"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
22538         LDKClosingTransaction this_arg_conv;
22539         this_arg_conv.inner = (void*)(this_arg & (~1));
22540         this_arg_conv.is_owned = false;
22541         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
22542         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22543         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22544         return ret_arr;
22545 }
22546
22547 void  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
22548         LDKTrustedClosingTransaction this_obj_conv;
22549         this_obj_conv.inner = (void*)(this_obj & (~1));
22550         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22551         TrustedClosingTransaction_free(this_obj_conv);
22552 }
22553
22554 int8_tArray  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
22555         LDKTrustedClosingTransaction this_arg_conv;
22556         this_arg_conv.inner = (void*)(this_arg & (~1));
22557         this_arg_conv.is_owned = false;
22558         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
22559         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22560         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22561         Transaction_free(ret_var);
22562         return ret_arr;
22563 }
22564
22565 int8_tArray  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
22566         LDKTrustedClosingTransaction this_arg_conv;
22567         this_arg_conv.inner = (void*)(this_arg & (~1));
22568         this_arg_conv.is_owned = false;
22569         LDKu8slice funding_redeemscript_ref;
22570         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
22571         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
22572         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22573         memcpy((uint8_t*)(ret_arr + 4), TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
22574         return ret_arr;
22575 }
22576
22577 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) {
22578         LDKTrustedClosingTransaction this_arg_conv;
22579         this_arg_conv.inner = (void*)(this_arg & (~1));
22580         this_arg_conv.is_owned = false;
22581         unsigned char funding_key_arr[32];
22582         CHECK(*((uint32_t*)funding_key) == 32);
22583         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
22584         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
22585         LDKu8slice funding_redeemscript_ref;
22586         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
22587         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
22588         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
22589         memcpy((uint8_t*)(ret_arr + 4), TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
22590         return ret_arr;
22591 }
22592
22593 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
22594         LDKCommitmentTransaction this_obj_conv;
22595         this_obj_conv.inner = (void*)(this_obj & (~1));
22596         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22597         CommitmentTransaction_free(this_obj_conv);
22598 }
22599
22600 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
22601         LDKCommitmentTransaction orig_conv;
22602         orig_conv.inner = (void*)(orig & (~1));
22603         orig_conv.is_owned = false;
22604         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
22605         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22606         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22607         uint64_t ret_ref = (uint64_t)ret_var.inner;
22608         if (ret_var.is_owned) {
22609                 ret_ref |= 1;
22610         }
22611         return ret_ref;
22612 }
22613
22614 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
22615         LDKCommitmentTransaction obj_conv;
22616         obj_conv.inner = (void*)(obj & (~1));
22617         obj_conv.is_owned = false;
22618         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
22619         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22620         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22621         CVec_u8Z_free(ret_var);
22622         return ret_arr;
22623 }
22624
22625 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
22626         LDKu8slice ser_ref;
22627         ser_ref.datalen = *((uint32_t*)ser);
22628         ser_ref.data = (int8_t*)(ser + 4);
22629         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
22630         *ret_conv = CommitmentTransaction_read(ser_ref);
22631         return (uint64_t)ret_conv;
22632 }
22633
22634 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
22635         LDKCommitmentTransaction this_arg_conv;
22636         this_arg_conv.inner = (void*)(this_arg & (~1));
22637         this_arg_conv.is_owned = false;
22638         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
22639         return ret_val;
22640 }
22641
22642 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
22643         LDKCommitmentTransaction this_arg_conv;
22644         this_arg_conv.inner = (void*)(this_arg & (~1));
22645         this_arg_conv.is_owned = false;
22646         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
22647         return ret_val;
22648 }
22649
22650 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
22651         LDKCommitmentTransaction this_arg_conv;
22652         this_arg_conv.inner = (void*)(this_arg & (~1));
22653         this_arg_conv.is_owned = false;
22654         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
22655         return ret_val;
22656 }
22657
22658 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
22659         LDKCommitmentTransaction this_arg_conv;
22660         this_arg_conv.inner = (void*)(this_arg & (~1));
22661         this_arg_conv.is_owned = false;
22662         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
22663         return ret_val;
22664 }
22665
22666 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
22667         LDKCommitmentTransaction this_arg_conv;
22668         this_arg_conv.inner = (void*)(this_arg & (~1));
22669         this_arg_conv.is_owned = false;
22670         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
22671         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22672         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22673         uint64_t ret_ref = (uint64_t)ret_var.inner;
22674         if (ret_var.is_owned) {
22675                 ret_ref |= 1;
22676         }
22677         return ret_ref;
22678 }
22679
22680 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
22681         LDKCommitmentTransaction this_arg_conv;
22682         this_arg_conv.inner = (void*)(this_arg & (~1));
22683         this_arg_conv.is_owned = false;
22684         LDKDirectedChannelTransactionParameters channel_parameters_conv;
22685         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
22686         channel_parameters_conv.is_owned = false;
22687         LDKChannelPublicKeys broadcaster_keys_conv;
22688         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
22689         broadcaster_keys_conv.is_owned = false;
22690         LDKChannelPublicKeys countersignatory_keys_conv;
22691         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
22692         countersignatory_keys_conv.is_owned = false;
22693         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
22694         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
22695         return (uint64_t)ret_conv;
22696 }
22697
22698 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
22699         LDKTrustedCommitmentTransaction this_obj_conv;
22700         this_obj_conv.inner = (void*)(this_obj & (~1));
22701         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22702         TrustedCommitmentTransaction_free(this_obj_conv);
22703 }
22704
22705 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
22706         LDKTrustedCommitmentTransaction this_arg_conv;
22707         this_arg_conv.inner = (void*)(this_arg & (~1));
22708         this_arg_conv.is_owned = false;
22709         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22710         memcpy((uint8_t*)(ret_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
22711         return ret_arr;
22712 }
22713
22714 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
22715         LDKTrustedCommitmentTransaction this_arg_conv;
22716         this_arg_conv.inner = (void*)(this_arg & (~1));
22717         this_arg_conv.is_owned = false;
22718         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
22719         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22720         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22721         uint64_t ret_ref = (uint64_t)ret_var.inner;
22722         if (ret_var.is_owned) {
22723                 ret_ref |= 1;
22724         }
22725         return ret_ref;
22726 }
22727
22728 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
22729         LDKTrustedCommitmentTransaction this_arg_conv;
22730         this_arg_conv.inner = (void*)(this_arg & (~1));
22731         this_arg_conv.is_owned = false;
22732         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
22733         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22734         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22735         uint64_t ret_ref = (uint64_t)ret_var.inner;
22736         if (ret_var.is_owned) {
22737                 ret_ref |= 1;
22738         }
22739         return ret_ref;
22740 }
22741
22742 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
22743         LDKTrustedCommitmentTransaction this_arg_conv;
22744         this_arg_conv.inner = (void*)(this_arg & (~1));
22745         this_arg_conv.is_owned = false;
22746         unsigned char htlc_base_key_arr[32];
22747         CHECK(*((uint32_t*)htlc_base_key) == 32);
22748         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
22749         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
22750         LDKDirectedChannelTransactionParameters channel_parameters_conv;
22751         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
22752         channel_parameters_conv.is_owned = false;
22753         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
22754         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
22755         return (uint64_t)ret_conv;
22756 }
22757
22758 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) {
22759         LDKPublicKey broadcaster_payment_basepoint_ref;
22760         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
22761         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
22762         LDKPublicKey countersignatory_payment_basepoint_ref;
22763         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
22764         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
22765         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
22766         return ret_val;
22767 }
22768
22769 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
22770         LDKInitFeatures a_conv;
22771         a_conv.inner = (void*)(a & (~1));
22772         a_conv.is_owned = false;
22773         LDKInitFeatures b_conv;
22774         b_conv.inner = (void*)(b & (~1));
22775         b_conv.is_owned = false;
22776         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
22777         return ret_val;
22778 }
22779
22780 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
22781         LDKNodeFeatures a_conv;
22782         a_conv.inner = (void*)(a & (~1));
22783         a_conv.is_owned = false;
22784         LDKNodeFeatures b_conv;
22785         b_conv.inner = (void*)(b & (~1));
22786         b_conv.is_owned = false;
22787         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
22788         return ret_val;
22789 }
22790
22791 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
22792         LDKChannelFeatures a_conv;
22793         a_conv.inner = (void*)(a & (~1));
22794         a_conv.is_owned = false;
22795         LDKChannelFeatures b_conv;
22796         b_conv.inner = (void*)(b & (~1));
22797         b_conv.is_owned = false;
22798         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
22799         return ret_val;
22800 }
22801
22802 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
22803         LDKInvoiceFeatures a_conv;
22804         a_conv.inner = (void*)(a & (~1));
22805         a_conv.is_owned = false;
22806         LDKInvoiceFeatures b_conv;
22807         b_conv.inner = (void*)(b & (~1));
22808         b_conv.is_owned = false;
22809         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
22810         return ret_val;
22811 }
22812
22813 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t orig) {
22814         LDKInitFeatures orig_conv;
22815         orig_conv.inner = (void*)(orig & (~1));
22816         orig_conv.is_owned = false;
22817         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
22818         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22819         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22820         uint64_t ret_ref = (uint64_t)ret_var.inner;
22821         if (ret_var.is_owned) {
22822                 ret_ref |= 1;
22823         }
22824         return ret_ref;
22825 }
22826
22827 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t orig) {
22828         LDKNodeFeatures orig_conv;
22829         orig_conv.inner = (void*)(orig & (~1));
22830         orig_conv.is_owned = false;
22831         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
22832         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22833         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22834         uint64_t ret_ref = (uint64_t)ret_var.inner;
22835         if (ret_var.is_owned) {
22836                 ret_ref |= 1;
22837         }
22838         return ret_ref;
22839 }
22840
22841 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32_t orig) {
22842         LDKChannelFeatures orig_conv;
22843         orig_conv.inner = (void*)(orig & (~1));
22844         orig_conv.is_owned = false;
22845         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
22846         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22847         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22848         uint64_t ret_ref = (uint64_t)ret_var.inner;
22849         if (ret_var.is_owned) {
22850                 ret_ref |= 1;
22851         }
22852         return ret_ref;
22853 }
22854
22855 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32_t orig) {
22856         LDKInvoiceFeatures orig_conv;
22857         orig_conv.inner = (void*)(orig & (~1));
22858         orig_conv.is_owned = false;
22859         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
22860         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22861         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22862         uint64_t ret_ref = (uint64_t)ret_var.inner;
22863         if (ret_var.is_owned) {
22864                 ret_ref |= 1;
22865         }
22866         return ret_ref;
22867 }
22868
22869 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_obj) {
22870         LDKInitFeatures this_obj_conv;
22871         this_obj_conv.inner = (void*)(this_obj & (~1));
22872         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22873         InitFeatures_free(this_obj_conv);
22874 }
22875
22876 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_obj) {
22877         LDKNodeFeatures this_obj_conv;
22878         this_obj_conv.inner = (void*)(this_obj & (~1));
22879         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22880         NodeFeatures_free(this_obj_conv);
22881 }
22882
22883 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_obj) {
22884         LDKChannelFeatures this_obj_conv;
22885         this_obj_conv.inner = (void*)(this_obj & (~1));
22886         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22887         ChannelFeatures_free(this_obj_conv);
22888 }
22889
22890 void  __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
22891         LDKInvoiceFeatures this_obj_conv;
22892         this_obj_conv.inner = (void*)(this_obj & (~1));
22893         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22894         InvoiceFeatures_free(this_obj_conv);
22895 }
22896
22897 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
22898         LDKInitFeatures ret_var = InitFeatures_empty();
22899         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22900         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22901         uint64_t ret_ref = (uint64_t)ret_var.inner;
22902         if (ret_var.is_owned) {
22903                 ret_ref |= 1;
22904         }
22905         return ret_ref;
22906 }
22907
22908 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
22909         LDKInitFeatures ret_var = InitFeatures_known();
22910         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22911         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22912         uint64_t ret_ref = (uint64_t)ret_var.inner;
22913         if (ret_var.is_owned) {
22914                 ret_ref |= 1;
22915         }
22916         return ret_ref;
22917 }
22918
22919 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
22920         LDKInitFeatures this_arg_conv;
22921         this_arg_conv.inner = (void*)(this_arg & (~1));
22922         this_arg_conv.is_owned = false;
22923         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
22924         return ret_val;
22925 }
22926
22927 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
22928         LDKNodeFeatures ret_var = NodeFeatures_empty();
22929         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22930         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22931         uint64_t ret_ref = (uint64_t)ret_var.inner;
22932         if (ret_var.is_owned) {
22933                 ret_ref |= 1;
22934         }
22935         return ret_ref;
22936 }
22937
22938 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
22939         LDKNodeFeatures ret_var = NodeFeatures_known();
22940         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22941         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22942         uint64_t ret_ref = (uint64_t)ret_var.inner;
22943         if (ret_var.is_owned) {
22944                 ret_ref |= 1;
22945         }
22946         return ret_ref;
22947 }
22948
22949 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
22950         LDKNodeFeatures this_arg_conv;
22951         this_arg_conv.inner = (void*)(this_arg & (~1));
22952         this_arg_conv.is_owned = false;
22953         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
22954         return ret_val;
22955 }
22956
22957 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
22958         LDKChannelFeatures ret_var = ChannelFeatures_empty();
22959         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22960         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22961         uint64_t ret_ref = (uint64_t)ret_var.inner;
22962         if (ret_var.is_owned) {
22963                 ret_ref |= 1;
22964         }
22965         return ret_ref;
22966 }
22967
22968 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
22969         LDKChannelFeatures ret_var = ChannelFeatures_known();
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         uint64_t ret_ref = (uint64_t)ret_var.inner;
22973         if (ret_var.is_owned) {
22974                 ret_ref |= 1;
22975         }
22976         return ret_ref;
22977 }
22978
22979 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
22980         LDKChannelFeatures this_arg_conv;
22981         this_arg_conv.inner = (void*)(this_arg & (~1));
22982         this_arg_conv.is_owned = false;
22983         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
22984         return ret_val;
22985 }
22986
22987 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
22988         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
22989         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22990         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22991         uint64_t ret_ref = (uint64_t)ret_var.inner;
22992         if (ret_var.is_owned) {
22993                 ret_ref |= 1;
22994         }
22995         return ret_ref;
22996 }
22997
22998 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_known() {
22999         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
23000         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23001         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23002         uint64_t ret_ref = (uint64_t)ret_var.inner;
23003         if (ret_var.is_owned) {
23004                 ret_ref |= 1;
23005         }
23006         return ret_ref;
23007 }
23008
23009 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
23010         LDKInvoiceFeatures this_arg_conv;
23011         this_arg_conv.inner = (void*)(this_arg & (~1));
23012         this_arg_conv.is_owned = false;
23013         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
23014         return ret_val;
23015 }
23016
23017 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) {
23018         LDKInitFeatures this_arg_conv;
23019         this_arg_conv.inner = (void*)(this_arg & (~1));
23020         this_arg_conv.is_owned = false;
23021         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
23022         return ret_val;
23023 }
23024
23025 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_supports_payment_secret(uint32_t this_arg) {
23026         LDKNodeFeatures this_arg_conv;
23027         this_arg_conv.inner = (void*)(this_arg & (~1));
23028         this_arg_conv.is_owned = false;
23029         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
23030         return ret_val;
23031 }
23032
23033 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_supports_payment_secret(uint32_t this_arg) {
23034         LDKInvoiceFeatures this_arg_conv;
23035         this_arg_conv.inner = (void*)(this_arg & (~1));
23036         this_arg_conv.is_owned = false;
23037         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
23038         return ret_val;
23039 }
23040
23041 int8_tArray  __attribute__((visibility("default"))) TS_InitFeatures_write(uint32_t obj) {
23042         LDKInitFeatures obj_conv;
23043         obj_conv.inner = (void*)(obj & (~1));
23044         obj_conv.is_owned = false;
23045         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
23046         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23047         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23048         CVec_u8Z_free(ret_var);
23049         return ret_arr;
23050 }
23051
23052 int8_tArray  __attribute__((visibility("default"))) TS_NodeFeatures_write(uint32_t obj) {
23053         LDKNodeFeatures obj_conv;
23054         obj_conv.inner = (void*)(obj & (~1));
23055         obj_conv.is_owned = false;
23056         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
23057         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23058         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23059         CVec_u8Z_free(ret_var);
23060         return ret_arr;
23061 }
23062
23063 int8_tArray  __attribute__((visibility("default"))) TS_ChannelFeatures_write(uint32_t obj) {
23064         LDKChannelFeatures obj_conv;
23065         obj_conv.inner = (void*)(obj & (~1));
23066         obj_conv.is_owned = false;
23067         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
23068         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23069         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23070         CVec_u8Z_free(ret_var);
23071         return ret_arr;
23072 }
23073
23074 int8_tArray  __attribute__((visibility("default"))) TS_InvoiceFeatures_write(uint32_t obj) {
23075         LDKInvoiceFeatures obj_conv;
23076         obj_conv.inner = (void*)(obj & (~1));
23077         obj_conv.is_owned = false;
23078         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
23079         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23080         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23081         CVec_u8Z_free(ret_var);
23082         return ret_arr;
23083 }
23084
23085 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_read(int8_tArray ser) {
23086         LDKu8slice ser_ref;
23087         ser_ref.datalen = *((uint32_t*)ser);
23088         ser_ref.data = (int8_t*)(ser + 4);
23089         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
23090         *ret_conv = InitFeatures_read(ser_ref);
23091         return (uint64_t)ret_conv;
23092 }
23093
23094 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_read(int8_tArray ser) {
23095         LDKu8slice ser_ref;
23096         ser_ref.datalen = *((uint32_t*)ser);
23097         ser_ref.data = (int8_t*)(ser + 4);
23098         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
23099         *ret_conv = NodeFeatures_read(ser_ref);
23100         return (uint64_t)ret_conv;
23101 }
23102
23103 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_read(int8_tArray ser) {
23104         LDKu8slice ser_ref;
23105         ser_ref.datalen = *((uint32_t*)ser);
23106         ser_ref.data = (int8_t*)(ser + 4);
23107         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
23108         *ret_conv = ChannelFeatures_read(ser_ref);
23109         return (uint64_t)ret_conv;
23110 }
23111
23112 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_read(int8_tArray ser) {
23113         LDKu8slice ser_ref;
23114         ser_ref.datalen = *((uint32_t*)ser);
23115         ser_ref.data = (int8_t*)(ser + 4);
23116         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
23117         *ret_conv = InvoiceFeatures_read(ser_ref);
23118         return (uint64_t)ret_conv;
23119 }
23120
23121 void  __attribute__((visibility("default"))) TS_ShutdownScript_free(uint32_t this_obj) {
23122         LDKShutdownScript this_obj_conv;
23123         this_obj_conv.inner = (void*)(this_obj & (~1));
23124         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23125         ShutdownScript_free(this_obj_conv);
23126 }
23127
23128 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_clone(uint32_t orig) {
23129         LDKShutdownScript orig_conv;
23130         orig_conv.inner = (void*)(orig & (~1));
23131         orig_conv.is_owned = false;
23132         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
23133         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23134         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23135         uint64_t ret_ref = (uint64_t)ret_var.inner;
23136         if (ret_var.is_owned) {
23137                 ret_ref |= 1;
23138         }
23139         return ret_ref;
23140 }
23141
23142 void  __attribute__((visibility("default"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
23143         LDKInvalidShutdownScript this_obj_conv;
23144         this_obj_conv.inner = (void*)(this_obj & (~1));
23145         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23146         InvalidShutdownScript_free(this_obj_conv);
23147 }
23148
23149 int8_tArray  __attribute__((visibility("default"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
23150         LDKInvalidShutdownScript this_ptr_conv;
23151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23152         this_ptr_conv.is_owned = false;
23153         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
23154         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23155         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23156         return ret_arr;
23157 }
23158
23159 void  __attribute__((visibility("default"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
23160         LDKInvalidShutdownScript this_ptr_conv;
23161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23162         this_ptr_conv.is_owned = false;
23163         LDKCVec_u8Z val_ref;
23164         val_ref.datalen = *((uint32_t*)val);
23165         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
23166         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
23167         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
23168 }
23169
23170 uint32_t  __attribute__((visibility("default"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
23171         LDKCVec_u8Z script_arg_ref;
23172         script_arg_ref.datalen = *((uint32_t*)script_arg);
23173         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
23174         memcpy(script_arg_ref.data, (uint8_t*)(script_arg + 4), script_arg_ref.datalen);
23175         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
23176         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23177         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23178         uint64_t ret_ref = (uint64_t)ret_var.inner;
23179         if (ret_var.is_owned) {
23180                 ret_ref |= 1;
23181         }
23182         return ret_ref;
23183 }
23184
23185 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_write(uint32_t obj) {
23186         LDKShutdownScript obj_conv;
23187         obj_conv.inner = (void*)(obj & (~1));
23188         obj_conv.is_owned = false;
23189         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
23190         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23191         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23192         CVec_u8Z_free(ret_var);
23193         return ret_arr;
23194 }
23195
23196 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_read(int8_tArray ser) {
23197         LDKu8slice ser_ref;
23198         ser_ref.datalen = *((uint32_t*)ser);
23199         ser_ref.data = (int8_t*)(ser + 4);
23200         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
23201         *ret_conv = ShutdownScript_read(ser_ref);
23202         return (uint64_t)ret_conv;
23203 }
23204
23205 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2pkh(int8_tArray pubkey_hash) {
23206         unsigned char pubkey_hash_arr[20];
23207         CHECK(*((uint32_t*)pubkey_hash) == 20);
23208         memcpy(pubkey_hash_arr, (uint8_t*)(pubkey_hash + 4), 20);
23209         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
23210         LDKShutdownScript ret_var = ShutdownScript_new_p2pkh(pubkey_hash_ref);
23211         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23212         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23213         uint64_t ret_ref = (uint64_t)ret_var.inner;
23214         if (ret_var.is_owned) {
23215                 ret_ref |= 1;
23216         }
23217         return ret_ref;
23218 }
23219
23220 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2sh(int8_tArray script_hash) {
23221         unsigned char script_hash_arr[20];
23222         CHECK(*((uint32_t*)script_hash) == 20);
23223         memcpy(script_hash_arr, (uint8_t*)(script_hash + 4), 20);
23224         unsigned char (*script_hash_ref)[20] = &script_hash_arr;
23225         LDKShutdownScript ret_var = ShutdownScript_new_p2sh(script_hash_ref);
23226         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23227         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23228         uint64_t ret_ref = (uint64_t)ret_var.inner;
23229         if (ret_var.is_owned) {
23230                 ret_ref |= 1;
23231         }
23232         return ret_ref;
23233 }
23234
23235 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
23236         unsigned char pubkey_hash_arr[20];
23237         CHECK(*((uint32_t*)pubkey_hash) == 20);
23238         memcpy(pubkey_hash_arr, (uint8_t*)(pubkey_hash + 4), 20);
23239         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
23240         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
23241         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23242         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23243         uint64_t ret_ref = (uint64_t)ret_var.inner;
23244         if (ret_var.is_owned) {
23245                 ret_ref |= 1;
23246         }
23247         return ret_ref;
23248 }
23249
23250 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
23251         unsigned char script_hash_arr[32];
23252         CHECK(*((uint32_t*)script_hash) == 32);
23253         memcpy(script_hash_arr, (uint8_t*)(script_hash + 4), 32);
23254         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
23255         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
23256         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23257         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23258         uint64_t ret_ref = (uint64_t)ret_var.inner;
23259         if (ret_var.is_owned) {
23260                 ret_ref |= 1;
23261         }
23262         return ret_ref;
23263 }
23264
23265 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
23266         LDKu8slice program_ref;
23267         program_ref.datalen = *((uint32_t*)program);
23268         program_ref.data = (int8_t*)(program + 4);
23269         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
23270         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
23271         return (uint64_t)ret_conv;
23272 }
23273
23274 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
23275         LDKShutdownScript this_arg_conv;
23276         this_arg_conv.inner = (void*)(this_arg & (~1));
23277         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
23278         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
23279         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
23280         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23281         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23282         CVec_u8Z_free(ret_var);
23283         return ret_arr;
23284 }
23285
23286 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
23287         LDKShutdownScript this_arg_conv;
23288         this_arg_conv.inner = (void*)(this_arg & (~1));
23289         this_arg_conv.is_owned = false;
23290         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23291         memcpy((uint8_t*)(ret_arr + 4), ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
23292         return ret_arr;
23293 }
23294
23295 jboolean  __attribute__((visibility("default"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
23296         LDKShutdownScript this_arg_conv;
23297         this_arg_conv.inner = (void*)(this_arg & (~1));
23298         this_arg_conv.is_owned = false;
23299         LDKInitFeatures features_conv;
23300         features_conv.inner = (void*)(features & (~1));
23301         features_conv.is_owned = false;
23302         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
23303         return ret_val;
23304 }
23305
23306 void  __attribute__((visibility("default"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
23307         if ((this_ptr & 1) != 0) return;
23308         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(((uint64_t)this_ptr) & ~1);
23309         FREE((void*)this_ptr);
23310         CustomMessageReader_free(this_ptr_conv);
23311 }
23312
23313 uint32_t  __attribute__((visibility("default"))) TS_Type_clone(uint32_t orig) {
23314         LDKType* orig_conv = (LDKType*)(((uint64_t)orig) & ~1);
23315         LDKType* ret_ret =MALLOC(sizeof(LDKType), "LDKType");
23316         *ret_ret = Type_clone(orig_conv);
23317         return (uint64_t)ret_ret;
23318 }
23319
23320 void  __attribute__((visibility("default"))) TS_Type_free(uint32_t this_ptr) {
23321         if ((this_ptr & 1) != 0) return;
23322         LDKType this_ptr_conv = *(LDKType*)(((uint64_t)this_ptr) & ~1);
23323         FREE((void*)this_ptr);
23324         Type_free(this_ptr_conv);
23325 }
23326
23327 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) {
23328         LDKRouteHop this_obj_conv;
23329         this_obj_conv.inner = (void*)(this_obj & (~1));
23330         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23331         RouteHop_free(this_obj_conv);
23332 }
23333
23334 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
23335         LDKRouteHop this_ptr_conv;
23336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23337         this_ptr_conv.is_owned = false;
23338         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23339         memcpy((uint8_t*)(ret_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
23340         return ret_arr;
23341 }
23342
23343 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
23344         LDKRouteHop this_ptr_conv;
23345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23346         this_ptr_conv.is_owned = false;
23347         LDKPublicKey val_ref;
23348         CHECK(*((uint32_t*)val) == 33);
23349         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23350         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
23351 }
23352
23353 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
23354         LDKRouteHop this_ptr_conv;
23355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23356         this_ptr_conv.is_owned = false;
23357         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
23358         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23359         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23360         uint64_t 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_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
23368         LDKRouteHop this_ptr_conv;
23369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23370         this_ptr_conv.is_owned = false;
23371         LDKNodeFeatures val_conv;
23372         val_conv.inner = (void*)(val & (~1));
23373         val_conv.is_owned = (val & 1) || (val == 0);
23374         val_conv = NodeFeatures_clone(&val_conv);
23375         RouteHop_set_node_features(&this_ptr_conv, val_conv);
23376 }
23377
23378 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
23379         LDKRouteHop this_ptr_conv;
23380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23381         this_ptr_conv.is_owned = false;
23382         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
23383         return ret_val;
23384 }
23385
23386 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
23387         LDKRouteHop this_ptr_conv;
23388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23389         this_ptr_conv.is_owned = false;
23390         RouteHop_set_short_channel_id(&this_ptr_conv, val);
23391 }
23392
23393 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
23394         LDKRouteHop this_ptr_conv;
23395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23396         this_ptr_conv.is_owned = false;
23397         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
23398         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23399         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23400         uint64_t ret_ref = (uint64_t)ret_var.inner;
23401         if (ret_var.is_owned) {
23402                 ret_ref |= 1;
23403         }
23404         return ret_ref;
23405 }
23406
23407 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
23408         LDKRouteHop this_ptr_conv;
23409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23410         this_ptr_conv.is_owned = false;
23411         LDKChannelFeatures val_conv;
23412         val_conv.inner = (void*)(val & (~1));
23413         val_conv.is_owned = (val & 1) || (val == 0);
23414         val_conv = ChannelFeatures_clone(&val_conv);
23415         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
23416 }
23417
23418 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
23419         LDKRouteHop this_ptr_conv;
23420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23421         this_ptr_conv.is_owned = false;
23422         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
23423         return ret_val;
23424 }
23425
23426 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
23427         LDKRouteHop this_ptr_conv;
23428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23429         this_ptr_conv.is_owned = false;
23430         RouteHop_set_fee_msat(&this_ptr_conv, val);
23431 }
23432
23433 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
23434         LDKRouteHop this_ptr_conv;
23435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23436         this_ptr_conv.is_owned = false;
23437         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
23438         return ret_val;
23439 }
23440
23441 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
23442         LDKRouteHop this_ptr_conv;
23443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23444         this_ptr_conv.is_owned = false;
23445         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
23446 }
23447
23448 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) {
23449         LDKPublicKey pubkey_arg_ref;
23450         CHECK(*((uint32_t*)pubkey_arg) == 33);
23451         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
23452         LDKNodeFeatures node_features_arg_conv;
23453         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
23454         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
23455         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
23456         LDKChannelFeatures channel_features_arg_conv;
23457         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
23458         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
23459         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
23460         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);
23461         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23462         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23463         uint64_t ret_ref = (uint64_t)ret_var.inner;
23464         if (ret_var.is_owned) {
23465                 ret_ref |= 1;
23466         }
23467         return ret_ref;
23468 }
23469
23470 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
23471         LDKRouteHop orig_conv;
23472         orig_conv.inner = (void*)(orig & (~1));
23473         orig_conv.is_owned = false;
23474         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
23475         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23476         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23477         uint64_t ret_ref = (uint64_t)ret_var.inner;
23478         if (ret_var.is_owned) {
23479                 ret_ref |= 1;
23480         }
23481         return ret_ref;
23482 }
23483
23484 int64_t  __attribute__((visibility("default"))) TS_RouteHop_hash(uint32_t o) {
23485         LDKRouteHop o_conv;
23486         o_conv.inner = (void*)(o & (~1));
23487         o_conv.is_owned = false;
23488         int64_t ret_val = RouteHop_hash(&o_conv);
23489         return ret_val;
23490 }
23491
23492 jboolean  __attribute__((visibility("default"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
23493         LDKRouteHop a_conv;
23494         a_conv.inner = (void*)(a & (~1));
23495         a_conv.is_owned = false;
23496         LDKRouteHop b_conv;
23497         b_conv.inner = (void*)(b & (~1));
23498         b_conv.is_owned = false;
23499         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
23500         return ret_val;
23501 }
23502
23503 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_write(uint32_t obj) {
23504         LDKRouteHop obj_conv;
23505         obj_conv.inner = (void*)(obj & (~1));
23506         obj_conv.is_owned = false;
23507         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
23508         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23509         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23510         CVec_u8Z_free(ret_var);
23511         return ret_arr;
23512 }
23513
23514 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_read(int8_tArray ser) {
23515         LDKu8slice ser_ref;
23516         ser_ref.datalen = *((uint32_t*)ser);
23517         ser_ref.data = (int8_t*)(ser + 4);
23518         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
23519         *ret_conv = RouteHop_read(ser_ref);
23520         return (uint64_t)ret_conv;
23521 }
23522
23523 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) {
23524         LDKRoute this_obj_conv;
23525         this_obj_conv.inner = (void*)(this_obj & (~1));
23526         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23527         Route_free(this_obj_conv);
23528 }
23529
23530 ptrArray  __attribute__((visibility("default"))) TS_Route_get_paths(uint32_t this_ptr) {
23531         LDKRoute this_ptr_conv;
23532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23533         this_ptr_conv.is_owned = false;
23534         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
23535         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
23536         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(ret_arr + 4);
23537         for (size_t m = 0; m < ret_var.datalen; m++) {
23538                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
23539                 uint32_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
23540                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(ret_conv_12_arr + 4);
23541                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
23542                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
23543                         CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23544                         CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23545                         uint64_t ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner;
23546                         if (ret_conv_12_conv_10_var.is_owned) {
23547                                 ret_conv_12_conv_10_ref |= 1;
23548                         }
23549                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
23550                 }
23551                 FREE(ret_conv_12_var.data);
23552                 ret_arr_ptr[m] = ret_conv_12_arr;
23553         }
23554         FREE(ret_var.data);
23555         return ret_arr;
23556 }
23557
23558 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
23559         LDKRoute this_ptr_conv;
23560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23561         this_ptr_conv.is_owned = false;
23562         LDKCVec_CVec_RouteHopZZ val_constr;
23563         val_constr.datalen = *((uint32_t*)val);
23564         if (val_constr.datalen > 0)
23565                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
23566         else
23567                 val_constr.data = NULL;
23568         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
23569         for (size_t m = 0; m < val_constr.datalen; m++) {
23570                 uint32_tArray val_conv_12 = val_vals[m];
23571                 LDKCVec_RouteHopZ val_conv_12_constr;
23572                 val_conv_12_constr.datalen = *((uint32_t*)val_conv_12);
23573                 if (val_conv_12_constr.datalen > 0)
23574                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23575                 else
23576                         val_conv_12_constr.data = NULL;
23577                 uint32_t* val_conv_12_vals = (uint32_t*)(val_conv_12 + 4);
23578                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
23579                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
23580                         LDKRouteHop val_conv_12_conv_10_conv;
23581                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
23582                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
23583                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
23584                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
23585                 }
23586                 val_constr.data[m] = val_conv_12_constr;
23587         }
23588         Route_set_paths(&this_ptr_conv, val_constr);
23589 }
23590
23591 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
23592         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
23593         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
23594         if (paths_arg_constr.datalen > 0)
23595                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
23596         else
23597                 paths_arg_constr.data = NULL;
23598         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
23599         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
23600                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
23601                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
23602                 paths_arg_conv_12_constr.datalen = *((uint32_t*)paths_arg_conv_12);
23603                 if (paths_arg_conv_12_constr.datalen > 0)
23604                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23605                 else
23606                         paths_arg_conv_12_constr.data = NULL;
23607                 uint32_t* paths_arg_conv_12_vals = (uint32_t*)(paths_arg_conv_12 + 4);
23608                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
23609                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
23610                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
23611                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
23612                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
23613                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
23614                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
23615                 }
23616                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
23617         }
23618         LDKRoute ret_var = Route_new(paths_arg_constr);
23619         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23620         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23621         uint64_t ret_ref = (uint64_t)ret_var.inner;
23622         if (ret_var.is_owned) {
23623                 ret_ref |= 1;
23624         }
23625         return ret_ref;
23626 }
23627
23628 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
23629         LDKRoute orig_conv;
23630         orig_conv.inner = (void*)(orig & (~1));
23631         orig_conv.is_owned = false;
23632         LDKRoute ret_var = Route_clone(&orig_conv);
23633         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23634         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23635         uint64_t ret_ref = (uint64_t)ret_var.inner;
23636         if (ret_var.is_owned) {
23637                 ret_ref |= 1;
23638         }
23639         return ret_ref;
23640 }
23641
23642 int64_t  __attribute__((visibility("default"))) TS_Route_hash(uint32_t o) {
23643         LDKRoute o_conv;
23644         o_conv.inner = (void*)(o & (~1));
23645         o_conv.is_owned = false;
23646         int64_t ret_val = Route_hash(&o_conv);
23647         return ret_val;
23648 }
23649
23650 jboolean  __attribute__((visibility("default"))) TS_Route_eq(uint32_t a, uint32_t b) {
23651         LDKRoute a_conv;
23652         a_conv.inner = (void*)(a & (~1));
23653         a_conv.is_owned = false;
23654         LDKRoute b_conv;
23655         b_conv.inner = (void*)(b & (~1));
23656         b_conv.is_owned = false;
23657         jboolean ret_val = Route_eq(&a_conv, &b_conv);
23658         return ret_val;
23659 }
23660
23661 int64_t  __attribute__((visibility("default"))) TS_Route_get_total_fees(uint32_t this_arg) {
23662         LDKRoute this_arg_conv;
23663         this_arg_conv.inner = (void*)(this_arg & (~1));
23664         this_arg_conv.is_owned = false;
23665         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
23666         return ret_val;
23667 }
23668
23669 int64_t  __attribute__((visibility("default"))) TS_Route_get_total_amount(uint32_t this_arg) {
23670         LDKRoute this_arg_conv;
23671         this_arg_conv.inner = (void*)(this_arg & (~1));
23672         this_arg_conv.is_owned = false;
23673         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
23674         return ret_val;
23675 }
23676
23677 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
23678         LDKRoute obj_conv;
23679         obj_conv.inner = (void*)(obj & (~1));
23680         obj_conv.is_owned = false;
23681         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
23682         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
23683         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
23684         CVec_u8Z_free(ret_var);
23685         return ret_arr;
23686 }
23687
23688 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
23689         LDKu8slice ser_ref;
23690         ser_ref.datalen = *((uint32_t*)ser);
23691         ser_ref.data = (int8_t*)(ser + 4);
23692         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
23693         *ret_conv = Route_read(ser_ref);
23694         return (uint64_t)ret_conv;
23695 }
23696
23697 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
23698         LDKRouteHint this_obj_conv;
23699         this_obj_conv.inner = (void*)(this_obj & (~1));
23700         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23701         RouteHint_free(this_obj_conv);
23702 }
23703
23704 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
23705         LDKRouteHint orig_conv;
23706         orig_conv.inner = (void*)(orig & (~1));
23707         orig_conv.is_owned = false;
23708         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
23709         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23710         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23711         uint64_t ret_ref = (uint64_t)ret_var.inner;
23712         if (ret_var.is_owned) {
23713                 ret_ref |= 1;
23714         }
23715         return ret_ref;
23716 }
23717
23718 int64_t  __attribute__((visibility("default"))) TS_RouteHint_hash(uint32_t o) {
23719         LDKRouteHint o_conv;
23720         o_conv.inner = (void*)(o & (~1));
23721         o_conv.is_owned = false;
23722         int64_t ret_val = RouteHint_hash(&o_conv);
23723         return ret_val;
23724 }
23725
23726 jboolean  __attribute__((visibility("default"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
23727         LDKRouteHint a_conv;
23728         a_conv.inner = (void*)(a & (~1));
23729         a_conv.is_owned = false;
23730         LDKRouteHint b_conv;
23731         b_conv.inner = (void*)(b & (~1));
23732         b_conv.is_owned = false;
23733         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
23734         return ret_val;
23735 }
23736
23737 void  __attribute__((visibility("default"))) TS_RouteHintHop_free(uint32_t this_obj) {
23738         LDKRouteHintHop this_obj_conv;
23739         this_obj_conv.inner = (void*)(this_obj & (~1));
23740         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23741         RouteHintHop_free(this_obj_conv);
23742 }
23743
23744 int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
23745         LDKRouteHintHop this_ptr_conv;
23746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23747         this_ptr_conv.is_owned = false;
23748         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23749         memcpy((uint8_t*)(ret_arr + 4), RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
23750         return ret_arr;
23751 }
23752
23753 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
23754         LDKRouteHintHop this_ptr_conv;
23755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23756         this_ptr_conv.is_owned = false;
23757         LDKPublicKey val_ref;
23758         CHECK(*((uint32_t*)val) == 33);
23759         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23760         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
23761 }
23762
23763 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
23764         LDKRouteHintHop this_ptr_conv;
23765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23766         this_ptr_conv.is_owned = false;
23767         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
23768         return ret_val;
23769 }
23770
23771 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
23772         LDKRouteHintHop this_ptr_conv;
23773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23774         this_ptr_conv.is_owned = false;
23775         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
23776 }
23777
23778 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
23779         LDKRouteHintHop this_ptr_conv;
23780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23781         this_ptr_conv.is_owned = false;
23782         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
23783         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23784         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23785         uint64_t ret_ref = (uint64_t)ret_var.inner;
23786         if (ret_var.is_owned) {
23787                 ret_ref |= 1;
23788         }
23789         return ret_ref;
23790 }
23791
23792 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
23793         LDKRouteHintHop this_ptr_conv;
23794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23795         this_ptr_conv.is_owned = false;
23796         LDKRoutingFees val_conv;
23797         val_conv.inner = (void*)(val & (~1));
23798         val_conv.is_owned = (val & 1) || (val == 0);
23799         val_conv = RoutingFees_clone(&val_conv);
23800         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
23801 }
23802
23803 int16_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
23804         LDKRouteHintHop this_ptr_conv;
23805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23806         this_ptr_conv.is_owned = false;
23807         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
23808         return ret_val;
23809 }
23810
23811 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
23812         LDKRouteHintHop this_ptr_conv;
23813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23814         this_ptr_conv.is_owned = false;
23815         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
23816 }
23817
23818 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
23819         LDKRouteHintHop this_ptr_conv;
23820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23821         this_ptr_conv.is_owned = false;
23822         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23823         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
23824         uint64_t ret_ref = (uint64_t)ret_copy;
23825         return ret_ref;
23826 }
23827
23828 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
23829         LDKRouteHintHop this_ptr_conv;
23830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23831         this_ptr_conv.is_owned = false;
23832         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23833         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
23834         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
23835 }
23836
23837 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
23838         LDKRouteHintHop this_ptr_conv;
23839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23840         this_ptr_conv.is_owned = false;
23841         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
23842         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
23843         uint64_t ret_ref = (uint64_t)ret_copy;
23844         return ret_ref;
23845 }
23846
23847 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
23848         LDKRouteHintHop this_ptr_conv;
23849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23850         this_ptr_conv.is_owned = false;
23851         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
23852         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
23853         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
23854 }
23855
23856 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) {
23857         LDKPublicKey src_node_id_arg_ref;
23858         CHECK(*((uint32_t*)src_node_id_arg) == 33);
23859         memcpy(src_node_id_arg_ref.compressed_form, (uint8_t*)(src_node_id_arg + 4), 33);
23860         LDKRoutingFees fees_arg_conv;
23861         fees_arg_conv.inner = (void*)(fees_arg & (~1));
23862         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
23863         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
23864         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
23865         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1));
23866         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
23867         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
23868         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);
23869         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23870         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23871         uint64_t ret_ref = (uint64_t)ret_var.inner;
23872         if (ret_var.is_owned) {
23873                 ret_ref |= 1;
23874         }
23875         return ret_ref;
23876 }
23877
23878 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t orig) {
23879         LDKRouteHintHop orig_conv;
23880         orig_conv.inner = (void*)(orig & (~1));
23881         orig_conv.is_owned = false;
23882         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
23883         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23884         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23885         uint64_t ret_ref = (uint64_t)ret_var.inner;
23886         if (ret_var.is_owned) {
23887                 ret_ref |= 1;
23888         }
23889         return ret_ref;
23890 }
23891
23892 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_hash(uint32_t o) {
23893         LDKRouteHintHop o_conv;
23894         o_conv.inner = (void*)(o & (~1));
23895         o_conv.is_owned = false;
23896         int64_t ret_val = RouteHintHop_hash(&o_conv);
23897         return ret_val;
23898 }
23899
23900 jboolean  __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
23901         LDKRouteHintHop a_conv;
23902         a_conv.inner = (void*)(a & (~1));
23903         a_conv.is_owned = false;
23904         LDKRouteHintHop b_conv;
23905         b_conv.inner = (void*)(b & (~1));
23906         b_conv.is_owned = false;
23907         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
23908         return ret_val;
23909 }
23910
23911 uint32_t  __attribute__((visibility("default"))) TS_get_keysend_route(int8_tArray our_node_id, uint32_t network, int8_tArray payee, uint32_tArray first_hops, uint32_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, uint32_t logger) {
23912         LDKPublicKey our_node_id_ref;
23913         CHECK(*((uint32_t*)our_node_id) == 33);
23914         memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
23915         LDKNetworkGraph network_conv;
23916         network_conv.inner = (void*)(network & (~1));
23917         network_conv.is_owned = false;
23918         LDKPublicKey payee_ref;
23919         CHECK(*((uint32_t*)payee) == 33);
23920         memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
23921         LDKCVec_ChannelDetailsZ first_hops_constr;
23922         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
23923         if (first_hops != 0) {
23924                 first_hops_constr.datalen = *((uint32_t*)first_hops);
23925                 if (first_hops_constr.datalen > 0)
23926                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
23927                 else
23928                         first_hops_constr.data = NULL;
23929                 uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
23930                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
23931                         uint32_t first_hops_conv_16 = first_hops_vals[q];
23932                         LDKChannelDetails first_hops_conv_16_conv;
23933                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
23934                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
23935                         first_hops_constr.data[q] = first_hops_conv_16_conv;
23936                 }
23937                 first_hops_ptr = &first_hops_constr;
23938         }
23939         LDKCVec_RouteHintZ last_hops_constr;
23940         last_hops_constr.datalen = *((uint32_t*)last_hops);
23941         if (last_hops_constr.datalen > 0)
23942                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
23943         else
23944                 last_hops_constr.data = NULL;
23945         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
23946         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
23947                 uint32_t last_hops_conv_11 = last_hops_vals[l];
23948                 LDKRouteHint last_hops_conv_11_conv;
23949                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
23950                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
23951                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
23952                 last_hops_constr.data[l] = last_hops_conv_11_conv;
23953         }
23954         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
23955         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
23956         *ret_conv = get_keysend_route(our_node_id_ref, &network_conv, payee_ref, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
23957         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
23958         return (uint64_t)ret_conv;
23959 }
23960
23961 uint32_t  __attribute__((visibility("default"))) TS_get_route(int8_tArray our_node_id, uint32_t network, int8_tArray payee, uint32_t payee_features, uint32_tArray first_hops, uint32_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, uint32_t logger) {
23962         LDKPublicKey our_node_id_ref;
23963         CHECK(*((uint32_t*)our_node_id) == 33);
23964         memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
23965         LDKNetworkGraph network_conv;
23966         network_conv.inner = (void*)(network & (~1));
23967         network_conv.is_owned = false;
23968         LDKPublicKey payee_ref;
23969         CHECK(*((uint32_t*)payee) == 33);
23970         memcpy(payee_ref.compressed_form, (uint8_t*)(payee + 4), 33);
23971         LDKInvoiceFeatures payee_features_conv;
23972         payee_features_conv.inner = (void*)(payee_features & (~1));
23973         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
23974         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
23975         LDKCVec_ChannelDetailsZ first_hops_constr;
23976         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
23977         if (first_hops != 0) {
23978                 first_hops_constr.datalen = *((uint32_t*)first_hops);
23979                 if (first_hops_constr.datalen > 0)
23980                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
23981                 else
23982                         first_hops_constr.data = NULL;
23983                 uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
23984                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
23985                         uint32_t first_hops_conv_16 = first_hops_vals[q];
23986                         LDKChannelDetails first_hops_conv_16_conv;
23987                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
23988                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
23989                         first_hops_constr.data[q] = first_hops_conv_16_conv;
23990                 }
23991                 first_hops_ptr = &first_hops_constr;
23992         }
23993         LDKCVec_RouteHintZ last_hops_constr;
23994         last_hops_constr.datalen = *((uint32_t*)last_hops);
23995         if (last_hops_constr.datalen > 0)
23996                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
23997         else
23998                 last_hops_constr.data = NULL;
23999         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
24000         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
24001                 uint32_t last_hops_conv_11 = last_hops_vals[l];
24002                 LDKRouteHint last_hops_conv_11_conv;
24003                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
24004                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
24005                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
24006                 last_hops_constr.data[l] = last_hops_conv_11_conv;
24007         }
24008         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24009         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
24010         *ret_conv = get_route(our_node_id_ref, &network_conv, payee_ref, payee_features_conv, first_hops_ptr, last_hops_constr, final_value_msat, final_cltv, logger_conv);
24011         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
24012         return (uint64_t)ret_conv;
24013 }
24014
24015 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_obj) {
24016         LDKNetworkGraph this_obj_conv;
24017         this_obj_conv.inner = (void*)(this_obj & (~1));
24018         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24019         NetworkGraph_free(this_obj_conv);
24020 }
24021
24022 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t orig) {
24023         LDKNetworkGraph orig_conv;
24024         orig_conv.inner = (void*)(orig & (~1));
24025         orig_conv.is_owned = false;
24026         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
24027         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24028         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24029         uint64_t ret_ref = (uint64_t)ret_var.inner;
24030         if (ret_var.is_owned) {
24031                 ret_ref |= 1;
24032         }
24033         return ret_ref;
24034 }
24035
24036 void  __attribute__((visibility("default"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
24037         LDKReadOnlyNetworkGraph this_obj_conv;
24038         this_obj_conv.inner = (void*)(this_obj & (~1));
24039         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24040         ReadOnlyNetworkGraph_free(this_obj_conv);
24041 }
24042
24043 void  __attribute__((visibility("default"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
24044         if ((this_ptr & 1) != 0) return;
24045         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(((uint64_t)this_ptr) & ~1);
24046         FREE((void*)this_ptr);
24047         NetworkUpdate_free(this_ptr_conv);
24048 }
24049
24050 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_clone(uint32_t orig) {
24051         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
24052         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
24053         *ret_copy = NetworkUpdate_clone(orig_conv);
24054         uint64_t ret_ref = (uint64_t)ret_copy;
24055         return ret_ref;
24056 }
24057
24058 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
24059         LDKChannelUpdate msg_conv;
24060         msg_conv.inner = (void*)(msg & (~1));
24061         msg_conv.is_owned = (msg & 1) || (msg == 0);
24062         msg_conv = ChannelUpdate_clone(&msg_conv);
24063         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
24064         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
24065         uint64_t ret_ref = (uint64_t)ret_copy;
24066         return ret_ref;
24067 }
24068
24069 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
24070         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
24071         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
24072         uint64_t ret_ref = (uint64_t)ret_copy;
24073         return ret_ref;
24074 }
24075
24076 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
24077         LDKPublicKey node_id_ref;
24078         CHECK(*((uint32_t*)node_id) == 33);
24079         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
24080         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
24081         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
24082         uint64_t ret_ref = (uint64_t)ret_copy;
24083         return ret_ref;
24084 }
24085
24086 int8_tArray  __attribute__((visibility("default"))) TS_NetworkUpdate_write(uint32_t obj) {
24087         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
24088         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
24089         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24090         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24091         CVec_u8Z_free(ret_var);
24092         return ret_arr;
24093 }
24094
24095 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) {
24096         LDKNetGraphMsgHandler this_arg_conv;
24097         this_arg_conv.inner = (void*)(this_arg & (~1));
24098         this_arg_conv.is_owned = false;
24099         LDKEventHandler* ret_ret =MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
24100         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
24101         return (uint64_t)ret_ret;
24102 }
24103
24104 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
24105         LDKNetGraphMsgHandler this_obj_conv;
24106         this_obj_conv.inner = (void*)(this_obj & (~1));
24107         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24108         NetGraphMsgHandler_free(this_obj_conv);
24109 }
24110
24111 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_get_network_graph(uint32_t this_ptr) {
24112         LDKNetGraphMsgHandler this_ptr_conv;
24113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24114         this_ptr_conv.is_owned = false;
24115         LDKNetworkGraph ret_var = NetGraphMsgHandler_get_network_graph(&this_ptr_conv);
24116         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24117         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24118         uint64_t ret_ref = (uint64_t)ret_var.inner;
24119         if (ret_var.is_owned) {
24120                 ret_ref |= 1;
24121         }
24122         return ret_ref;
24123 }
24124
24125 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_set_network_graph(uint32_t this_ptr, uint32_t val) {
24126         LDKNetGraphMsgHandler this_ptr_conv;
24127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24128         this_ptr_conv.is_owned = false;
24129         LDKNetworkGraph val_conv;
24130         val_conv.inner = (void*)(val & (~1));
24131         val_conv.is_owned = (val & 1) || (val == 0);
24132         val_conv = NetworkGraph_clone(&val_conv);
24133         NetGraphMsgHandler_set_network_graph(&this_ptr_conv, val_conv);
24134 }
24135
24136 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
24137         LDKNetworkGraph network_graph_conv;
24138         network_graph_conv.inner = (void*)(network_graph & (~1));
24139         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
24140         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
24141         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
24142         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
24143         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
24144                 // Manually implement clone for Java trait instances
24145         }
24146         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24147         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(network_graph_conv, chain_access_conv, logger_conv);
24148         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24149         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24150         uint64_t ret_ref = (uint64_t)ret_var.inner;
24151         if (ret_var.is_owned) {
24152                 ret_ref |= 1;
24153         }
24154         return ret_ref;
24155 }
24156
24157 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
24158         LDKNetGraphMsgHandler this_arg_conv;
24159         this_arg_conv.inner = (void*)(this_arg & (~1));
24160         this_arg_conv.is_owned = false;
24161         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
24162         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
24163         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
24164                 // Manually implement clone for Java trait instances
24165         }
24166         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
24167 }
24168
24169 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
24170         LDKNetGraphMsgHandler this_arg_conv;
24171         this_arg_conv.inner = (void*)(this_arg & (~1));
24172         this_arg_conv.is_owned = false;
24173         LDKRoutingMessageHandler* ret_ret =MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
24174         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
24175         return (uint64_t)ret_ret;
24176 }
24177
24178 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
24179         LDKNetGraphMsgHandler this_arg_conv;
24180         this_arg_conv.inner = (void*)(this_arg & (~1));
24181         this_arg_conv.is_owned = false;
24182         LDKMessageSendEventsProvider* ret_ret =MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
24183         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
24184         return (uint64_t)ret_ret;
24185 }
24186
24187 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
24188         LDKDirectionalChannelInfo this_obj_conv;
24189         this_obj_conv.inner = (void*)(this_obj & (~1));
24190         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24191         DirectionalChannelInfo_free(this_obj_conv);
24192 }
24193
24194 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
24195         LDKDirectionalChannelInfo this_ptr_conv;
24196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24197         this_ptr_conv.is_owned = false;
24198         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
24199         return ret_val;
24200 }
24201
24202 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
24203         LDKDirectionalChannelInfo this_ptr_conv;
24204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24205         this_ptr_conv.is_owned = false;
24206         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
24207 }
24208
24209 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
24210         LDKDirectionalChannelInfo this_ptr_conv;
24211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24212         this_ptr_conv.is_owned = false;
24213         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
24214         return ret_val;
24215 }
24216
24217 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
24218         LDKDirectionalChannelInfo this_ptr_conv;
24219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24220         this_ptr_conv.is_owned = false;
24221         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
24222 }
24223
24224 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
24225         LDKDirectionalChannelInfo this_ptr_conv;
24226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24227         this_ptr_conv.is_owned = false;
24228         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
24229         return ret_val;
24230 }
24231
24232 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
24233         LDKDirectionalChannelInfo this_ptr_conv;
24234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24235         this_ptr_conv.is_owned = false;
24236         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
24237 }
24238
24239 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
24240         LDKDirectionalChannelInfo this_ptr_conv;
24241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24242         this_ptr_conv.is_owned = false;
24243         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
24244         return ret_val;
24245 }
24246
24247 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
24248         LDKDirectionalChannelInfo this_ptr_conv;
24249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24250         this_ptr_conv.is_owned = false;
24251         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
24252 }
24253
24254 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
24255         LDKDirectionalChannelInfo this_ptr_conv;
24256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24257         this_ptr_conv.is_owned = false;
24258         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24259         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
24260         uint64_t ret_ref = (uint64_t)ret_copy;
24261         return ret_ref;
24262 }
24263
24264 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
24265         LDKDirectionalChannelInfo this_ptr_conv;
24266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24267         this_ptr_conv.is_owned = false;
24268         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24269         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
24270         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
24271 }
24272
24273 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
24274         LDKDirectionalChannelInfo this_ptr_conv;
24275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24276         this_ptr_conv.is_owned = false;
24277         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
24278         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24279         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24280         uint64_t ret_ref = (uint64_t)ret_var.inner;
24281         if (ret_var.is_owned) {
24282                 ret_ref |= 1;
24283         }
24284         return ret_ref;
24285 }
24286
24287 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
24288         LDKDirectionalChannelInfo this_ptr_conv;
24289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24290         this_ptr_conv.is_owned = false;
24291         LDKRoutingFees val_conv;
24292         val_conv.inner = (void*)(val & (~1));
24293         val_conv.is_owned = (val & 1) || (val == 0);
24294         val_conv = RoutingFees_clone(&val_conv);
24295         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
24296 }
24297
24298 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
24299         LDKDirectionalChannelInfo this_ptr_conv;
24300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24301         this_ptr_conv.is_owned = false;
24302         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
24303         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24304         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24305         uint64_t ret_ref = (uint64_t)ret_var.inner;
24306         if (ret_var.is_owned) {
24307                 ret_ref |= 1;
24308         }
24309         return ret_ref;
24310 }
24311
24312 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
24313         LDKDirectionalChannelInfo this_ptr_conv;
24314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24315         this_ptr_conv.is_owned = false;
24316         LDKChannelUpdate val_conv;
24317         val_conv.inner = (void*)(val & (~1));
24318         val_conv.is_owned = (val & 1) || (val == 0);
24319         val_conv = ChannelUpdate_clone(&val_conv);
24320         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
24321 }
24322
24323 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) {
24324         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
24325         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
24326         LDKRoutingFees fees_arg_conv;
24327         fees_arg_conv.inner = (void*)(fees_arg & (~1));
24328         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
24329         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
24330         LDKChannelUpdate last_update_message_arg_conv;
24331         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
24332         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
24333         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
24334         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);
24335         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24336         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24337         uint64_t ret_ref = (uint64_t)ret_var.inner;
24338         if (ret_var.is_owned) {
24339                 ret_ref |= 1;
24340         }
24341         return ret_ref;
24342 }
24343
24344 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
24345         LDKDirectionalChannelInfo orig_conv;
24346         orig_conv.inner = (void*)(orig & (~1));
24347         orig_conv.is_owned = false;
24348         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
24349         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24350         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24351         uint64_t ret_ref = (uint64_t)ret_var.inner;
24352         if (ret_var.is_owned) {
24353                 ret_ref |= 1;
24354         }
24355         return ret_ref;
24356 }
24357
24358 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
24359         LDKDirectionalChannelInfo obj_conv;
24360         obj_conv.inner = (void*)(obj & (~1));
24361         obj_conv.is_owned = false;
24362         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
24363         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24364         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24365         CVec_u8Z_free(ret_var);
24366         return ret_arr;
24367 }
24368
24369 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
24370         LDKu8slice ser_ref;
24371         ser_ref.datalen = *((uint32_t*)ser);
24372         ser_ref.data = (int8_t*)(ser + 4);
24373         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
24374         *ret_conv = DirectionalChannelInfo_read(ser_ref);
24375         return (uint64_t)ret_conv;
24376 }
24377
24378 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_obj) {
24379         LDKChannelInfo this_obj_conv;
24380         this_obj_conv.inner = (void*)(this_obj & (~1));
24381         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24382         ChannelInfo_free(this_obj_conv);
24383 }
24384
24385 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
24386         LDKChannelInfo this_ptr_conv;
24387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24388         this_ptr_conv.is_owned = false;
24389         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
24390         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24391         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24392         uint64_t ret_ref = (uint64_t)ret_var.inner;
24393         if (ret_var.is_owned) {
24394                 ret_ref |= 1;
24395         }
24396         return ret_ref;
24397 }
24398
24399 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
24400         LDKChannelInfo this_ptr_conv;
24401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24402         this_ptr_conv.is_owned = false;
24403         LDKChannelFeatures val_conv;
24404         val_conv.inner = (void*)(val & (~1));
24405         val_conv.is_owned = (val & 1) || (val == 0);
24406         val_conv = ChannelFeatures_clone(&val_conv);
24407         ChannelInfo_set_features(&this_ptr_conv, val_conv);
24408 }
24409
24410 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
24411         LDKChannelInfo this_ptr_conv;
24412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24413         this_ptr_conv.is_owned = false;
24414         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
24415         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_one(&this_ptr_conv).compressed_form, 33);
24416         return ret_arr;
24417 }
24418
24419 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, int8_tArray val) {
24420         LDKChannelInfo this_ptr_conv;
24421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24422         this_ptr_conv.is_owned = false;
24423         LDKPublicKey val_ref;
24424         CHECK(*((uint32_t*)val) == 33);
24425         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
24426         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
24427 }
24428
24429 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
24430         LDKChannelInfo this_ptr_conv;
24431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24432         this_ptr_conv.is_owned = false;
24433         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
24434         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24435         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24436         uint64_t ret_ref = (uint64_t)ret_var.inner;
24437         if (ret_var.is_owned) {
24438                 ret_ref |= 1;
24439         }
24440         return ret_ref;
24441 }
24442
24443 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
24444         LDKChannelInfo this_ptr_conv;
24445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24446         this_ptr_conv.is_owned = false;
24447         LDKDirectionalChannelInfo val_conv;
24448         val_conv.inner = (void*)(val & (~1));
24449         val_conv.is_owned = (val & 1) || (val == 0);
24450         val_conv = DirectionalChannelInfo_clone(&val_conv);
24451         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
24452 }
24453
24454 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
24455         LDKChannelInfo this_ptr_conv;
24456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24457         this_ptr_conv.is_owned = false;
24458         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
24459         memcpy((uint8_t*)(ret_arr + 4), ChannelInfo_get_node_two(&this_ptr_conv).compressed_form, 33);
24460         return ret_arr;
24461 }
24462
24463 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, int8_tArray val) {
24464         LDKChannelInfo this_ptr_conv;
24465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24466         this_ptr_conv.is_owned = false;
24467         LDKPublicKey val_ref;
24468         CHECK(*((uint32_t*)val) == 33);
24469         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
24470         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
24471 }
24472
24473 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
24474         LDKChannelInfo this_ptr_conv;
24475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24476         this_ptr_conv.is_owned = false;
24477         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
24478         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24479         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24480         uint64_t ret_ref = (uint64_t)ret_var.inner;
24481         if (ret_var.is_owned) {
24482                 ret_ref |= 1;
24483         }
24484         return ret_ref;
24485 }
24486
24487 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
24488         LDKChannelInfo this_ptr_conv;
24489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24490         this_ptr_conv.is_owned = false;
24491         LDKDirectionalChannelInfo val_conv;
24492         val_conv.inner = (void*)(val & (~1));
24493         val_conv.is_owned = (val & 1) || (val == 0);
24494         val_conv = DirectionalChannelInfo_clone(&val_conv);
24495         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
24496 }
24497
24498 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
24499         LDKChannelInfo this_ptr_conv;
24500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24501         this_ptr_conv.is_owned = false;
24502         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24503         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
24504         uint64_t ret_ref = (uint64_t)ret_copy;
24505         return ret_ref;
24506 }
24507
24508 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
24509         LDKChannelInfo this_ptr_conv;
24510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24511         this_ptr_conv.is_owned = false;
24512         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24513         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
24514         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
24515 }
24516
24517 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
24518         LDKChannelInfo this_ptr_conv;
24519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24520         this_ptr_conv.is_owned = false;
24521         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
24522         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24523         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24524         uint64_t ret_ref = (uint64_t)ret_var.inner;
24525         if (ret_var.is_owned) {
24526                 ret_ref |= 1;
24527         }
24528         return ret_ref;
24529 }
24530
24531 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
24532         LDKChannelInfo this_ptr_conv;
24533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24534         this_ptr_conv.is_owned = false;
24535         LDKChannelAnnouncement val_conv;
24536         val_conv.inner = (void*)(val & (~1));
24537         val_conv.is_owned = (val & 1) || (val == 0);
24538         val_conv = ChannelAnnouncement_clone(&val_conv);
24539         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
24540 }
24541
24542 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_new(uint32_t features_arg, int8_tArray node_one_arg, uint32_t one_to_two_arg, int8_tArray node_two_arg, uint32_t two_to_one_arg, uint32_t capacity_sats_arg, uint32_t announcement_message_arg) {
24543         LDKChannelFeatures features_arg_conv;
24544         features_arg_conv.inner = (void*)(features_arg & (~1));
24545         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24546         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
24547         LDKPublicKey node_one_arg_ref;
24548         CHECK(*((uint32_t*)node_one_arg) == 33);
24549         memcpy(node_one_arg_ref.compressed_form, (uint8_t*)(node_one_arg + 4), 33);
24550         LDKDirectionalChannelInfo one_to_two_arg_conv;
24551         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
24552         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
24553         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
24554         LDKPublicKey node_two_arg_ref;
24555         CHECK(*((uint32_t*)node_two_arg) == 33);
24556         memcpy(node_two_arg_ref.compressed_form, (uint8_t*)(node_two_arg + 4), 33);
24557         LDKDirectionalChannelInfo two_to_one_arg_conv;
24558         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
24559         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
24560         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
24561         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
24562         capacity_sats_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1));
24563         LDKChannelAnnouncement announcement_message_arg_conv;
24564         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24565         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24566         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
24567         LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_ref, one_to_two_arg_conv, node_two_arg_ref, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
24568         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24569         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24570         uint64_t ret_ref = (uint64_t)ret_var.inner;
24571         if (ret_var.is_owned) {
24572                 ret_ref |= 1;
24573         }
24574         return ret_ref;
24575 }
24576
24577 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t orig) {
24578         LDKChannelInfo orig_conv;
24579         orig_conv.inner = (void*)(orig & (~1));
24580         orig_conv.is_owned = false;
24581         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
24582         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24583         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24584         uint64_t ret_ref = (uint64_t)ret_var.inner;
24585         if (ret_var.is_owned) {
24586                 ret_ref |= 1;
24587         }
24588         return ret_ref;
24589 }
24590
24591 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
24592         LDKChannelInfo obj_conv;
24593         obj_conv.inner = (void*)(obj & (~1));
24594         obj_conv.is_owned = false;
24595         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
24596         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24597         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24598         CVec_u8Z_free(ret_var);
24599         return ret_arr;
24600 }
24601
24602 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
24603         LDKu8slice ser_ref;
24604         ser_ref.datalen = *((uint32_t*)ser);
24605         ser_ref.data = (int8_t*)(ser + 4);
24606         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
24607         *ret_conv = ChannelInfo_read(ser_ref);
24608         return (uint64_t)ret_conv;
24609 }
24610
24611 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_obj) {
24612         LDKRoutingFees this_obj_conv;
24613         this_obj_conv.inner = (void*)(this_obj & (~1));
24614         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24615         RoutingFees_free(this_obj_conv);
24616 }
24617
24618 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
24619         LDKRoutingFees this_ptr_conv;
24620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24621         this_ptr_conv.is_owned = false;
24622         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
24623         return ret_val;
24624 }
24625
24626 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
24627         LDKRoutingFees this_ptr_conv;
24628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24629         this_ptr_conv.is_owned = false;
24630         RoutingFees_set_base_msat(&this_ptr_conv, val);
24631 }
24632
24633 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
24634         LDKRoutingFees this_ptr_conv;
24635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24636         this_ptr_conv.is_owned = false;
24637         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
24638         return ret_val;
24639 }
24640
24641 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
24642         LDKRoutingFees this_ptr_conv;
24643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24644         this_ptr_conv.is_owned = false;
24645         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
24646 }
24647
24648 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
24649         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
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         uint64_t ret_ref = (uint64_t)ret_var.inner;
24653         if (ret_var.is_owned) {
24654                 ret_ref |= 1;
24655         }
24656         return ret_ref;
24657 }
24658
24659 jboolean  __attribute__((visibility("default"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
24660         LDKRoutingFees a_conv;
24661         a_conv.inner = (void*)(a & (~1));
24662         a_conv.is_owned = false;
24663         LDKRoutingFees b_conv;
24664         b_conv.inner = (void*)(b & (~1));
24665         b_conv.is_owned = false;
24666         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
24667         return ret_val;
24668 }
24669
24670 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
24671         LDKRoutingFees orig_conv;
24672         orig_conv.inner = (void*)(orig & (~1));
24673         orig_conv.is_owned = false;
24674         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
24675         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24676         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24677         uint64_t ret_ref = (uint64_t)ret_var.inner;
24678         if (ret_var.is_owned) {
24679                 ret_ref |= 1;
24680         }
24681         return ret_ref;
24682 }
24683
24684 int64_t  __attribute__((visibility("default"))) TS_RoutingFees_hash(uint32_t o) {
24685         LDKRoutingFees o_conv;
24686         o_conv.inner = (void*)(o & (~1));
24687         o_conv.is_owned = false;
24688         int64_t ret_val = RoutingFees_hash(&o_conv);
24689         return ret_val;
24690 }
24691
24692 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
24693         LDKRoutingFees obj_conv;
24694         obj_conv.inner = (void*)(obj & (~1));
24695         obj_conv.is_owned = false;
24696         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
24697         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24698         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24699         CVec_u8Z_free(ret_var);
24700         return ret_arr;
24701 }
24702
24703 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
24704         LDKu8slice ser_ref;
24705         ser_ref.datalen = *((uint32_t*)ser);
24706         ser_ref.data = (int8_t*)(ser + 4);
24707         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
24708         *ret_conv = RoutingFees_read(ser_ref);
24709         return (uint64_t)ret_conv;
24710 }
24711
24712 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
24713         LDKNodeAnnouncementInfo this_obj_conv;
24714         this_obj_conv.inner = (void*)(this_obj & (~1));
24715         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24716         NodeAnnouncementInfo_free(this_obj_conv);
24717 }
24718
24719 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
24720         LDKNodeAnnouncementInfo this_ptr_conv;
24721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24722         this_ptr_conv.is_owned = false;
24723         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
24724         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24725         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24726         uint64_t ret_ref = (uint64_t)ret_var.inner;
24727         if (ret_var.is_owned) {
24728                 ret_ref |= 1;
24729         }
24730         return ret_ref;
24731 }
24732
24733 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
24734         LDKNodeAnnouncementInfo this_ptr_conv;
24735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24736         this_ptr_conv.is_owned = false;
24737         LDKNodeFeatures val_conv;
24738         val_conv.inner = (void*)(val & (~1));
24739         val_conv.is_owned = (val & 1) || (val == 0);
24740         val_conv = NodeFeatures_clone(&val_conv);
24741         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
24742 }
24743
24744 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
24745         LDKNodeAnnouncementInfo this_ptr_conv;
24746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24747         this_ptr_conv.is_owned = false;
24748         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
24749         return ret_val;
24750 }
24751
24752 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
24753         LDKNodeAnnouncementInfo this_ptr_conv;
24754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24755         this_ptr_conv.is_owned = false;
24756         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
24757 }
24758
24759 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
24760         LDKNodeAnnouncementInfo this_ptr_conv;
24761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24762         this_ptr_conv.is_owned = false;
24763         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
24764         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
24765         return ret_arr;
24766 }
24767
24768 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
24769         LDKNodeAnnouncementInfo this_ptr_conv;
24770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24771         this_ptr_conv.is_owned = false;
24772         LDKThreeBytes val_ref;
24773         CHECK(*((uint32_t*)val) == 3);
24774         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
24775         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
24776 }
24777
24778 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
24779         LDKNodeAnnouncementInfo this_ptr_conv;
24780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24781         this_ptr_conv.is_owned = false;
24782         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24783         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
24784         return ret_arr;
24785 }
24786
24787 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
24788         LDKNodeAnnouncementInfo this_ptr_conv;
24789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24790         this_ptr_conv.is_owned = false;
24791         LDKThirtyTwoBytes val_ref;
24792         CHECK(*((uint32_t*)val) == 32);
24793         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24794         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
24795 }
24796
24797 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
24798         LDKNodeAnnouncementInfo this_ptr_conv;
24799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24800         this_ptr_conv.is_owned = false;
24801         LDKCVec_NetAddressZ val_constr;
24802         val_constr.datalen = *((uint32_t*)val);
24803         if (val_constr.datalen > 0)
24804                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24805         else
24806                 val_constr.data = NULL;
24807         uint32_t* val_vals = (uint32_t*)(val + 4);
24808         for (size_t m = 0; m < val_constr.datalen; m++) {
24809                 uint32_t val_conv_12 = val_vals[m];
24810                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
24811                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
24812                 val_constr.data[m] = val_conv_12_conv;
24813         }
24814         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
24815 }
24816
24817 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
24818         LDKNodeAnnouncementInfo this_ptr_conv;
24819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24820         this_ptr_conv.is_owned = false;
24821         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
24822         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24823         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24824         uint64_t ret_ref = (uint64_t)ret_var.inner;
24825         if (ret_var.is_owned) {
24826                 ret_ref |= 1;
24827         }
24828         return ret_ref;
24829 }
24830
24831 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
24832         LDKNodeAnnouncementInfo this_ptr_conv;
24833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24834         this_ptr_conv.is_owned = false;
24835         LDKNodeAnnouncement val_conv;
24836         val_conv.inner = (void*)(val & (~1));
24837         val_conv.is_owned = (val & 1) || (val == 0);
24838         val_conv = NodeAnnouncement_clone(&val_conv);
24839         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
24840 }
24841
24842 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) {
24843         LDKNodeFeatures features_arg_conv;
24844         features_arg_conv.inner = (void*)(features_arg & (~1));
24845         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24846         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
24847         LDKThreeBytes rgb_arg_ref;
24848         CHECK(*((uint32_t*)rgb_arg) == 3);
24849         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
24850         LDKThirtyTwoBytes alias_arg_ref;
24851         CHECK(*((uint32_t*)alias_arg) == 32);
24852         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
24853         LDKCVec_NetAddressZ addresses_arg_constr;
24854         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
24855         if (addresses_arg_constr.datalen > 0)
24856                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24857         else
24858                 addresses_arg_constr.data = NULL;
24859         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
24860         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
24861                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
24862                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
24863                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
24864         }
24865         LDKNodeAnnouncement announcement_message_arg_conv;
24866         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
24867         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
24868         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
24869         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
24870         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24871         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24872         uint64_t ret_ref = (uint64_t)ret_var.inner;
24873         if (ret_var.is_owned) {
24874                 ret_ref |= 1;
24875         }
24876         return ret_ref;
24877 }
24878
24879 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
24880         LDKNodeAnnouncementInfo orig_conv;
24881         orig_conv.inner = (void*)(orig & (~1));
24882         orig_conv.is_owned = false;
24883         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
24884         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24885         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24886         uint64_t ret_ref = (uint64_t)ret_var.inner;
24887         if (ret_var.is_owned) {
24888                 ret_ref |= 1;
24889         }
24890         return ret_ref;
24891 }
24892
24893 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
24894         LDKNodeAnnouncementInfo obj_conv;
24895         obj_conv.inner = (void*)(obj & (~1));
24896         obj_conv.is_owned = false;
24897         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
24898         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24899         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24900         CVec_u8Z_free(ret_var);
24901         return ret_arr;
24902 }
24903
24904 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
24905         LDKu8slice ser_ref;
24906         ser_ref.datalen = *((uint32_t*)ser);
24907         ser_ref.data = (int8_t*)(ser + 4);
24908         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
24909         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
24910         return (uint64_t)ret_conv;
24911 }
24912
24913 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_obj) {
24914         LDKNodeInfo this_obj_conv;
24915         this_obj_conv.inner = (void*)(this_obj & (~1));
24916         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24917         NodeInfo_free(this_obj_conv);
24918 }
24919
24920 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
24921         LDKNodeInfo this_ptr_conv;
24922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24923         this_ptr_conv.is_owned = false;
24924         LDKCVec_u64Z val_constr;
24925         val_constr.datalen = *((uint32_t*)val);
24926         if (val_constr.datalen > 0)
24927                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24928         else
24929                 val_constr.data = NULL;
24930         int64_t* val_vals = (int64_t*)(val + 4);
24931         for (size_t i = 0; i < val_constr.datalen; i++) {
24932                 int64_t val_conv_8 = val_vals[i];
24933                 val_constr.data[i] = val_conv_8;
24934         }
24935         NodeInfo_set_channels(&this_ptr_conv, val_constr);
24936 }
24937
24938 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
24939         LDKNodeInfo this_ptr_conv;
24940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24941         this_ptr_conv.is_owned = false;
24942         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
24943         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24944         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24945         uint64_t ret_ref = (uint64_t)ret_var.inner;
24946         if (ret_var.is_owned) {
24947                 ret_ref |= 1;
24948         }
24949         return ret_ref;
24950 }
24951
24952 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
24953         LDKNodeInfo this_ptr_conv;
24954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24955         this_ptr_conv.is_owned = false;
24956         LDKRoutingFees val_conv;
24957         val_conv.inner = (void*)(val & (~1));
24958         val_conv.is_owned = (val & 1) || (val == 0);
24959         val_conv = RoutingFees_clone(&val_conv);
24960         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
24961 }
24962
24963 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
24964         LDKNodeInfo this_ptr_conv;
24965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24966         this_ptr_conv.is_owned = false;
24967         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
24968         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24969         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24970         uint64_t ret_ref = (uint64_t)ret_var.inner;
24971         if (ret_var.is_owned) {
24972                 ret_ref |= 1;
24973         }
24974         return ret_ref;
24975 }
24976
24977 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
24978         LDKNodeInfo this_ptr_conv;
24979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24980         this_ptr_conv.is_owned = false;
24981         LDKNodeAnnouncementInfo val_conv;
24982         val_conv.inner = (void*)(val & (~1));
24983         val_conv.is_owned = (val & 1) || (val == 0);
24984         val_conv = NodeAnnouncementInfo_clone(&val_conv);
24985         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
24986 }
24987
24988 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
24989         LDKCVec_u64Z channels_arg_constr;
24990         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
24991         if (channels_arg_constr.datalen > 0)
24992                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
24993         else
24994                 channels_arg_constr.data = NULL;
24995         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
24996         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
24997                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
24998                 channels_arg_constr.data[i] = channels_arg_conv_8;
24999         }
25000         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
25001         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
25002         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
25003         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
25004         LDKNodeAnnouncementInfo announcement_info_arg_conv;
25005         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
25006         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
25007         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
25008         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
25009         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25010         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25011         uint64_t ret_ref = (uint64_t)ret_var.inner;
25012         if (ret_var.is_owned) {
25013                 ret_ref |= 1;
25014         }
25015         return ret_ref;
25016 }
25017
25018 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig) {
25019         LDKNodeInfo orig_conv;
25020         orig_conv.inner = (void*)(orig & (~1));
25021         orig_conv.is_owned = false;
25022         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
25023         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25024         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25025         uint64_t ret_ref = (uint64_t)ret_var.inner;
25026         if (ret_var.is_owned) {
25027                 ret_ref |= 1;
25028         }
25029         return ret_ref;
25030 }
25031
25032 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
25033         LDKNodeInfo obj_conv;
25034         obj_conv.inner = (void*)(obj & (~1));
25035         obj_conv.is_owned = false;
25036         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
25037         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25038         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25039         CVec_u8Z_free(ret_var);
25040         return ret_arr;
25041 }
25042
25043 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
25044         LDKu8slice ser_ref;
25045         ser_ref.datalen = *((uint32_t*)ser);
25046         ser_ref.data = (int8_t*)(ser + 4);
25047         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
25048         *ret_conv = NodeInfo_read(ser_ref);
25049         return (uint64_t)ret_conv;
25050 }
25051
25052 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
25053         LDKNetworkGraph obj_conv;
25054         obj_conv.inner = (void*)(obj & (~1));
25055         obj_conv.is_owned = false;
25056         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
25057         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25058         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25059         CVec_u8Z_free(ret_var);
25060         return ret_arr;
25061 }
25062
25063 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
25064         LDKu8slice ser_ref;
25065         ser_ref.datalen = *((uint32_t*)ser);
25066         ser_ref.data = (int8_t*)(ser + 4);
25067         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
25068         *ret_conv = NetworkGraph_read(ser_ref);
25069         return (uint64_t)ret_conv;
25070 }
25071
25072 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
25073         LDKThirtyTwoBytes genesis_hash_ref;
25074         CHECK(*((uint32_t*)genesis_hash) == 32);
25075         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
25076         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
25077         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25078         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25079         uint64_t ret_ref = (uint64_t)ret_var.inner;
25080         if (ret_var.is_owned) {
25081                 ret_ref |= 1;
25082         }
25083         return ret_ref;
25084 }
25085
25086 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
25087         LDKNetworkGraph this_arg_conv;
25088         this_arg_conv.inner = (void*)(this_arg & (~1));
25089         this_arg_conv.is_owned = false;
25090         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
25091         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25092         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25093         uint64_t ret_ref = (uint64_t)ret_var.inner;
25094         if (ret_var.is_owned) {
25095                 ret_ref |= 1;
25096         }
25097         return ret_ref;
25098 }
25099
25100 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
25101         LDKNetworkGraph this_arg_conv;
25102         this_arg_conv.inner = (void*)(this_arg & (~1));
25103         this_arg_conv.is_owned = false;
25104         LDKNodeAnnouncement msg_conv;
25105         msg_conv.inner = (void*)(msg & (~1));
25106         msg_conv.is_owned = false;
25107         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25108         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
25109         return (uint64_t)ret_conv;
25110 }
25111
25112 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
25113         LDKNetworkGraph this_arg_conv;
25114         this_arg_conv.inner = (void*)(this_arg & (~1));
25115         this_arg_conv.is_owned = false;
25116         LDKUnsignedNodeAnnouncement msg_conv;
25117         msg_conv.inner = (void*)(msg & (~1));
25118         msg_conv.is_owned = false;
25119         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25120         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
25121         return (uint64_t)ret_conv;
25122 }
25123
25124 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
25125         LDKNetworkGraph this_arg_conv;
25126         this_arg_conv.inner = (void*)(this_arg & (~1));
25127         this_arg_conv.is_owned = false;
25128         LDKChannelAnnouncement msg_conv;
25129         msg_conv.inner = (void*)(msg & (~1));
25130         msg_conv.is_owned = false;
25131         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
25132         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
25133         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
25134                 // Manually implement clone for Java trait instances
25135         }
25136         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25137         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
25138         return (uint64_t)ret_conv;
25139 }
25140
25141 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
25142         LDKNetworkGraph this_arg_conv;
25143         this_arg_conv.inner = (void*)(this_arg & (~1));
25144         this_arg_conv.is_owned = false;
25145         LDKUnsignedChannelAnnouncement msg_conv;
25146         msg_conv.inner = (void*)(msg & (~1));
25147         msg_conv.is_owned = false;
25148         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(((uint64_t)chain_access) & ~1);
25149         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
25150         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
25151                 // Manually implement clone for Java trait instances
25152         }
25153         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25154         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
25155         return (uint64_t)ret_conv;
25156 }
25157
25158 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
25159         LDKNetworkGraph this_arg_conv;
25160         this_arg_conv.inner = (void*)(this_arg & (~1));
25161         this_arg_conv.is_owned = false;
25162         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
25163 }
25164
25165 void  __attribute__((visibility("default"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
25166         LDKNetworkGraph this_arg_conv;
25167         this_arg_conv.inner = (void*)(this_arg & (~1));
25168         this_arg_conv.is_owned = false;
25169         LDKPublicKey _node_id_ref;
25170         CHECK(*((uint32_t*)_node_id) == 33);
25171         memcpy(_node_id_ref.compressed_form, (uint8_t*)(_node_id + 4), 33);
25172         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
25173 }
25174
25175 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
25176         LDKNetworkGraph this_arg_conv;
25177         this_arg_conv.inner = (void*)(this_arg & (~1));
25178         this_arg_conv.is_owned = false;
25179         LDKChannelUpdate msg_conv;
25180         msg_conv.inner = (void*)(msg & (~1));
25181         msg_conv.is_owned = false;
25182         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25183         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
25184         return (uint64_t)ret_conv;
25185 }
25186
25187 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
25188         LDKNetworkGraph this_arg_conv;
25189         this_arg_conv.inner = (void*)(this_arg & (~1));
25190         this_arg_conv.is_owned = false;
25191         LDKUnsignedChannelUpdate msg_conv;
25192         msg_conv.inner = (void*)(msg & (~1));
25193         msg_conv.is_owned = false;
25194         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25195         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
25196         return (uint64_t)ret_conv;
25197 }
25198
25199 void  __attribute__((visibility("default"))) TS_FilesystemPersister_free(uint32_t this_obj) {
25200         LDKFilesystemPersister this_obj_conv;
25201         this_obj_conv.inner = (void*)(this_obj & (~1));
25202         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25203         FilesystemPersister_free(this_obj_conv);
25204 }
25205
25206 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_new(jstring path_to_channel_data) {
25207         LDKStr path_to_channel_data_conv = str_ref_to_owned_c(path_to_channel_data);
25208         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
25209         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25210         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25211         uint64_t ret_ref = (uint64_t)ret_var.inner;
25212         if (ret_var.is_owned) {
25213                 ret_ref |= 1;
25214         }
25215         return ret_ref;
25216 }
25217
25218 jstring  __attribute__((visibility("default"))) TS_FilesystemPersister_get_data_dir(uint32_t this_arg) {
25219         LDKFilesystemPersister this_arg_conv;
25220         this_arg_conv.inner = (void*)(this_arg & (~1));
25221         this_arg_conv.is_owned = false;
25222         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
25223         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
25224         Str_free(ret_str);
25225         return ret_conv;
25226 }
25227
25228 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_persist_manager(jstring data_dir, uint32_t manager) {
25229         LDKStr data_dir_conv = str_ref_to_owned_c(data_dir);
25230         LDKChannelManager manager_conv;
25231         manager_conv.inner = (void*)(manager & (~1));
25232         manager_conv.is_owned = false;
25233         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25234         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
25235         return (uint64_t)ret_conv;
25236 }
25237
25238 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_read_channelmonitors(uint32_t this_arg, uint32_t keys_manager) {
25239         LDKFilesystemPersister this_arg_conv;
25240         this_arg_conv.inner = (void*)(this_arg & (~1));
25241         this_arg_conv.is_owned = false;
25242         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
25243         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
25244         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
25245         return (uint64_t)ret_conv;
25246 }
25247
25248 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_as_Persist(uint32_t this_arg) {
25249         LDKFilesystemPersister this_arg_conv;
25250         this_arg_conv.inner = (void*)(this_arg & (~1));
25251         this_arg_conv.is_owned = false;
25252         LDKPersist* ret_ret =MALLOC(sizeof(LDKPersist), "LDKPersist");
25253         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
25254         return (uint64_t)ret_ret;
25255 }
25256
25257 void  __attribute__((visibility("default"))) TS_BackgroundProcessor_free(uint32_t this_obj) {
25258         LDKBackgroundProcessor this_obj_conv;
25259         this_obj_conv.inner = (void*)(this_obj & (~1));
25260         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25261         BackgroundProcessor_free(this_obj_conv);
25262 }
25263
25264 void  __attribute__((visibility("default"))) TS_ChannelManagerPersister_free(uint32_t this_ptr) {
25265         if ((this_ptr & 1) != 0) return;
25266         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
25267         FREE((void*)this_ptr);
25268         ChannelManagerPersister_free(this_ptr_conv);
25269 }
25270
25271 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) {
25272         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
25273         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
25274         LDKChainMonitor chain_monitor_conv;
25275         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
25276         chain_monitor_conv.is_owned = false;
25277         LDKChannelManager channel_manager_conv;
25278         channel_manager_conv.inner = (void*)(channel_manager & (~1));
25279         channel_manager_conv.is_owned = false;
25280         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
25281         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
25282         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
25283         LDKPeerManager peer_manager_conv;
25284         peer_manager_conv.inner = (void*)(peer_manager & (~1));
25285         peer_manager_conv.is_owned = false;
25286         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25287         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);
25288         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25289         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25290         uint64_t ret_ref = (uint64_t)ret_var.inner;
25291         if (ret_var.is_owned) {
25292                 ret_ref |= 1;
25293         }
25294         return ret_ref;
25295 }
25296
25297 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_join(uint32_t this_arg) {
25298         LDKBackgroundProcessor this_arg_conv;
25299         this_arg_conv.inner = (void*)(this_arg & (~1));
25300         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25301         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
25302         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25303         *ret_conv = BackgroundProcessor_join(this_arg_conv);
25304         return (uint64_t)ret_conv;
25305 }
25306
25307 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_stop(uint32_t this_arg) {
25308         LDKBackgroundProcessor this_arg_conv;
25309         this_arg_conv.inner = (void*)(this_arg & (~1));
25310         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25311         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
25312         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25313         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
25314         return (uint64_t)ret_conv;
25315 }
25316
25317 void  __attribute__((visibility("default"))) TS_check_platform() {
25318         check_platform();
25319 }
25320
25321 void  __attribute__((visibility("default"))) TS_Invoice_free(uint32_t this_obj) {
25322         LDKInvoice this_obj_conv;
25323         this_obj_conv.inner = (void*)(this_obj & (~1));
25324         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25325         Invoice_free(this_obj_conv);
25326 }
25327
25328 jboolean  __attribute__((visibility("default"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
25329         LDKInvoice a_conv;
25330         a_conv.inner = (void*)(a & (~1));
25331         a_conv.is_owned = false;
25332         LDKInvoice b_conv;
25333         b_conv.inner = (void*)(b & (~1));
25334         b_conv.is_owned = false;
25335         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
25336         return ret_val;
25337 }
25338
25339 uint32_t  __attribute__((visibility("default"))) TS_Invoice_clone(uint32_t orig) {
25340         LDKInvoice orig_conv;
25341         orig_conv.inner = (void*)(orig & (~1));
25342         orig_conv.is_owned = false;
25343         LDKInvoice ret_var = Invoice_clone(&orig_conv);
25344         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25345         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25346         uint64_t ret_ref = (uint64_t)ret_var.inner;
25347         if (ret_var.is_owned) {
25348                 ret_ref |= 1;
25349         }
25350         return ret_ref;
25351 }
25352
25353 void  __attribute__((visibility("default"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
25354         LDKSignedRawInvoice this_obj_conv;
25355         this_obj_conv.inner = (void*)(this_obj & (~1));
25356         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25357         SignedRawInvoice_free(this_obj_conv);
25358 }
25359
25360 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
25361         LDKSignedRawInvoice a_conv;
25362         a_conv.inner = (void*)(a & (~1));
25363         a_conv.is_owned = false;
25364         LDKSignedRawInvoice b_conv;
25365         b_conv.inner = (void*)(b & (~1));
25366         b_conv.is_owned = false;
25367         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
25368         return ret_val;
25369 }
25370
25371 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_clone(uint32_t orig) {
25372         LDKSignedRawInvoice orig_conv;
25373         orig_conv.inner = (void*)(orig & (~1));
25374         orig_conv.is_owned = false;
25375         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
25376         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25377         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25378         uint64_t ret_ref = (uint64_t)ret_var.inner;
25379         if (ret_var.is_owned) {
25380                 ret_ref |= 1;
25381         }
25382         return ret_ref;
25383 }
25384
25385 void  __attribute__((visibility("default"))) TS_RawInvoice_free(uint32_t this_obj) {
25386         LDKRawInvoice this_obj_conv;
25387         this_obj_conv.inner = (void*)(this_obj & (~1));
25388         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25389         RawInvoice_free(this_obj_conv);
25390 }
25391
25392 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
25393         LDKRawInvoice this_ptr_conv;
25394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25395         this_ptr_conv.is_owned = false;
25396         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
25397         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25398         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25399         uint64_t ret_ref = (uint64_t)ret_var.inner;
25400         if (ret_var.is_owned) {
25401                 ret_ref |= 1;
25402         }
25403         return ret_ref;
25404 }
25405
25406 void  __attribute__((visibility("default"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
25407         LDKRawInvoice this_ptr_conv;
25408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25409         this_ptr_conv.is_owned = false;
25410         LDKRawDataPart val_conv;
25411         val_conv.inner = (void*)(val & (~1));
25412         val_conv.is_owned = (val & 1) || (val == 0);
25413         val_conv = RawDataPart_clone(&val_conv);
25414         RawInvoice_set_data(&this_ptr_conv, val_conv);
25415 }
25416
25417 jboolean  __attribute__((visibility("default"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
25418         LDKRawInvoice a_conv;
25419         a_conv.inner = (void*)(a & (~1));
25420         a_conv.is_owned = false;
25421         LDKRawInvoice b_conv;
25422         b_conv.inner = (void*)(b & (~1));
25423         b_conv.is_owned = false;
25424         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
25425         return ret_val;
25426 }
25427
25428 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_clone(uint32_t orig) {
25429         LDKRawInvoice orig_conv;
25430         orig_conv.inner = (void*)(orig & (~1));
25431         orig_conv.is_owned = false;
25432         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
25433         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25434         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25435         uint64_t ret_ref = (uint64_t)ret_var.inner;
25436         if (ret_var.is_owned) {
25437                 ret_ref |= 1;
25438         }
25439         return ret_ref;
25440 }
25441
25442 void  __attribute__((visibility("default"))) TS_RawDataPart_free(uint32_t this_obj) {
25443         LDKRawDataPart this_obj_conv;
25444         this_obj_conv.inner = (void*)(this_obj & (~1));
25445         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25446         RawDataPart_free(this_obj_conv);
25447 }
25448
25449 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
25450         LDKRawDataPart this_ptr_conv;
25451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25452         this_ptr_conv.is_owned = false;
25453         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
25454         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25455         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25456         uint64_t ret_ref = (uint64_t)ret_var.inner;
25457         if (ret_var.is_owned) {
25458                 ret_ref |= 1;
25459         }
25460         return ret_ref;
25461 }
25462
25463 void  __attribute__((visibility("default"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
25464         LDKRawDataPart this_ptr_conv;
25465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25466         this_ptr_conv.is_owned = false;
25467         LDKPositiveTimestamp val_conv;
25468         val_conv.inner = (void*)(val & (~1));
25469         val_conv.is_owned = (val & 1) || (val == 0);
25470         val_conv = PositiveTimestamp_clone(&val_conv);
25471         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
25472 }
25473
25474 jboolean  __attribute__((visibility("default"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
25475         LDKRawDataPart a_conv;
25476         a_conv.inner = (void*)(a & (~1));
25477         a_conv.is_owned = false;
25478         LDKRawDataPart b_conv;
25479         b_conv.inner = (void*)(b & (~1));
25480         b_conv.is_owned = false;
25481         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
25482         return ret_val;
25483 }
25484
25485 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_clone(uint32_t orig) {
25486         LDKRawDataPart orig_conv;
25487         orig_conv.inner = (void*)(orig & (~1));
25488         orig_conv.is_owned = false;
25489         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
25490         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25491         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25492         uint64_t ret_ref = (uint64_t)ret_var.inner;
25493         if (ret_var.is_owned) {
25494                 ret_ref |= 1;
25495         }
25496         return ret_ref;
25497 }
25498
25499 void  __attribute__((visibility("default"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
25500         LDKPositiveTimestamp this_obj_conv;
25501         this_obj_conv.inner = (void*)(this_obj & (~1));
25502         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25503         PositiveTimestamp_free(this_obj_conv);
25504 }
25505
25506 jboolean  __attribute__((visibility("default"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
25507         LDKPositiveTimestamp a_conv;
25508         a_conv.inner = (void*)(a & (~1));
25509         a_conv.is_owned = false;
25510         LDKPositiveTimestamp b_conv;
25511         b_conv.inner = (void*)(b & (~1));
25512         b_conv.is_owned = false;
25513         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
25514         return ret_val;
25515 }
25516
25517 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_clone(uint32_t orig) {
25518         LDKPositiveTimestamp orig_conv;
25519         orig_conv.inner = (void*)(orig & (~1));
25520         orig_conv.is_owned = false;
25521         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
25522         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25523         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25524         uint64_t ret_ref = (uint64_t)ret_var.inner;
25525         if (ret_var.is_owned) {
25526                 ret_ref |= 1;
25527         }
25528         return ret_ref;
25529 }
25530
25531 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_clone(uint32_t orig) {
25532         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
25533         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
25534         return ret_conv;
25535 }
25536
25537 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_milli() {
25538         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
25539         return ret_conv;
25540 }
25541
25542 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_micro() {
25543         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
25544         return ret_conv;
25545 }
25546
25547 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_nano() {
25548         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
25549         return ret_conv;
25550 }
25551
25552 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_pico() {
25553         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
25554         return ret_conv;
25555 }
25556
25557 jboolean  __attribute__((visibility("default"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
25558         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
25559         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
25560         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
25561         return ret_val;
25562 }
25563
25564 int64_t  __attribute__((visibility("default"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
25565         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
25566         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
25567         return ret_val;
25568 }
25569
25570 uint32_t  __attribute__((visibility("default"))) TS_Currency_clone(uint32_t orig) {
25571         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
25572         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
25573         return ret_conv;
25574 }
25575
25576 uint32_t  __attribute__((visibility("default"))) TS_Currency_bitcoin() {
25577         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
25578         return ret_conv;
25579 }
25580
25581 uint32_t  __attribute__((visibility("default"))) TS_Currency_bitcoin_testnet() {
25582         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
25583         return ret_conv;
25584 }
25585
25586 uint32_t  __attribute__((visibility("default"))) TS_Currency_regtest() {
25587         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
25588         return ret_conv;
25589 }
25590
25591 uint32_t  __attribute__((visibility("default"))) TS_Currency_simnet() {
25592         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
25593         return ret_conv;
25594 }
25595
25596 uint32_t  __attribute__((visibility("default"))) TS_Currency_signet() {
25597         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
25598         return ret_conv;
25599 }
25600
25601 int64_t  __attribute__((visibility("default"))) TS_Currency_hash(uint32_t o) {
25602         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
25603         int64_t ret_val = Currency_hash(o_conv);
25604         return ret_val;
25605 }
25606
25607 jboolean  __attribute__((visibility("default"))) TS_Currency_eq(uint32_t a, uint32_t b) {
25608         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
25609         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
25610         jboolean ret_val = Currency_eq(a_conv, b_conv);
25611         return ret_val;
25612 }
25613
25614 void  __attribute__((visibility("default"))) TS_Sha256_free(uint32_t this_obj) {
25615         LDKSha256 this_obj_conv;
25616         this_obj_conv.inner = (void*)(this_obj & (~1));
25617         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25618         Sha256_free(this_obj_conv);
25619 }
25620
25621 uint32_t  __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) {
25622         LDKSha256 orig_conv;
25623         orig_conv.inner = (void*)(orig & (~1));
25624         orig_conv.is_owned = false;
25625         LDKSha256 ret_var = Sha256_clone(&orig_conv);
25626         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25627         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25628         uint64_t ret_ref = (uint64_t)ret_var.inner;
25629         if (ret_var.is_owned) {
25630                 ret_ref |= 1;
25631         }
25632         return ret_ref;
25633 }
25634
25635 int64_t  __attribute__((visibility("default"))) TS_Sha256_hash(uint32_t o) {
25636         LDKSha256 o_conv;
25637         o_conv.inner = (void*)(o & (~1));
25638         o_conv.is_owned = false;
25639         int64_t ret_val = Sha256_hash(&o_conv);
25640         return ret_val;
25641 }
25642
25643 jboolean  __attribute__((visibility("default"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
25644         LDKSha256 a_conv;
25645         a_conv.inner = (void*)(a & (~1));
25646         a_conv.is_owned = false;
25647         LDKSha256 b_conv;
25648         b_conv.inner = (void*)(b & (~1));
25649         b_conv.is_owned = false;
25650         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
25651         return ret_val;
25652 }
25653
25654 void  __attribute__((visibility("default"))) TS_Description_free(uint32_t this_obj) {
25655         LDKDescription this_obj_conv;
25656         this_obj_conv.inner = (void*)(this_obj & (~1));
25657         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25658         Description_free(this_obj_conv);
25659 }
25660
25661 uint32_t  __attribute__((visibility("default"))) TS_Description_clone(uint32_t orig) {
25662         LDKDescription orig_conv;
25663         orig_conv.inner = (void*)(orig & (~1));
25664         orig_conv.is_owned = false;
25665         LDKDescription ret_var = Description_clone(&orig_conv);
25666         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25667         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25668         uint64_t ret_ref = (uint64_t)ret_var.inner;
25669         if (ret_var.is_owned) {
25670                 ret_ref |= 1;
25671         }
25672         return ret_ref;
25673 }
25674
25675 int64_t  __attribute__((visibility("default"))) TS_Description_hash(uint32_t o) {
25676         LDKDescription o_conv;
25677         o_conv.inner = (void*)(o & (~1));
25678         o_conv.is_owned = false;
25679         int64_t ret_val = Description_hash(&o_conv);
25680         return ret_val;
25681 }
25682
25683 jboolean  __attribute__((visibility("default"))) TS_Description_eq(uint32_t a, uint32_t b) {
25684         LDKDescription a_conv;
25685         a_conv.inner = (void*)(a & (~1));
25686         a_conv.is_owned = false;
25687         LDKDescription b_conv;
25688         b_conv.inner = (void*)(b & (~1));
25689         b_conv.is_owned = false;
25690         jboolean ret_val = Description_eq(&a_conv, &b_conv);
25691         return ret_val;
25692 }
25693
25694 void  __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_obj) {
25695         LDKPayeePubKey this_obj_conv;
25696         this_obj_conv.inner = (void*)(this_obj & (~1));
25697         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25698         PayeePubKey_free(this_obj_conv);
25699 }
25700
25701 uint32_t  __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t orig) {
25702         LDKPayeePubKey orig_conv;
25703         orig_conv.inner = (void*)(orig & (~1));
25704         orig_conv.is_owned = false;
25705         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
25706         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25707         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25708         uint64_t ret_ref = (uint64_t)ret_var.inner;
25709         if (ret_var.is_owned) {
25710                 ret_ref |= 1;
25711         }
25712         return ret_ref;
25713 }
25714
25715 int64_t  __attribute__((visibility("default"))) TS_PayeePubKey_hash(uint32_t o) {
25716         LDKPayeePubKey o_conv;
25717         o_conv.inner = (void*)(o & (~1));
25718         o_conv.is_owned = false;
25719         int64_t ret_val = PayeePubKey_hash(&o_conv);
25720         return ret_val;
25721 }
25722
25723 jboolean  __attribute__((visibility("default"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
25724         LDKPayeePubKey a_conv;
25725         a_conv.inner = (void*)(a & (~1));
25726         a_conv.is_owned = false;
25727         LDKPayeePubKey b_conv;
25728         b_conv.inner = (void*)(b & (~1));
25729         b_conv.is_owned = false;
25730         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
25731         return ret_val;
25732 }
25733
25734 void  __attribute__((visibility("default"))) TS_ExpiryTime_free(uint32_t this_obj) {
25735         LDKExpiryTime this_obj_conv;
25736         this_obj_conv.inner = (void*)(this_obj & (~1));
25737         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25738         ExpiryTime_free(this_obj_conv);
25739 }
25740
25741 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t orig) {
25742         LDKExpiryTime orig_conv;
25743         orig_conv.inner = (void*)(orig & (~1));
25744         orig_conv.is_owned = false;
25745         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
25746         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25747         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25748         uint64_t ret_ref = (uint64_t)ret_var.inner;
25749         if (ret_var.is_owned) {
25750                 ret_ref |= 1;
25751         }
25752         return ret_ref;
25753 }
25754
25755 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_hash(uint32_t o) {
25756         LDKExpiryTime o_conv;
25757         o_conv.inner = (void*)(o & (~1));
25758         o_conv.is_owned = false;
25759         int64_t ret_val = ExpiryTime_hash(&o_conv);
25760         return ret_val;
25761 }
25762
25763 jboolean  __attribute__((visibility("default"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
25764         LDKExpiryTime a_conv;
25765         a_conv.inner = (void*)(a & (~1));
25766         a_conv.is_owned = false;
25767         LDKExpiryTime b_conv;
25768         b_conv.inner = (void*)(b & (~1));
25769         b_conv.is_owned = false;
25770         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
25771         return ret_val;
25772 }
25773
25774 void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
25775         LDKMinFinalCltvExpiry this_obj_conv;
25776         this_obj_conv.inner = (void*)(this_obj & (~1));
25777         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25778         MinFinalCltvExpiry_free(this_obj_conv);
25779 }
25780
25781 uint32_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
25782         LDKMinFinalCltvExpiry orig_conv;
25783         orig_conv.inner = (void*)(orig & (~1));
25784         orig_conv.is_owned = false;
25785         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
25786         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25787         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25788         uint64_t ret_ref = (uint64_t)ret_var.inner;
25789         if (ret_var.is_owned) {
25790                 ret_ref |= 1;
25791         }
25792         return ret_ref;
25793 }
25794
25795 int64_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
25796         LDKMinFinalCltvExpiry o_conv;
25797         o_conv.inner = (void*)(o & (~1));
25798         o_conv.is_owned = false;
25799         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
25800         return ret_val;
25801 }
25802
25803 jboolean  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
25804         LDKMinFinalCltvExpiry a_conv;
25805         a_conv.inner = (void*)(a & (~1));
25806         a_conv.is_owned = false;
25807         LDKMinFinalCltvExpiry b_conv;
25808         b_conv.inner = (void*)(b & (~1));
25809         b_conv.is_owned = false;
25810         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
25811         return ret_val;
25812 }
25813
25814 void  __attribute__((visibility("default"))) TS_Fallback_free(uint32_t this_ptr) {
25815         if ((this_ptr & 1) != 0) return;
25816         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
25817         FREE((void*)this_ptr);
25818         Fallback_free(this_ptr_conv);
25819 }
25820
25821 uint32_t  __attribute__((visibility("default"))) TS_Fallback_clone(uint32_t orig) {
25822         LDKFallback* orig_conv = (LDKFallback*)orig;
25823         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
25824         *ret_copy = Fallback_clone(orig_conv);
25825         uint64_t ret_ref = (uint64_t)ret_copy;
25826         return ret_ref;
25827 }
25828
25829 uint32_t  __attribute__((visibility("default"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
25830         
25831         LDKCVec_u8Z program_ref;
25832         program_ref.datalen = *((uint32_t*)program);
25833         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
25834         memcpy(program_ref.data, (uint8_t*)(program + 4), program_ref.datalen);
25835         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
25836         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
25837         uint64_t ret_ref = (uint64_t)ret_copy;
25838         return ret_ref;
25839 }
25840
25841 uint32_t  __attribute__((visibility("default"))) TS_Fallback_pub_key_hash(int8_tArray a) {
25842         LDKTwentyBytes a_ref;
25843         CHECK(*((uint32_t*)a) == 20);
25844         memcpy(a_ref.data, (uint8_t*)(a + 4), 20);
25845         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
25846         *ret_copy = Fallback_pub_key_hash(a_ref);
25847         uint64_t ret_ref = (uint64_t)ret_copy;
25848         return ret_ref;
25849 }
25850
25851 uint32_t  __attribute__((visibility("default"))) TS_Fallback_script_hash(int8_tArray a) {
25852         LDKTwentyBytes a_ref;
25853         CHECK(*((uint32_t*)a) == 20);
25854         memcpy(a_ref.data, (uint8_t*)(a + 4), 20);
25855         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
25856         *ret_copy = Fallback_script_hash(a_ref);
25857         uint64_t ret_ref = (uint64_t)ret_copy;
25858         return ret_ref;
25859 }
25860
25861 int64_t  __attribute__((visibility("default"))) TS_Fallback_hash(uint32_t o) {
25862         LDKFallback* o_conv = (LDKFallback*)o;
25863         int64_t ret_val = Fallback_hash(o_conv);
25864         return ret_val;
25865 }
25866
25867 jboolean  __attribute__((visibility("default"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
25868         LDKFallback* a_conv = (LDKFallback*)a;
25869         LDKFallback* b_conv = (LDKFallback*)b;
25870         jboolean ret_val = Fallback_eq(a_conv, b_conv);
25871         return ret_val;
25872 }
25873
25874 void  __attribute__((visibility("default"))) TS_InvoiceSignature_free(uint32_t this_obj) {
25875         LDKInvoiceSignature this_obj_conv;
25876         this_obj_conv.inner = (void*)(this_obj & (~1));
25877         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25878         InvoiceSignature_free(this_obj_conv);
25879 }
25880
25881 uint32_t  __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint32_t orig) {
25882         LDKInvoiceSignature orig_conv;
25883         orig_conv.inner = (void*)(orig & (~1));
25884         orig_conv.is_owned = false;
25885         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
25886         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25887         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25888         uint64_t ret_ref = (uint64_t)ret_var.inner;
25889         if (ret_var.is_owned) {
25890                 ret_ref |= 1;
25891         }
25892         return ret_ref;
25893 }
25894
25895 jboolean  __attribute__((visibility("default"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
25896         LDKInvoiceSignature a_conv;
25897         a_conv.inner = (void*)(a & (~1));
25898         a_conv.is_owned = false;
25899         LDKInvoiceSignature b_conv;
25900         b_conv.inner = (void*)(b & (~1));
25901         b_conv.is_owned = false;
25902         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
25903         return ret_val;
25904 }
25905
25906 void  __attribute__((visibility("default"))) TS_PrivateRoute_free(uint32_t this_obj) {
25907         LDKPrivateRoute this_obj_conv;
25908         this_obj_conv.inner = (void*)(this_obj & (~1));
25909         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25910         PrivateRoute_free(this_obj_conv);
25911 }
25912
25913 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t orig) {
25914         LDKPrivateRoute orig_conv;
25915         orig_conv.inner = (void*)(orig & (~1));
25916         orig_conv.is_owned = false;
25917         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
25918         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25919         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25920         uint64_t ret_ref = (uint64_t)ret_var.inner;
25921         if (ret_var.is_owned) {
25922                 ret_ref |= 1;
25923         }
25924         return ret_ref;
25925 }
25926
25927 int64_t  __attribute__((visibility("default"))) TS_PrivateRoute_hash(uint32_t o) {
25928         LDKPrivateRoute o_conv;
25929         o_conv.inner = (void*)(o & (~1));
25930         o_conv.is_owned = false;
25931         int64_t ret_val = PrivateRoute_hash(&o_conv);
25932         return ret_val;
25933 }
25934
25935 jboolean  __attribute__((visibility("default"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
25936         LDKPrivateRoute a_conv;
25937         a_conv.inner = (void*)(a & (~1));
25938         a_conv.is_owned = false;
25939         LDKPrivateRoute b_conv;
25940         b_conv.inner = (void*)(b & (~1));
25941         b_conv.is_owned = false;
25942         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
25943         return ret_val;
25944 }
25945
25946 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
25947         LDKSignedRawInvoice this_arg_conv;
25948         this_arg_conv.inner = (void*)(this_arg & (~1));
25949         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25950         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
25951         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
25952         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
25953         return ((uint64_t)ret_conv);
25954 }
25955
25956 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
25957         LDKSignedRawInvoice this_arg_conv;
25958         this_arg_conv.inner = (void*)(this_arg & (~1));
25959         this_arg_conv.is_owned = false;
25960         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
25961         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25962         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25963         uint64_t ret_ref = (uint64_t)ret_var.inner;
25964         if (ret_var.is_owned) {
25965                 ret_ref |= 1;
25966         }
25967         return ret_ref;
25968 }
25969
25970 int8_tArray  __attribute__((visibility("default"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
25971         LDKSignedRawInvoice this_arg_conv;
25972         this_arg_conv.inner = (void*)(this_arg & (~1));
25973         this_arg_conv.is_owned = false;
25974         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25975         memcpy((uint8_t*)(ret_arr + 4), *SignedRawInvoice_hash(&this_arg_conv), 32);
25976         return ret_arr;
25977 }
25978
25979 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
25980         LDKSignedRawInvoice this_arg_conv;
25981         this_arg_conv.inner = (void*)(this_arg & (~1));
25982         this_arg_conv.is_owned = false;
25983         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
25984         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25985         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25986         uint64_t ret_ref = (uint64_t)ret_var.inner;
25987         if (ret_var.is_owned) {
25988                 ret_ref |= 1;
25989         }
25990         return ret_ref;
25991 }
25992
25993 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
25994         LDKSignedRawInvoice this_arg_conv;
25995         this_arg_conv.inner = (void*)(this_arg & (~1));
25996         this_arg_conv.is_owned = false;
25997         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
25998         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
25999         return (uint64_t)ret_conv;
26000 }
26001
26002 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
26003         LDKSignedRawInvoice this_arg_conv;
26004         this_arg_conv.inner = (void*)(this_arg & (~1));
26005         this_arg_conv.is_owned = false;
26006         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
26007         return ret_val;
26008 }
26009
26010 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_hash(uint32_t this_arg) {
26011         LDKRawInvoice this_arg_conv;
26012         this_arg_conv.inner = (void*)(this_arg & (~1));
26013         this_arg_conv.is_owned = false;
26014         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26015         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_hash(&this_arg_conv).data, 32);
26016         return ret_arr;
26017 }
26018
26019 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
26020         LDKRawInvoice this_arg_conv;
26021         this_arg_conv.inner = (void*)(this_arg & (~1));
26022         this_arg_conv.is_owned = false;
26023         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
26024         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26025         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26026         uint64_t ret_ref = (uint64_t)ret_var.inner;
26027         if (ret_var.is_owned) {
26028                 ret_ref |= 1;
26029         }
26030         return ret_ref;
26031 }
26032
26033 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description(uint32_t this_arg) {
26034         LDKRawInvoice this_arg_conv;
26035         this_arg_conv.inner = (void*)(this_arg & (~1));
26036         this_arg_conv.is_owned = false;
26037         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
26038         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26039         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26040         uint64_t ret_ref = (uint64_t)ret_var.inner;
26041         if (ret_var.is_owned) {
26042                 ret_ref |= 1;
26043         }
26044         return ret_ref;
26045 }
26046
26047 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
26048         LDKRawInvoice this_arg_conv;
26049         this_arg_conv.inner = (void*)(this_arg & (~1));
26050         this_arg_conv.is_owned = false;
26051         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
26052         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26053         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26054         uint64_t ret_ref = (uint64_t)ret_var.inner;
26055         if (ret_var.is_owned) {
26056                 ret_ref |= 1;
26057         }
26058         return ret_ref;
26059 }
26060
26061 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
26062         LDKRawInvoice this_arg_conv;
26063         this_arg_conv.inner = (void*)(this_arg & (~1));
26064         this_arg_conv.is_owned = false;
26065         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
26066         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26067         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26068         uint64_t ret_ref = (uint64_t)ret_var.inner;
26069         if (ret_var.is_owned) {
26070                 ret_ref |= 1;
26071         }
26072         return ret_ref;
26073 }
26074
26075 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
26076         LDKRawInvoice this_arg_conv;
26077         this_arg_conv.inner = (void*)(this_arg & (~1));
26078         this_arg_conv.is_owned = false;
26079         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
26080         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26081         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26082         uint64_t ret_ref = (uint64_t)ret_var.inner;
26083         if (ret_var.is_owned) {
26084                 ret_ref |= 1;
26085         }
26086         return ret_ref;
26087 }
26088
26089 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
26090         LDKRawInvoice this_arg_conv;
26091         this_arg_conv.inner = (void*)(this_arg & (~1));
26092         this_arg_conv.is_owned = false;
26093         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
26094         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26095         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26096         uint64_t ret_ref = (uint64_t)ret_var.inner;
26097         if (ret_var.is_owned) {
26098                 ret_ref |= 1;
26099         }
26100         return ret_ref;
26101 }
26102
26103 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
26104         LDKRawInvoice this_arg_conv;
26105         this_arg_conv.inner = (void*)(this_arg & (~1));
26106         this_arg_conv.is_owned = false;
26107         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26108         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_payment_secret(&this_arg_conv).data, 32);
26109         return ret_arr;
26110 }
26111
26112 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_features(uint32_t this_arg) {
26113         LDKRawInvoice this_arg_conv;
26114         this_arg_conv.inner = (void*)(this_arg & (~1));
26115         this_arg_conv.is_owned = false;
26116         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
26117         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26118         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26119         uint64_t ret_ref = (uint64_t)ret_var.inner;
26120         if (ret_var.is_owned) {
26121                 ret_ref |= 1;
26122         }
26123         return ret_ref;
26124 }
26125
26126 uint32_tArray  __attribute__((visibility("default"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
26127         LDKRawInvoice this_arg_conv;
26128         this_arg_conv.inner = (void*)(this_arg & (~1));
26129         this_arg_conv.is_owned = false;
26130         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
26131         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
26132         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
26133         for (size_t o = 0; o < ret_var.datalen; o++) {
26134                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
26135                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26136                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26137                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
26138                 if (ret_conv_14_var.is_owned) {
26139                         ret_conv_14_ref |= 1;
26140                 }
26141                 ret_arr_ptr[o] = ret_conv_14_ref;
26142         }
26143         FREE(ret_var.data);
26144         return ret_arr;
26145 }
26146
26147 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
26148         LDKRawInvoice this_arg_conv;
26149         this_arg_conv.inner = (void*)(this_arg & (~1));
26150         this_arg_conv.is_owned = false;
26151         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26152         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
26153         uint64_t ret_ref = (uint64_t)ret_copy;
26154         return ret_ref;
26155 }
26156
26157 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_currency(uint32_t this_arg) {
26158         LDKRawInvoice this_arg_conv;
26159         this_arg_conv.inner = (void*)(this_arg & (~1));
26160         this_arg_conv.is_owned = false;
26161         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
26162         return ret_conv;
26163 }
26164
26165 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
26166         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
26167         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
26168         return (uint64_t)ret_conv;
26169 }
26170
26171 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_system_time(int64_t time) {
26172         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
26173         *ret_conv = PositiveTimestamp_from_system_time(time);
26174         return (uint64_t)ret_conv;
26175 }
26176
26177 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
26178         LDKPositiveTimestamp this_arg_conv;
26179         this_arg_conv.inner = (void*)(this_arg & (~1));
26180         this_arg_conv.is_owned = false;
26181         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
26182         return ret_val;
26183 }
26184
26185 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_time(uint32_t this_arg) {
26186         LDKPositiveTimestamp this_arg_conv;
26187         this_arg_conv.inner = (void*)(this_arg & (~1));
26188         this_arg_conv.is_owned = false;
26189         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
26190         return ret_val;
26191 }
26192
26193 uint32_t  __attribute__((visibility("default"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
26194         LDKInvoice this_arg_conv;
26195         this_arg_conv.inner = (void*)(this_arg & (~1));
26196         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26197         this_arg_conv = Invoice_clone(&this_arg_conv);
26198         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
26199         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26200         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26201         uint64_t ret_ref = (uint64_t)ret_var.inner;
26202         if (ret_var.is_owned) {
26203                 ret_ref |= 1;
26204         }
26205         return ret_ref;
26206 }
26207
26208 uint32_t  __attribute__((visibility("default"))) TS_Invoice_check_signature(uint32_t this_arg) {
26209         LDKInvoice this_arg_conv;
26210         this_arg_conv.inner = (void*)(this_arg & (~1));
26211         this_arg_conv.is_owned = false;
26212         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
26213         *ret_conv = Invoice_check_signature(&this_arg_conv);
26214         return (uint64_t)ret_conv;
26215 }
26216
26217 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
26218         LDKSignedRawInvoice signed_invoice_conv;
26219         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
26220         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
26221         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
26222         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
26223         *ret_conv = Invoice_from_signed(signed_invoice_conv);
26224         return (uint64_t)ret_conv;
26225 }
26226
26227 int64_t  __attribute__((visibility("default"))) TS_Invoice_timestamp(uint32_t this_arg) {
26228         LDKInvoice this_arg_conv;
26229         this_arg_conv.inner = (void*)(this_arg & (~1));
26230         this_arg_conv.is_owned = false;
26231         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
26232         return ret_val;
26233 }
26234
26235 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_hash(uint32_t this_arg) {
26236         LDKInvoice this_arg_conv;
26237         this_arg_conv.inner = (void*)(this_arg & (~1));
26238         this_arg_conv.is_owned = false;
26239         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26240         memcpy((uint8_t*)(ret_arr + 4), *Invoice_payment_hash(&this_arg_conv), 32);
26241         return ret_arr;
26242 }
26243
26244 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
26245         LDKInvoice this_arg_conv;
26246         this_arg_conv.inner = (void*)(this_arg & (~1));
26247         this_arg_conv.is_owned = false;
26248         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
26249         memcpy((uint8_t*)(ret_arr + 4), Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
26250         return ret_arr;
26251 }
26252
26253 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_secret(uint32_t this_arg) {
26254         LDKInvoice this_arg_conv;
26255         this_arg_conv.inner = (void*)(this_arg & (~1));
26256         this_arg_conv.is_owned = false;
26257         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26258         memcpy((uint8_t*)(ret_arr + 4), Invoice_payment_secret(&this_arg_conv).data, 32);
26259         return ret_arr;
26260 }
26261
26262 uint32_t  __attribute__((visibility("default"))) TS_Invoice_features(uint32_t this_arg) {
26263         LDKInvoice this_arg_conv;
26264         this_arg_conv.inner = (void*)(this_arg & (~1));
26265         this_arg_conv.is_owned = false;
26266         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
26267         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26268         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26269         uint64_t ret_ref = (uint64_t)ret_var.inner;
26270         if (ret_var.is_owned) {
26271                 ret_ref |= 1;
26272         }
26273         return ret_ref;
26274 }
26275
26276 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
26277         LDKInvoice this_arg_conv;
26278         this_arg_conv.inner = (void*)(this_arg & (~1));
26279         this_arg_conv.is_owned = false;
26280         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
26281         memcpy((uint8_t*)(ret_arr + 4), Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
26282         return ret_arr;
26283 }
26284
26285 int64_t  __attribute__((visibility("default"))) TS_Invoice_expiry_time(uint32_t this_arg) {
26286         LDKInvoice this_arg_conv;
26287         this_arg_conv.inner = (void*)(this_arg & (~1));
26288         this_arg_conv.is_owned = false;
26289         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
26290         return ret_val;
26291 }
26292
26293 int64_t  __attribute__((visibility("default"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
26294         LDKInvoice this_arg_conv;
26295         this_arg_conv.inner = (void*)(this_arg & (~1));
26296         this_arg_conv.is_owned = false;
26297         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
26298         return ret_val;
26299 }
26300
26301 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_private_routes(uint32_t this_arg) {
26302         LDKInvoice this_arg_conv;
26303         this_arg_conv.inner = (void*)(this_arg & (~1));
26304         this_arg_conv.is_owned = false;
26305         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
26306         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
26307         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
26308         for (size_t o = 0; o < ret_var.datalen; o++) {
26309                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
26310                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26311                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26312                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
26313                 if (ret_conv_14_var.is_owned) {
26314                         ret_conv_14_ref |= 1;
26315                 }
26316                 ret_arr_ptr[o] = ret_conv_14_ref;
26317         }
26318         FREE(ret_var.data);
26319         return ret_arr;
26320 }
26321
26322 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_route_hints(uint32_t this_arg) {
26323         LDKInvoice this_arg_conv;
26324         this_arg_conv.inner = (void*)(this_arg & (~1));
26325         this_arg_conv.is_owned = false;
26326         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
26327         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
26328         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
26329         for (size_t l = 0; l < ret_var.datalen; l++) {
26330                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
26331                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26332                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26333                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
26334                 if (ret_conv_11_var.is_owned) {
26335                         ret_conv_11_ref |= 1;
26336                 }
26337                 ret_arr_ptr[l] = ret_conv_11_ref;
26338         }
26339         FREE(ret_var.data);
26340         return ret_arr;
26341 }
26342
26343 uint32_t  __attribute__((visibility("default"))) TS_Invoice_currency(uint32_t this_arg) {
26344         LDKInvoice this_arg_conv;
26345         this_arg_conv.inner = (void*)(this_arg & (~1));
26346         this_arg_conv.is_owned = false;
26347         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
26348         return ret_conv;
26349 }
26350
26351 uint32_t  __attribute__((visibility("default"))) TS_Invoice_amount_pico_btc(uint32_t this_arg) {
26352         LDKInvoice this_arg_conv;
26353         this_arg_conv.inner = (void*)(this_arg & (~1));
26354         this_arg_conv.is_owned = false;
26355         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26356         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
26357         uint64_t ret_ref = (uint64_t)ret_copy;
26358         return ret_ref;
26359 }
26360
26361 uint32_t  __attribute__((visibility("default"))) TS_Description_new(jstring description) {
26362         LDKStr description_conv = str_ref_to_owned_c(description);
26363         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
26364         *ret_conv = Description_new(description_conv);
26365         return (uint64_t)ret_conv;
26366 }
26367
26368 jstring  __attribute__((visibility("default"))) TS_Description_into_inner(uint32_t this_arg) {
26369         LDKDescription this_arg_conv;
26370         this_arg_conv.inner = (void*)(this_arg & (~1));
26371         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26372         this_arg_conv = Description_clone(&this_arg_conv);
26373         LDKStr ret_str = Description_into_inner(this_arg_conv);
26374         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26375         Str_free(ret_str);
26376         return ret_conv;
26377 }
26378
26379 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
26380         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
26381         *ret_conv = ExpiryTime_from_seconds(seconds);
26382         return (uint64_t)ret_conv;
26383 }
26384
26385 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_duration(int64_t duration) {
26386         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
26387         *ret_conv = ExpiryTime_from_duration(duration);
26388         return (uint64_t)ret_conv;
26389 }
26390
26391 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
26392         LDKExpiryTime this_arg_conv;
26393         this_arg_conv.inner = (void*)(this_arg & (~1));
26394         this_arg_conv.is_owned = false;
26395         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
26396         return ret_val;
26397 }
26398
26399 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
26400         LDKExpiryTime this_arg_conv;
26401         this_arg_conv.inner = (void*)(this_arg & (~1));
26402         this_arg_conv.is_owned = false;
26403         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
26404         return ret_val;
26405 }
26406
26407 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_new(uint32_t hops) {
26408         LDKRouteHint hops_conv;
26409         hops_conv.inner = (void*)(hops & (~1));
26410         hops_conv.is_owned = (hops & 1) || (hops == 0);
26411         hops_conv = RouteHint_clone(&hops_conv);
26412         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
26413         *ret_conv = PrivateRoute_new(hops_conv);
26414         return (uint64_t)ret_conv;
26415 }
26416
26417 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
26418         LDKPrivateRoute this_arg_conv;
26419         this_arg_conv.inner = (void*)(this_arg & (~1));
26420         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26421         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
26422         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
26423         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26424         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26425         uint64_t ret_ref = (uint64_t)ret_var.inner;
26426         if (ret_var.is_owned) {
26427                 ret_ref |= 1;
26428         }
26429         return ret_ref;
26430 }
26431
26432 uint32_t  __attribute__((visibility("default"))) TS_CreationError_clone(uint32_t orig) {
26433         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
26434         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
26435         return ret_conv;
26436 }
26437
26438 uint32_t  __attribute__((visibility("default"))) TS_CreationError_description_too_long() {
26439         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
26440         return ret_conv;
26441 }
26442
26443 uint32_t  __attribute__((visibility("default"))) TS_CreationError_route_too_long() {
26444         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
26445         return ret_conv;
26446 }
26447
26448 uint32_t  __attribute__((visibility("default"))) TS_CreationError_timestamp_out_of_bounds() {
26449         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
26450         return ret_conv;
26451 }
26452
26453 uint32_t  __attribute__((visibility("default"))) TS_CreationError_expiry_time_out_of_bounds() {
26454         uint32_t ret_conv = LDKCreationError_to_js(CreationError_expiry_time_out_of_bounds());
26455         return ret_conv;
26456 }
26457
26458 jboolean  __attribute__((visibility("default"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
26459         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
26460         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
26461         jboolean ret_val = CreationError_eq(a_conv, b_conv);
26462         return ret_val;
26463 }
26464
26465 jstring  __attribute__((visibility("default"))) TS_CreationError_to_str(uint32_t o) {
26466         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
26467         LDKStr ret_str = CreationError_to_str(o_conv);
26468         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26469         Str_free(ret_str);
26470         return ret_conv;
26471 }
26472
26473 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_clone(uint32_t orig) {
26474         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
26475         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
26476         return ret_conv;
26477 }
26478
26479 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_payment_hash() {
26480         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
26481         return ret_conv;
26482 }
26483
26484 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_hashes() {
26485         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
26486         return ret_conv;
26487 }
26488
26489 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_description() {
26490         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
26491         return ret_conv;
26492 }
26493
26494 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_descriptions() {
26495         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
26496         return ret_conv;
26497 }
26498
26499 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_payment_secret() {
26500         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
26501         return ret_conv;
26502 }
26503
26504 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_secrets() {
26505         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
26506         return ret_conv;
26507 }
26508
26509 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_features() {
26510         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
26511         return ret_conv;
26512 }
26513
26514 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_recovery_id() {
26515         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
26516         return ret_conv;
26517 }
26518
26519 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_signature() {
26520         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
26521         return ret_conv;
26522 }
26523
26524 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_imprecise_amount() {
26525         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
26526         return ret_conv;
26527 }
26528
26529 jboolean  __attribute__((visibility("default"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
26530         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
26531         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
26532         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
26533         return ret_val;
26534 }
26535
26536 jstring  __attribute__((visibility("default"))) TS_SemanticError_to_str(uint32_t o) {
26537         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
26538         LDKStr ret_str = SemanticError_to_str(o_conv);
26539         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26540         Str_free(ret_str);
26541         return ret_conv;
26542 }
26543
26544 void  __attribute__((visibility("default"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
26545         if ((this_ptr & 1) != 0) return;
26546         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
26547         FREE((void*)this_ptr);
26548         SignOrCreationError_free(this_ptr_conv);
26549 }
26550
26551 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_clone(uint32_t orig) {
26552         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
26553         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
26554         *ret_copy = SignOrCreationError_clone(orig_conv);
26555         uint64_t ret_ref = (uint64_t)ret_copy;
26556         return ret_ref;
26557 }
26558
26559 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_sign_error() {
26560         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
26561         *ret_copy = SignOrCreationError_sign_error();
26562         uint64_t ret_ref = (uint64_t)ret_copy;
26563         return ret_ref;
26564 }
26565
26566 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_creation_error(uint32_t a) {
26567         LDKCreationError a_conv = LDKCreationError_from_js(a);
26568         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
26569         *ret_copy = SignOrCreationError_creation_error(a_conv);
26570         uint64_t ret_ref = (uint64_t)ret_copy;
26571         return ret_ref;
26572 }
26573
26574 jboolean  __attribute__((visibility("default"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
26575         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
26576         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
26577         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
26578         return ret_val;
26579 }
26580
26581 jstring  __attribute__((visibility("default"))) TS_SignOrCreationError_to_str(uint32_t o) {
26582         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
26583         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
26584         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26585         Str_free(ret_str);
26586         return ret_conv;
26587 }
26588
26589 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) {
26590         LDKChannelManager channelmanager_conv;
26591         channelmanager_conv.inner = (void*)(channelmanager & (~1));
26592         channelmanager_conv.is_owned = false;
26593         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
26594         LDKCurrency network_conv = LDKCurrency_from_js(network);
26595         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
26596         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1));
26597         LDKStr description_conv = str_ref_to_owned_c(description);
26598         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26599         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
26600         return (uint64_t)ret_conv;
26601 }
26602
26603 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_from_str(jstring s) {
26604         LDKStr s_conv = str_ref_to_owned_c(s);
26605         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
26606         *ret_conv = SiPrefix_from_str(s_conv);
26607         return (uint64_t)ret_conv;
26608 }
26609
26610 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_str(jstring s) {
26611         LDKStr s_conv = str_ref_to_owned_c(s);
26612         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
26613         *ret_conv = Invoice_from_str(s_conv);
26614         return (uint64_t)ret_conv;
26615 }
26616
26617 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_from_str(jstring s) {
26618         LDKStr s_conv = str_ref_to_owned_c(s);
26619         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
26620         *ret_conv = SignedRawInvoice_from_str(s_conv);
26621         return (uint64_t)ret_conv;
26622 }
26623
26624 jstring  __attribute__((visibility("default"))) TS_Invoice_to_str(uint32_t o) {
26625         LDKInvoice o_conv;
26626         o_conv.inner = (void*)(o & (~1));
26627         o_conv.is_owned = false;
26628         LDKStr ret_str = Invoice_to_str(&o_conv);
26629         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26630         Str_free(ret_str);
26631         return ret_conv;
26632 }
26633
26634 jstring  __attribute__((visibility("default"))) TS_SignedRawInvoice_to_str(uint32_t o) {
26635         LDKSignedRawInvoice o_conv;
26636         o_conv.inner = (void*)(o & (~1));
26637         o_conv.is_owned = false;
26638         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
26639         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26640         Str_free(ret_str);
26641         return ret_conv;
26642 }
26643
26644 jstring  __attribute__((visibility("default"))) TS_Currency_to_str(uint32_t o) {
26645         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
26646         LDKStr ret_str = Currency_to_str(o_conv);
26647         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26648         Str_free(ret_str);
26649         return ret_conv;
26650 }
26651
26652 jstring  __attribute__((visibility("default"))) TS_SiPrefix_to_str(uint32_t o) {
26653         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
26654         LDKStr ret_str = SiPrefix_to_str(o_conv);
26655         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26656         Str_free(ret_str);
26657         return ret_conv;
26658 }
26659